15#include <openssl/opensslv.h>
17#if OPENSSL_VERSION_NUMBER < 0x30000000L
20#include <openssl/evp.h>
21#include <openssl/ec.h>
22#include <openssl/objects.h>
33 if (EVP_PKEY_get0_EC_KEY(pkey) ==
nullptr)
37 const EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);
38 const EC_GROUP *group = EC_KEY_get0_group(ec);
40 int nid = EC_GROUP_get_curve_name(group);
46 const char *curve = OBJ_nid2sn(nid);
48 std::strncpy(gname, curve, gname_sz - 1);
49 *gname_len = std::strlen(curve);
55static inline const EVP_CIPHER *
60 const EVP_CIPHER *cipher = EVP_get_cipherbyname(algorithm);
65 if (FIPS_mode() && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_FIPS))
73static inline EVP_PKEY *
81 return PEM_read_bio_PrivateKey(bp, x, cb, u);
91static inline SSL_CTX *
94 return SSL_CTX_new(meth);
101#define EVP_PKEY_get_bits EVP_PKEY_bits
103static inline const EVP_MD *
106 return EVP_get_digestbyname(algorithm);
116#if OPENSSL_VERSION_NUMBER < 0x30200000L && OPENSSL_VERSION_NUMBER >= 0x30000000L
117static inline const char *
118SSL_get0_group_name(SSL *s)
122 int nid =
static_cast<int>(SSL_get_negotiated_group(s));
123 return SSL_group_to_name(s, nid);
static void EVP_CIPHER_free(const EVP_CIPHER *cipher)
static SSL_CTX * SSL_CTX_new_ex(void *libctx, const char *propq, const SSL_METHOD *meth)
static const EVP_CIPHER * EVP_CIPHER_fetch(void *ctx, const char *algorithm, const char *properties)
static EVP_PKEY * PEM_read_bio_PrivateKey_ex(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u, void *libctx, const char *propq)
static void OSSL_LIB_CTX_free(void *libctx)
static void EVP_MD_free(const EVP_MD *md)
static int EVP_PKEY_get_group_name(EVP_PKEY *pkey, char *gname, size_t gname_sz, size_t *gname_len)
static const EVP_MD * EVP_MD_fetch(void *, const char *algorithm, const char *)