get_ptr(mapOfMaps, key, key...)
[folly.git] / folly / portability / OpenSSL.cpp
1 /*
2  * Copyright 2017 Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <folly/portability/OpenSSL.h>
17
18 namespace folly {
19 namespace ssl {
20
21 #ifdef OPENSSL_IS_BORINGSSL
22 int SSL_CTX_set1_sigalgs_list(SSL_CTX*, const char*) {
23   return 1; // 0 implies error
24 }
25
26 int TLS1_get_client_version(SSL* s) {
27   return s->client_version;
28 }
29
30 int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int)) {
31   biom->bread = read;
32   return 1;
33 }
34
35 int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int)) {
36   biom->bwrite = write;
37   return 1;
38 }
39
40 #elif FOLLY_OPENSSL_IS_102 || FOLLY_OPENSSL_IS_101
41 int SSL_CTX_up_ref(SSL_CTX* ctx) {
42   return CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
43 }
44
45 int SSL_SESSION_up_ref(SSL_SESSION* session) {
46   return CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION);
47 }
48
49 int X509_up_ref(X509* x) {
50   return CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
51 }
52
53 int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int)) {
54   biom->bread = read;
55   return 1;
56 }
57
58 int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int)) {
59   biom->bwrite = write;
60   return 1;
61 }
62
63 #elif FOLLY_OPENSSL_IS_110
64
65 #endif
66 }
67 }