mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 18:12:57 +01:00
b077aed33b
Migrate to OpenSSL 3.0 in advance of FreeBSD 14.0. OpenSSL 1.1.1 (the version we were previously using) will be EOL as of 2023-09-11. Most of the base system has already been updated for a seamless switch to OpenSSL 3.0. For many components we've added `-DOPENSSL_API_COMPAT=0x10100000L` to CFLAGS to specify the API version, which avoids deprecation warnings from OpenSSL 3.0. Changes have also been made to avoid OpenSSL APIs that were already deprecated in OpenSSL 1.1.1. The process of updating to contemporary APIs can continue after this merge. Additional changes are still required for libarchive and Kerberos- related libraries or tools; workarounds will immediately follow this commit. Fixes are in progress in the upstream projects and will be incorporated when those are next updated. There are some performance regressions in benchmarks (certain tests in `openssl speed`) and in some OpenSSL consumers in ports (e.g. haproxy). Investigation will continue for these. Netflix's testing showed no functional regression and a rather small, albeit statistically significant, increase in CPU consumption with OpenSSL 3.0. Thanks to ngie@ and des@ for updating base system components, to antoine@ and bofh@ for ports exp-runs and port fixes/workarounds, and to Netflix and everyone who tested prior to commit or contributed to this update in other ways. PR: 271615 PR: 271656 [exp-run] Relnotes: Yes Sponsored by: The FreeBSD Foundation
96 lines
2.2 KiB
C
96 lines
2.2 KiB
C
/*
|
|
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
*
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#ifndef OSSL_ENGINES_E_AFALG_H
|
|
# define OSSL_ENGINES_E_AFALG_H
|
|
|
|
# if defined(__GNUC__) && __GNUC__ >= 4 && \
|
|
(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
|
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
|
# endif
|
|
|
|
# ifdef ALG_DEBUG
|
|
# define ALG_DGB(x, ...) fprintf(stderr, "ALG_DBG: " x, __VA_ARGS__)
|
|
# define ALG_INFO(x, ...) fprintf(stderr, "ALG_INFO: " x, __VA_ARGS__)
|
|
# define ALG_WARN(x, ...) fprintf(stderr, "ALG_WARN: " x, __VA_ARGS__)
|
|
# else
|
|
# define ALG_DGB(x, ...)
|
|
# define ALG_INFO(x, ...)
|
|
# define ALG_WARN(x, ...)
|
|
# endif
|
|
|
|
# define ALG_ERR(x, ...) fprintf(stderr, "ALG_ERR: " x, __VA_ARGS__)
|
|
# define ALG_PERR(x, ...) \
|
|
do { \
|
|
fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
|
|
perror(NULL); \
|
|
} while(0)
|
|
# define ALG_PWARN(x, ...) \
|
|
do { \
|
|
fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
|
|
perror(NULL); \
|
|
} while(0)
|
|
|
|
# ifndef AES_BLOCK_SIZE
|
|
# define AES_BLOCK_SIZE 16
|
|
# endif
|
|
# define AES_KEY_SIZE_128 16
|
|
# define AES_KEY_SIZE_192 24
|
|
# define AES_KEY_SIZE_256 32
|
|
# define AES_IV_LEN 16
|
|
|
|
# define MAX_INFLIGHTS 1
|
|
|
|
typedef enum {
|
|
MODE_UNINIT = 0,
|
|
MODE_SYNC,
|
|
MODE_ASYNC
|
|
} op_mode;
|
|
|
|
enum {
|
|
AES_CBC_128 = 0,
|
|
AES_CBC_192,
|
|
AES_CBC_256
|
|
};
|
|
|
|
struct cbc_cipher_handles {
|
|
int key_size;
|
|
EVP_CIPHER *_hidden;
|
|
};
|
|
|
|
typedef struct cbc_cipher_handles cbc_handles;
|
|
|
|
struct afalg_aio_st {
|
|
int efd;
|
|
op_mode mode;
|
|
aio_context_t aio_ctx;
|
|
struct io_event events[MAX_INFLIGHTS];
|
|
struct iocb cbt[MAX_INFLIGHTS];
|
|
};
|
|
typedef struct afalg_aio_st afalg_aio;
|
|
|
|
/*
|
|
* MAGIC Number to identify correct initialisation
|
|
* of afalg_ctx.
|
|
*/
|
|
# define MAGIC_INIT_NUM 0x1890671
|
|
|
|
struct afalg_ctx_st {
|
|
int init_done;
|
|
int sfd;
|
|
int bfd;
|
|
# ifdef ALG_ZERO_COPY
|
|
int zc_pipe[2];
|
|
# endif
|
|
afalg_aio aio;
|
|
};
|
|
|
|
typedef struct afalg_ctx_st afalg_ctx;
|
|
#endif
|