summaryrefslogtreecommitdiff
path: root/src/common/compat_openssl.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-11-10 10:02:21 -0500
committerNick Mathewson <nickm@torproject.org>2015-11-10 10:02:21 -0500
commitc32a43a4d2bbd2be89888fc5a253e55c72bb466a (patch)
treef02dd76f2498fa0f3ddddea7b39c47ff44b94a0d /src/common/compat_openssl.h
parent6512df34a4696a3adb1a2b3207fe7c886376aac5 (diff)
downloadtor-c32a43a4d2bbd2be89888fc5a253e55c72bb466a.tar.gz
tor-c32a43a4d2bbd2be89888fc5a253e55c72bb466a.zip
Move openssl version compatibility defines into a new header.
Diffstat (limited to 'src/common/compat_openssl.h')
-rw-r--r--src/common/compat_openssl.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/common/compat_openssl.h b/src/common/compat_openssl.h
new file mode 100644
index 0000000000..96c00c7993
--- /dev/null
+++ b/src/common/compat_openssl.h
@@ -0,0 +1,41 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2015, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_COMPAT_OPENSSL_H
+#define TOR_COMPAT_OPENSSL_H
+
+#include <openssl/opensslv.h>
+
+/**
+ * \file compat_openssl.h
+ *
+ * \brief compatability definitions for working with different openssl forks
+ **/
+
+#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,0)
+#error "We require OpenSSL >= 1.0.0"
+#endif
+
+#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,1,0)
+#define OPENSSL_VERSION SSLEAY_VERSION
+#define OpenSSL_version(v) SSLeay_version(v)
+#define OpenSSL_version_num() SSLeay()
+#define RAND_OpenSSL() RAND_SSLeay()
+#define tor_ERR_remove_cur_thread_state() ERR_remove_state(0)
+#ifndef SSL_get_state
+#define SSL_get_state(ssl) SSL_state(ssl)
+#endif
+#define STATE_IS_SW_SERVER_HELLO(st) \
+ (((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
+ ((st) == SSL3_ST_SW_SRVR_HELLO_B))
+#define OSSL_HANDSHAKE_STATE int
+#else
+#define tor_ERR_remove_cur_thread_state() ERR_remove_thread_state(NULL)
+#define STATE_IS_SW_SERVER_HELLO(st) \
+ ((st) == TLS_ST_SW_SRVR_HELLO)
+#endif
+
+#endif