compat_openssl.h 1.3 KB

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