Commit cd90eca5 authored by Jiawei Ou's avatar Jiawei Ou Committed by Facebook Github Bot

OpenSSL adaptor for OpenSSL1.1.0

Summary: Implement some OpenSSL 1.1.0 specific methods, so that code written with OpenSSL 1.1.0 can be compiled with OpenSSL 1.0.2

Reviewed By: yfeldblum

Differential Revision: D6930234

fbshipit-source-id: 257893787cecdfeaf9df13dce0ada46c15990699
parent 8c0bca50
...@@ -114,6 +114,17 @@ EC_KEY* EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) { ...@@ -114,6 +114,17 @@ EC_KEY* EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) {
#endif #endif
#if !FOLLY_OPENSSL_IS_110 #if !FOLLY_OPENSSL_IS_110
BIO_METHOD* BIO_meth_new(int type, const char* name) {
BIO_METHOD* method = (BIO_METHOD*)OPENSSL_malloc(sizeof(BIO_METHOD));
if (method == nullptr) {
return nullptr;
}
memset(method, 0, sizeof(BIO_METHOD));
method->type = type;
method->name = name;
return method;
}
void BIO_meth_free(BIO_METHOD* biom) { void BIO_meth_free(BIO_METHOD* biom) {
OPENSSL_free((void*)biom); OPENSSL_free((void*)biom);
} }
...@@ -128,6 +139,55 @@ int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int)) { ...@@ -128,6 +139,55 @@ int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int)) {
return 1; return 1;
} }
int BIO_meth_set_puts(BIO_METHOD* biom, int (*bputs)(BIO*, const char*)) {
biom->bputs = bputs;
return 1;
}
int BIO_meth_set_gets(BIO_METHOD* biom, int (*bgets)(BIO*, char*, int)) {
biom->bgets = bgets;
return 1;
}
int BIO_meth_set_ctrl(BIO_METHOD* biom, long (*ctrl)(BIO*, int, long, void*)) {
biom->ctrl = ctrl;
return 1;
}
int BIO_meth_set_create(BIO_METHOD* biom, int (*create)(BIO*)) {
biom->create = create;
return 1;
}
int BIO_meth_set_destroy(BIO_METHOD* biom, int (*destroy)(BIO*)) {
biom->destroy = destroy;
return 1;
}
void BIO_set_data(BIO* bio, void* ptr) {
bio->ptr = ptr;
}
void* BIO_get_data(BIO* bio) {
return bio->ptr;
}
void BIO_set_init(BIO* bio, int init) {
bio->init = init;
}
void BIO_set_shutdown(BIO* bio, int shutdown) {
bio->shutdown = shutdown;
}
const SSL_METHOD* TLS_server_method(void) {
return TLSv1_2_server_method();
}
const SSL_METHOD* TLS_client_method(void) {
return TLSv1_2_client_method();
}
const char* SSL_SESSION_get0_hostname(const SSL_SESSION* s) { const char* SSL_SESSION_get0_hostname(const SSL_SESSION* s) {
return s->tlsext_hostname; return s->tlsext_hostname;
} }
......
...@@ -123,9 +123,23 @@ EC_KEY* EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey); ...@@ -123,9 +123,23 @@ EC_KEY* EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey);
#endif #endif
#if !FOLLY_OPENSSL_IS_110 #if !FOLLY_OPENSSL_IS_110
BIO_METHOD* BIO_meth_new(int type, const char* name);
void BIO_meth_free(BIO_METHOD* biom); void BIO_meth_free(BIO_METHOD* biom);
int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int)); int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int));
int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int)); int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int));
int BIO_meth_set_puts(BIO_METHOD* biom, int (*bputs)(BIO*, const char*));
int BIO_meth_set_gets(BIO_METHOD* biom, int (*bgets)(BIO*, char*, int));
int BIO_meth_set_ctrl(BIO_METHOD* biom, long (*ctrl)(BIO*, int, long, void*));
int BIO_meth_set_create(BIO_METHOD* biom, int (*create)(BIO*));
int BIO_meth_set_destroy(BIO_METHOD* biom, int (*destroy)(BIO*));
void BIO_set_data(BIO* bio, void* ptr);
void* BIO_get_data(BIO* bio);
void BIO_set_init(BIO* bio, int init);
void BIO_set_shutdown(BIO* bio, int shutdown);
const SSL_METHOD* TLS_server_method(void);
const SSL_METHOD* TLS_client_method(void);
const char* SSL_SESSION_get0_hostname(const SSL_SESSION* s); const char* SSL_SESSION_get0_hostname(const SSL_SESSION* s);
unsigned char* ASN1_STRING_get0_data(const ASN1_STRING* x); unsigned char* ASN1_STRING_get0_data(const ASN1_STRING* x);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment