compat_openssl.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_1_1_API
  26. #define OPENSSL_VERSION SSLEAY_VERSION
  27. #define OpenSSL_version(v) SSLeay_version(v)
  28. #define OpenSSL_version_num() SSLeay()
  29. #define RAND_OpenSSL() RAND_SSLeay()
  30. #define STATE_IS_SW_SERVER_HELLO(st) \
  31. (((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
  32. ((st) == SSL3_ST_SW_SRVR_HELLO_B))
  33. #define OSSL_HANDSHAKE_STATE int
  34. #define CONST_IF_OPENSSL_1_1_API
  35. #else /* !(!defined(OPENSSL_1_1_API)) */
  36. #define STATE_IS_SW_SERVER_HELLO(st) \
  37. ((st) == TLS_ST_SW_SRVR_HELLO)
  38. #define CONST_IF_OPENSSL_1_1_API const
  39. #endif /* !defined(OPENSSL_1_1_API) */
  40. #endif /* !defined(TOR_COMPAT_OPENSSL_H) */