Tor  0.4.7.0-alpha-dev
compat_openssl.h
1 /* Copyright (c) 2001, Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 #ifndef TOR_COMPAT_OPENSSL_H
8 #define TOR_COMPAT_OPENSSL_H
9 
10 #include "orconfig.h"
11 
12 #ifdef ENABLE_OPENSSL
13 
14 #include <openssl/opensslv.h>
16 
17 /**
18  * \file compat_openssl.h
19  *
20  * \brief compatibility definitions for working with different openssl forks
21  **/
22 
23 #if !defined(LIBRESSL_VERSION_NUMBER) && \
24  OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,1)
25 #error "We require OpenSSL >= 1.0.1"
26 #endif
27 
28 #if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && \
29  ! defined(LIBRESSL_VERSION_NUMBER)
30 /* We define this macro if we're trying to build with the majorly refactored
31  * API in OpenSSL 1.1 */
32 #define OPENSSL_1_1_API
33 #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && ... */
34 
35 #ifndef OPENSSL_1_1_API
36 #define OpenSSL_version(v) SSLeay_version(v)
37 #define tor_OpenSSL_version_num() SSLeay()
38 #define RAND_OpenSSL() RAND_SSLeay()
39 #define STATE_IS_SW_SERVER_HELLO(st) \
40  (((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
41  ((st) == SSL3_ST_SW_SRVR_HELLO_B))
42 #define OSSL_HANDSHAKE_STATE int
43 #define CONST_IF_OPENSSL_1_1_API
44 #else /* defined(OPENSSL_1_1_API) */
45 #define tor_OpenSSL_version_num() OpenSSL_version_num()
46 #define STATE_IS_SW_SERVER_HELLO(st) \
47  ((st) == TLS_ST_SW_SRVR_HELLO)
48 #define CONST_IF_OPENSSL_1_1_API const
49 #endif /* !defined(OPENSSL_1_1_API) */
50 
51 #endif /* defined(ENABLE_OPENSSL) */
52 
53 #endif /* !defined(TOR_COMPAT_OPENSSL_H) */
Headers for crypto_openssl_mgt.c.