compat_openssl.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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-2017, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_COMPAT_OPENSSL_H
  7. #define TOR_COMPAT_OPENSSL_H
  8. #include <openssl/opensslv.h>
  9. #include "crypto_openssl_mgt.h"
  10. /**
  11. * \file compat_openssl.h
  12. *
  13. * \brief compatibility definitions for working with different openssl forks
  14. **/
  15. #if !defined(LIBRESSL_VERSION_NUMBER) && \
  16. OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,1)
  17. #error "We require OpenSSL >= 1.0.1"
  18. #endif
  19. #if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && \
  20. ! defined(LIBRESSL_VERSION_NUMBER)
  21. /* We define this macro if we're trying to build with the majorly refactored
  22. * API in OpenSSL 1.1 */
  23. #define OPENSSL_1_1_API
  24. #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && ... */
  25. #ifndef OPENSSL_VERSION
  26. #define OPENSSL_VERSION SSLEAY_VERSION
  27. #endif
  28. #ifndef OPENSSL_1_1_API
  29. #define OpenSSL_version(v) SSLeay_version(v)
  30. #define OpenSSL_version_num() SSLeay()
  31. #define RAND_OpenSSL() RAND_SSLeay()
  32. #define STATE_IS_SW_SERVER_HELLO(st) \
  33. (((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
  34. ((st) == SSL3_ST_SW_SRVR_HELLO_B))
  35. #define OSSL_HANDSHAKE_STATE int
  36. #define CONST_IF_OPENSSL_1_1_API
  37. #else /* !(!defined(OPENSSL_1_1_API)) */
  38. #define STATE_IS_SW_SERVER_HELLO(st) \
  39. ((st) == TLS_ST_SW_SRVR_HELLO)
  40. #define CONST_IF_OPENSSL_1_1_API const
  41. #endif /* !defined(OPENSSL_1_1_API) */
  42. #endif /* !defined(TOR_COMPAT_OPENSSL_H) */