crypto_openssl_mgt.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file crypto_openssl_mgt.h
  8. *
  9. * \brief Headers for crypto_openssl_mgt.c
  10. **/
  11. #ifndef TOR_CRYPTO_OPENSSL_H
  12. #define TOR_CRYPTO_OPENSSL_H
  13. #include "orconfig.h"
  14. #ifdef ENABLE_OPENSSL
  15. #include <openssl/engine.h>
  16. /*
  17. Macro to create an arbitrary OpenSSL version number as used by
  18. OPENSSL_VERSION_NUMBER or SSLeay(), since the actual numbers are a bit hard
  19. to read.
  20. Don't use this directly, instead use one of the other OPENSSL_V macros
  21. below.
  22. The format is: 4 bits major, 8 bits minor, 8 bits fix, 8 bits patch, 4 bit
  23. status.
  24. */
  25. #define OPENSSL_VER(a,b,c,d,e) \
  26. (((a)<<28) | \
  27. ((b)<<20) | \
  28. ((c)<<12) | \
  29. ((d)<< 4) | \
  30. (e))
  31. /** An openssl release number. For example, OPENSSL_V(0,9,8,'j') is the
  32. * version for the released version of 0.9.8j */
  33. #define OPENSSL_V(a,b,c,d) \
  34. OPENSSL_VER((a),(b),(c),(d)-'a'+1,0xf)
  35. /** An openssl release number for the first release in the series. For
  36. * example, OPENSSL_V_NOPATCH(1,0,0) is the first released version of OpenSSL
  37. * 1.0.0. */
  38. #define OPENSSL_V_NOPATCH(a,b,c) \
  39. OPENSSL_VER((a),(b),(c),0,0xf)
  40. /** The first version that would occur for any alpha or beta in an openssl
  41. * series. For example, OPENSSL_V_SERIES(0,9,8) is greater than any released
  42. * 0.9.7, and less than any released 0.9.8. */
  43. #define OPENSSL_V_SERIES(a,b,c) \
  44. OPENSSL_VER((a),(b),(c),0,0)
  45. #ifdef ANDROID
  46. /* Android's OpenSSL seems to have removed all of its Engine support. */
  47. #define DISABLE_ENGINES
  48. #endif
  49. #if OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && \
  50. !defined(LIBRESSL_VERSION_NUMBER)
  51. /* OpenSSL as of 1.1.0pre4 has an "new" thread API, which doesn't require
  52. * seting up various callbacks.
  53. *
  54. * OpenSSL 1.1.0pre4 has a messed up `ERR_remove_thread_state()` prototype,
  55. * while the previous one was restored in pre5, and the function made a no-op
  56. * (along with a deprecated annotation, which produces a compiler warning).
  57. *
  58. * While it is possible to support all three versions of the thread API,
  59. * a version that existed only for one snapshot pre-release is kind of
  60. * pointless, so let's not.
  61. */
  62. #define NEW_THREAD_API
  63. #endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
  64. void crypto_openssl_log_errors(int severity, const char *doing);
  65. /* global openssl state */
  66. const char * crypto_openssl_get_version_str(void);
  67. const char * crypto_openssl_get_header_version_str(void);
  68. void crypto_openssl_early_init(void);
  69. int crypto_openssl_late_init(int useAccel, const char *accelName,
  70. const char *accelDir);
  71. void crypto_openssl_thread_cleanup(void);
  72. void crypto_openssl_global_cleanup(void);
  73. #endif /* ENABLE_OPENSSL */
  74. #endif /* !defined(TOR_CRYPTO_OPENSSL_H) */