22 namespace portability {
25 #ifdef OPENSSL_IS_BORINGSSL 26 int SSL_CTX_set1_sigalgs_list(SSL_CTX*,
const char*) {
30 int TLS1_get_client_version(SSL*
s) {
38 #if FOLLY_OPENSSL_IS_100 39 uint32_t SSL_CIPHER_get_id(
const SSL_CIPHER*
c) {
43 int TLS1_get_client_version(
const SSL* s) {
44 return (s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0;
48 #if FOLLY_OPENSSL_IS_100 || FOLLY_OPENSSL_IS_101 49 int X509_get_signature_nid(X509* cert) {
50 return OBJ_obj2nid(cert->sig_alg->algorithm);
54 #if FOLLY_OPENSSL_IS_100 || FOLLY_OPENSSL_IS_101 || FOLLY_OPENSSL_IS_102 55 int SSL_CTX_up_ref(SSL_CTX* ctx) {
56 return CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
59 int SSL_SESSION_up_ref(SSL_SESSION* session) {
60 return CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION);
63 int X509_up_ref(X509*
x) {
64 return CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
67 int X509_STORE_up_ref(X509_STORE*
v) {
68 return CRYPTO_add(&v->references, 1, CRYPTO_LOCK_X509_STORE);
71 int EVP_PKEY_up_ref(EVP_PKEY* evp) {
72 return CRYPTO_add(&evp->references, 1, CRYPTO_LOCK_EVP_PKEY);
91 RSA* EVP_PKEY_get0_RSA(EVP_PKEY* pkey) {
92 if (pkey->type != EVP_PKEY_RSA) {
95 return pkey->pkey.rsa;
98 DSA* EVP_PKEY_get0_DSA(EVP_PKEY* pkey) {
99 if (pkey->type != EVP_PKEY_DSA) {
102 return pkey->pkey.dsa;
105 DH* EVP_PKEY_get0_DH(EVP_PKEY* pkey) {
106 if (pkey->type != EVP_PKEY_DH) {
109 return pkey->pkey.dh;
112 EC_KEY* EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) {
113 if (pkey->type != EVP_PKEY_EC) {
116 return pkey->pkey.ec;
120 #if !FOLLY_OPENSSL_IS_110 122 BIO_METHOD* method = (BIO_METHOD*)OPENSSL_malloc(
sizeof(BIO_METHOD));
123 if (method ==
nullptr) {
126 memset(method, 0,
sizeof(BIO_METHOD));
133 OPENSSL_free((
void*)biom);
142 biom->bwrite =
write;
162 biom->create = create;
188 return TLSv1_2_server_method();
192 return TLSv1_2_client_method();
196 return s->tlsext_hostname;
200 return ASN1_STRING_data((ASN1_STRING*)x);
204 return (s->tlsext_ticklen > 0) ? 1 : 0;
208 return s->tlsext_tick_lifetime_hint;
216 if (dh ==
nullptr || (dh->p ==
nullptr && p ==
nullptr) ||
217 (dh->g ==
nullptr && g ==
nullptr)) {
264 const BIGNUM** pub_key,
265 const BIGNUM** priv_key) {
267 if (pub_key !=
nullptr) {
268 *pub_key = dh->pub_key;
270 if (priv_key !=
nullptr) {
271 *priv_key = dh->priv_key;
294 const BIGNUM** pub_key,
295 const BIGNUM** priv_key) {
297 if (pub_key !=
nullptr) {
298 *pub_key = dsa->pub_key;
300 if (priv_key !=
nullptr) {
301 *priv_key = dsa->priv_key;
305 STACK_OF(X509_OBJECT) * X509_STORE_get0_objects(X509_STORE* store) {
313 STACK_OF(X509) * X509_STORE_CTX_get0_chain(X509_STORE_CTX* ctx) {
314 return X509_STORE_CTX_get_chain(ctx);
317 STACK_OF(X509) * X509_STORE_CTX_get0_untrusted(X509_STORE_CTX* ctx) {
318 return ctx->untrusted;
322 EVP_MD_CTX* ctx = (EVP_MD_CTX*)OPENSSL_malloc(
sizeof(EVP_MD_CTX));
324 throw std::runtime_error(
"Cannot allocate EVP_MD_CTX");
326 EVP_MD_CTX_init(ctx);
332 EVP_MD_CTX_cleanup(ctx);
338 HMAC_CTX* ctx = (HMAC_CTX*)OPENSSL_malloc(
sizeof(HMAC_CTX));
340 throw std::runtime_error(
"Cannot allocate HMAC_CTX");
348 HMAC_CTX_cleanup(ctx);
360 if ((r->n ==
nullptr && n ==
nullptr) || (r->e ==
nullptr && e ==
nullptr)) {
392 const BIGNUM** iqmp) {
394 if (dmp1 !=
nullptr) {
397 if (dmq1 !=
nullptr) {
400 if (iqmp !=
nullptr) {
407 if (r ==
nullptr || s ==
nullptr) {
410 BN_clear_free(sig->r);
411 BN_clear_free(sig->s);
418 const ECDSA_SIG*
sig,
442 OpenSSL_add_all_ciphers();
443 OpenSSL_add_all_digests();
444 OpenSSL_add_all_algorithms();
446 SSL_load_error_strings();
447 ERR_load_crypto_strings();
457 CRYPTO_cleanup_all_ex_data();
464 return r->serialNumber;
468 return r->revocationDate;
480 return x->ex_xkusage;
488 if (obj ==
nullptr || obj->type != X509_LU_X509) {
491 return obj->data.x509;
495 return X509_CRL_get_lastUpdate(crl);
499 return X509_CRL_get_nextUpdate(crl);
503 return x->cert_info->signature;
506 #endif // !FOLLY_OPENSSL_IS_110
X509 * X509_OBJECT_get0_X509(const X509_OBJECT *obj)
const X509_ALGOR * X509_get0_tbs_sigalg(const X509 *x)
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
void write(const T &in, folly::io::Appender &appender)
void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
void BIO_set_data(BIO *bio, void *ptr)
int BIO_meth_set_destroy(BIO_METHOD *biom, int(*destroy)(BIO *))
void cleanupThreadingLocks()
bool RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
const ASN1_INTEGER * X509_REVOKED_get0_serialNumber(const X509_REVOKED *r)
STACK_OF(X509_OBJECT)*X509_STORE_get0_objects(X509_STORE *store)
X509 * X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx)
int BIO_meth_set_create(BIO_METHOD *biom, int(*create)(BIO *))
unsigned char * ASN1_STRING_get0_data(const ASN1_STRING *x)
void BIO_meth_free(BIO_METHOD *biom)
void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
—— Concurrent Priority Queue Implementation ——
int OPENSSL_init_ssl(uint64_t, const OPENSSL_INIT_SETTINGS *)
const SSL_METHOD * TLS_client_method(void)
int BIO_meth_set_write(BIO_METHOD *biom, int(*write)(BIO *, const char *, int))
void installThreadingLocks()
void * BIO_get_data(BIO *bio)
void init(int *argc, char ***argv, bool removeFlags)
uint32_t X509_get_extended_key_usage(X509 *x)
int BIO_meth_set_gets(BIO_METHOD *biom, int(*bgets)(BIO *, char *, int))
HMAC_CTX * HMAC_CTX_new()
int SSL_SESSION_has_ticket(const SSL_SESSION *s)
int BIO_meth_set_ctrl(BIO_METHOD *biom, long(*ctrl)(BIO *, int, long, void *))
uint32_t X509_get_extension_flags(X509 *x)
size_t read(T &out, folly::io::Cursor &cursor)
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
const ASN1_TIME * X509_CRL_get0_nextUpdate(const X509_CRL *crl)
const ASN1_TIME * X509_REVOKED_get0_revocationDate(const X509_REVOKED *r)
void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp)
const ASN1_TIME * X509_CRL_get0_lastUpdate(const X509_CRL *crl)
uint32_t X509_get_key_usage(X509 *x)
void DSA_get0_pqg(const DSA *dsa, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
constexpr detail::Sig< Sig > const sig
void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
const char * SSL_SESSION_get0_hostname(const SSL_SESSION *s)
void BIO_set_init(BIO *bio, int init)
const SSL_METHOD * TLS_server_method(void)
void BIO_set_shutdown(BIO *bio, int shutdown)
unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s)
int X509_OBJECT_get_type(const X509_OBJECT *obj)
void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
void DSA_get0_key(const DSA *dsa, const BIGNUM **pub_key, const BIGNUM **priv_key)
EVP_MD_CTX * EVP_MD_CTX_new()
void HMAC_CTX_free(HMAC_CTX *ctx)
BIO_METHOD * BIO_meth_new(int type, const char *name)
void OPENSSL_INIT_SETTINGS
int BIO_meth_set_puts(BIO_METHOD *biom, int(*bputs)(BIO *, const char *))
int BIO_meth_set_read(BIO_METHOD *biom, int(*read)(BIO *, char *, int))