tor  0.4.2.0-alpha-dev
crypto_openssl_mgt.h
Go to the documentation of this file.
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 */
6 
13 #ifndef TOR_CRYPTO_OPENSSL_H
14 #define TOR_CRYPTO_OPENSSL_H
15 
16 #include "orconfig.h"
17 
18 #ifdef ENABLE_OPENSSL
19 #include <openssl/engine.h>
20 
21 /*
22  Macro to create an arbitrary OpenSSL version number as used by
23  OPENSSL_VERSION_NUMBER or SSLeay(), since the actual numbers are a bit hard
24  to read.
25 
26  Don't use this directly, instead use one of the other OPENSSL_V macros
27  below.
28 
29  The format is: 4 bits major, 8 bits minor, 8 bits fix, 8 bits patch, 4 bit
30  status.
31  */
32 #define OPENSSL_VER(a,b,c,d,e) \
33  (((a)<<28) | \
34  ((b)<<20) | \
35  ((c)<<12) | \
36  ((d)<< 4) | \
37  (e))
38 
40 #define OPENSSL_V(a,b,c,d) \
41  OPENSSL_VER((a),(b),(c),(d)-'a'+1,0xf)
42 
45 #define OPENSSL_V_NOPATCH(a,b,c) \
46  OPENSSL_VER((a),(b),(c),0,0xf)
47 
50 #define OPENSSL_V_SERIES(a,b,c) \
51  OPENSSL_VER((a),(b),(c),0,0)
52 
53 #ifdef OPENSSL_NO_ENGINE
54 /* Android's OpenSSL seems to have removed all of its Engine support. */
55 #define DISABLE_ENGINES
56 #endif
57 
58 #if OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && \
59  !defined(LIBRESSL_VERSION_NUMBER)
60 /* OpenSSL as of 1.1.0pre4 has an "new" thread API, which doesn't require
61  * seting up various callbacks.
62  *
63  * OpenSSL 1.1.0pre4 has a messed up `ERR_remove_thread_state()` prototype,
64  * while the previous one was restored in pre5, and the function made a no-op
65  * (along with a deprecated annotation, which produces a compiler warning).
66  *
67  * While it is possible to support all three versions of the thread API,
68  * a version that existed only for one snapshot pre-release is kind of
69  * pointless, so let's not.
70  */
71 #define NEW_THREAD_API
72 #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
73 
74 void crypto_openssl_log_errors(int severity, const char *doing);
75 
76 /* global openssl state */
77 const char * crypto_openssl_get_version_str(void);
78 const char * crypto_openssl_get_header_version_str(void);
79 
80 void crypto_openssl_early_init(void);
81 int crypto_openssl_late_init(int useAccel, const char *accelName,
82  const char *accelDir);
83 
86 
87 #endif /* defined(ENABLE_OPENSSL) */
88 
89 #endif /* !defined(TOR_CRYPTO_OPENSSL_H) */
void crypto_openssl_early_init(void)
void crypto_openssl_global_cleanup(void)
void crypto_openssl_thread_cleanup(void)
void crypto_openssl_log_errors(int severity, const char *doing)
int crypto_openssl_late_init(int useAccel, const char *accelName, const char *accelDir)