Bump copyright date to 2019
[tor.git] / src / lib / crypt_ops / crypto_openssl_mgt.h
blob83fb44cadf89b634e92debbc5321f1efd0da64e2
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/engine.h>
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.
26 Don't use this directly, instead use one of the other OPENSSL_V macros
27 below.
29 The format is: 4 bits major, 8 bits minor, 8 bits fix, 8 bits patch, 4 bit
30 status.
32 #define OPENSSL_VER(a,b,c,d,e) \
33 (((a)<<28) | \
34 ((b)<<20) | \
35 ((c)<<12) | \
36 ((d)<< 4) | \
37 (e))
38 /** An openssl release number. For example, OPENSSL_V(0,9,8,'j') is the
39 * version for the released version of 0.9.8j */
40 #define OPENSSL_V(a,b,c,d) \
41 OPENSSL_VER((a),(b),(c),(d)-'a'+1,0xf)
42 /** An openssl release number for the first release in the series. For
43 * example, OPENSSL_V_NOPATCH(1,0,0) is the first released version of OpenSSL
44 * 1.0.0. */
45 #define OPENSSL_V_NOPATCH(a,b,c) \
46 OPENSSL_VER((a),(b),(c),0,0xf)
47 /** The first version that would occur for any alpha or beta in an openssl
48 * series. For example, OPENSSL_V_SERIES(0,9,8) is greater than any released
49 * 0.9.7, and less than any released 0.9.8. */
50 #define OPENSSL_V_SERIES(a,b,c) \
51 OPENSSL_VER((a),(b),(c),0,0)
53 #ifdef ANDROID
54 /* Android's OpenSSL seems to have removed all of its Engine support. */
55 #define DISABLE_ENGINES
56 #endif
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.
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).
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.
71 #define NEW_THREAD_API
72 #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
74 void crypto_openssl_log_errors(int severity, const char *doing);
76 /* global openssl state */
77 const char * crypto_openssl_get_version_str(void);
78 const char * crypto_openssl_get_header_version_str(void);
80 void crypto_openssl_early_init(void);
81 int crypto_openssl_late_init(int useAccel, const char *accelName,
82 const char *accelDir);
84 void crypto_openssl_thread_cleanup(void);
85 void crypto_openssl_global_cleanup(void);
87 #endif /* ENABLE_OPENSSL */
89 #endif /* !defined(TOR_CRYPTO_OPENSSL_H) */