compat_openssl.h 1.6 KB

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