compat_openssl.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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-2015, 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. #define OPENSSL_VERSION SSLEAY_VERSION
  19. #define OpenSSL_version(v) SSLeay_version(v)
  20. #define OpenSSL_version_num() SSLeay()
  21. #define RAND_OpenSSL() RAND_SSLeay()
  22. #define tor_ERR_remove_cur_thread_state() ERR_remove_state(0)
  23. #ifndef SSL_get_state
  24. #define SSL_get_state(ssl) SSL_state(ssl)
  25. #endif
  26. #define STATE_IS_SW_SERVER_HELLO(st) \
  27. (((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
  28. ((st) == SSL3_ST_SW_SRVR_HELLO_B))
  29. #define OSSL_HANDSHAKE_STATE int
  30. #else
  31. #define tor_ERR_remove_cur_thread_state() ERR_remove_thread_state(NULL)
  32. #define STATE_IS_SW_SERVER_HELLO(st) \
  33. ((st) == TLS_ST_SW_SRVR_HELLO)
  34. #endif
  35. #endif