35#ifndef OPENSSL_COMPAT_H_
36#define OPENSSL_COMPAT_H_
44#include <openssl/rsa.h>
45#include <openssl/ssl.h>
46#include <openssl/x509.h>
47#include <openssl/err.h>
50#if OPENSSL_VERSION_NUMBER < 0x10101000L && !defined(ENABLE_CRYPTO_WOLFSSL)
51#define SSL_CTX_set1_groups SSL_CTX_set1_curves
55#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL
62X509_OBJECT_free(X509_OBJECT *obj)
66 X509_OBJECT_free_contents(obj);
71#define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
72#define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
75#if defined(LIBRESSL_VERSION_NUMBER)
76#define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT RSA_F_RSA_EAY_PRIVATE_ENCRYPT
79#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050400fL || defined(OPENSSL_IS_AWSLC)
80#define SSL_get_peer_tmp_key SSL_get_server_tmp_key
84#if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined(OPENSSL_NO_EC)
94 const EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);
99 const EC_GROUP *group = EC_KEY_get0_group(ec);
100 int nid = EC_GROUP_get_curve_name(group);
106 const char *curve = OBJ_nid2sn(nid);
109 curve =
"(error fetching curve name)";
115 *gname_len = strlen(curve);
120#if OPENSSL_VERSION_NUMBER < 0x30000000L
121#define EVP_MD_get0_name EVP_MD_name
122#define EVP_CIPHER_get0_name EVP_CIPHER_name
123#define EVP_CIPHER_CTX_get_mode EVP_CIPHER_CTX_mode
126#define SSL_CTX_new_ex(libctx, propq, method) \
127 SSL_CTX_new((method))
135static inline const EVP_CIPHER *
140 return EVP_get_cipherbyname(algorithm);
143static inline const EVP_MD *
148 return EVP_get_digestbyname(algorithm);
163static inline unsigned long
166 const char **data,
int *flags)
168 static const char *empty =
"";
170 unsigned long err = ERR_get_error_line_data(file, line, data, flags);
static void strncpynt(char *dest, const char *src, size_t maxlen)
static void EVP_CIPHER_free(const EVP_CIPHER *cipher)
static const EVP_CIPHER * EVP_CIPHER_fetch(void *ctx, const char *algorithm, const char *properties)
static unsigned long ERR_get_error_all(const char **file, int *line, const char **func, const char **data, int *flags)
static void EVP_MD_free(const EVP_MD *md)
static const EVP_MD * EVP_MD_fetch(void *ctx, const char *algorithm, const char *properties)
static int EVP_PKEY_get_group_name(EVP_PKEY *pkey, char *gname, size_t gname_sz, size_t *gname_len)