Include a more modest openssl header in crypto_openssl_mgt.h
[tor.git] / src / lib / crypt_ops / crypto_openssl_mgt.h
blob8dbadfc9d2e6c17f0066162badccd7675589e6c7
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-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file crypto_openssl_mgt.h
10 * \brief Headers for crypto_openssl_mgt.c
11 **/
13 #ifndef TOR_CRYPTO_OPENSSL_H
14 #define TOR_CRYPTO_OPENSSL_H
16 #include "orconfig.h"
18 #ifdef ENABLE_OPENSSL
19 #include <openssl/opensslv.h>
21 Macro to create an arbitrary OpenSSL version number as used by
22 OPENSSL_VERSION_NUMBER or SSLeay(), since the actual numbers are a bit hard
23 to read.
25 Don't use this directly, instead use one of the other OPENSSL_V macros
26 below.
28 The format is: 4 bits major, 8 bits minor, 8 bits fix, 8 bits patch, 4 bit
29 status.
31 #define OPENSSL_VER(a,b,c,d,e) \
32 (((a)<<28) | \
33 ((b)<<20) | \
34 ((c)<<12) | \
35 ((d)<< 4) | \
36 (e))
37 /** An openssl release number. For example, OPENSSL_V(0,9,8,'j') is the
38 * version for the released version of 0.9.8j */
39 #define OPENSSL_V(a,b,c,d) \
40 OPENSSL_VER((a),(b),(c),(d)-'a'+1,0xf)
41 /** An openssl release number for the first release in the series. For
42 * example, OPENSSL_V_NOPATCH(1,0,0) is the first released version of OpenSSL
43 * 1.0.0. */
44 #define OPENSSL_V_NOPATCH(a,b,c) \
45 OPENSSL_VER((a),(b),(c),0,0xf)
46 /** The first version that would occur for any alpha or beta in an openssl
47 * series. For example, OPENSSL_V_SERIES(0,9,8) is greater than any released
48 * 0.9.7, and less than any released 0.9.8. */
49 #define OPENSSL_V_SERIES(a,b,c) \
50 OPENSSL_VER((a),(b),(c),0,0)
52 #ifdef OPENSSL_NO_ENGINE
53 /* Android's OpenSSL seems to have removed all of its Engine support. */
54 #define DISABLE_ENGINES
55 #endif
57 #if OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && \
58 !defined(LIBRESSL_VERSION_NUMBER)
59 /* OpenSSL as of 1.1.0pre4 has an "new" thread API, which doesn't require
60 * seting up various callbacks.
62 * OpenSSL 1.1.0pre4 has a messed up `ERR_remove_thread_state()` prototype,
63 * while the previous one was restored in pre5, and the function made a no-op
64 * (along with a deprecated annotation, which produces a compiler warning).
66 * While it is possible to support all three versions of the thread API,
67 * a version that existed only for one snapshot pre-release is kind of
68 * pointless, so let's not.
70 #define NEW_THREAD_API
71 #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
73 void crypto_openssl_log_errors(int severity, const char *doing);
75 /* global openssl state */
76 const char * crypto_openssl_get_version_str(void);
77 const char * crypto_openssl_get_header_version_str(void);
79 void crypto_openssl_early_init(void);
80 int crypto_openssl_late_init(int useAccel, const char *accelName,
81 const char *accelDir);
83 void crypto_openssl_thread_cleanup(void);
84 void crypto_openssl_global_cleanup(void);
86 #endif /* ENABLE_OPENSSL */
88 #endif /* !defined(TOR_CRYPTO_OPENSSL_H) */