1 | /* |
2 | Copyright (c) 2016, 2017 MariaDB Corporation |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
16 | |
17 | #include <openssl/opensslv.h> |
18 | |
19 | /* OpenSSL version specific definitions */ |
20 | #if !defined(HAVE_YASSL) && defined(OPENSSL_VERSION_NUMBER) |
21 | |
22 | #if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) |
23 | #define HAVE_X509_check_host 1 |
24 | #endif |
25 | |
26 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) |
27 | #define HAVE_OPENSSL11 1 |
28 | #define SSL_LIBRARY OpenSSL_version(OPENSSL_VERSION) |
29 | #define ERR_remove_state(X) ERR_clear_error() |
30 | #define EVP_CIPHER_CTX_SIZE 168 |
31 | #define EVP_MD_CTX_SIZE 48 |
32 | #undef EVP_MD_CTX_init |
33 | #define EVP_MD_CTX_init(X) do { bzero((X), EVP_MD_CTX_SIZE); EVP_MD_CTX_reset(X); } while(0) |
34 | #undef EVP_CIPHER_CTX_init |
35 | #define EVP_CIPHER_CTX_init(X) do { bzero((X), EVP_CIPHER_CTX_SIZE); EVP_CIPHER_CTX_reset(X); } while(0) |
36 | |
37 | /* |
38 | Macros below are deprecated. OpenSSL 1.1 may define them or not, |
39 | depending on how it was built. |
40 | */ |
41 | #undef ERR_free_strings |
42 | #define ERR_free_strings() |
43 | #undef EVP_cleanup |
44 | #define EVP_cleanup() |
45 | #undef CRYPTO_cleanup_all_ex_data |
46 | #define CRYPTO_cleanup_all_ex_data() |
47 | #undef SSL_load_error_strings |
48 | #define SSL_load_error_strings() |
49 | |
50 | #else |
51 | #define HAVE_OPENSSL10 1 |
52 | #define SSL_LIBRARY SSLeay_version(SSLEAY_VERSION) |
53 | |
54 | #ifdef HAVE_ERR_remove_thread_state |
55 | #define ERR_remove_state(X) ERR_remove_thread_state(NULL) |
56 | #endif /* HAVE_ERR_remove_thread_state */ |
57 | |
58 | #endif /* HAVE_OPENSSL11 */ |
59 | |
60 | #elif defined(HAVE_YASSL) |
61 | #define SSL_LIBRARY "YaSSL " YASSL_VERSION |
62 | #define BN_free(X) do { } while(0) |
63 | #endif /* !defined(HAVE_YASSL) */ |
64 | |
65 | #ifndef HAVE_OPENSSL11 |
66 | #define ASN1_STRING_get0_data(X) ASN1_STRING_data(X) |
67 | #define OPENSSL_init_ssl(X,Y) SSL_library_init() |
68 | #define DH_set0_pqg(D,P,Q,G) ((D)->p= (P), (D)->g= (G)) |
69 | #define EVP_CIPHER_CTX_buf_noconst(ctx) ((ctx)->buf) |
70 | #define EVP_CIPHER_CTX_encrypting(ctx) ((ctx)->encrypt) |
71 | #define EVP_CIPHER_CTX_SIZE sizeof(EVP_CIPHER_CTX) |
72 | #define EVP_MD_CTX_SIZE sizeof(EVP_MD_CTX) |
73 | |
74 | #define EVP_MD_CTX_reset(X) EVP_MD_CTX_cleanup(X) |
75 | #define EVP_CIPHER_CTX_reset(X) EVP_CIPHER_CTX_cleanup(X) |
76 | #define X509_get0_notBefore(X) X509_get_notBefore(X) |
77 | #define X509_get0_notAfter(X) X509_get_notAfter(X) |
78 | #endif |
79 | |
80 | #ifdef __cplusplus |
81 | extern "C" { |
82 | #endif /* __cplusplus */ |
83 | |
84 | int check_openssl_compatibility(); |
85 | |
86 | #ifdef __cplusplus |
87 | } |
88 | #endif |
89 | |