cryptography.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from __future__ import absolute_import, division, print_function
  5. INCLUDES = """
  6. /* define our OpenSSL API compatibility level to 1.0.1. Any symbols older than
  7. that will raise an error during compilation. We can raise this number again
  8. after we drop 1.0.2 support in the distant future. */
  9. #define OPENSSL_API_COMPAT 0x10001000L
  10. #include <openssl/opensslv.h>
  11. #if defined(LIBRESSL_VERSION_NUMBER)
  12. #define CRYPTOGRAPHY_IS_LIBRESSL 1
  13. #else
  14. #define CRYPTOGRAPHY_IS_LIBRESSL 0
  15. #endif
  16. /*
  17. LibreSSL removed e_os2.h from the public headers so we'll only include it
  18. if we're using vanilla OpenSSL.
  19. */
  20. #if !CRYPTOGRAPHY_IS_LIBRESSL
  21. #include <openssl/e_os2.h>
  22. #endif
  23. #if defined(_WIN32)
  24. #define WIN32_LEAN_AND_MEAN
  25. #include <windows.h>
  26. #include <Wincrypt.h>
  27. #include <Winsock2.h>
  28. #endif
  29. #define CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER \
  30. (OPENSSL_VERSION_NUMBER >= 0x1010006f && !CRYPTOGRAPHY_IS_LIBRESSL)
  31. #define CRYPTOGRAPHY_OPENSSL_LESS_THAN_110J \
  32. (OPENSSL_VERSION_NUMBER < 0x101000af || CRYPTOGRAPHY_IS_LIBRESSL)
  33. #define CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 \
  34. (OPENSSL_VERSION_NUMBER < 0x10101000 || CRYPTOGRAPHY_IS_LIBRESSL)
  35. #define CRYPTOGRAPHY_OPENSSL_LESS_THAN_111B \
  36. (OPENSSL_VERSION_NUMBER < 0x10101020 || CRYPTOGRAPHY_IS_LIBRESSL)
  37. #define CRYPTOGRAPHY_OPENSSL_LESS_THAN_111D \
  38. (OPENSSL_VERSION_NUMBER < 0x10101040 || CRYPTOGRAPHY_IS_LIBRESSL)
  39. #if (CRYPTOGRAPHY_OPENSSL_LESS_THAN_111D && !CRYPTOGRAPHY_IS_LIBRESSL && \
  40. !defined(OPENSSL_NO_ENGINE)) || defined(USE_OSRANDOM_RNG_FOR_TESTING)
  41. #define CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE 1
  42. #else
  43. #define CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE 0
  44. #endif
  45. """
  46. TYPES = """
  47. static const int CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER;
  48. static const int CRYPTOGRAPHY_OPENSSL_LESS_THAN_111;
  49. static const int CRYPTOGRAPHY_OPENSSL_LESS_THAN_111B;
  50. static const int CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE;
  51. static const int CRYPTOGRAPHY_IS_LIBRESSL;
  52. """
  53. FUNCTIONS = """
  54. """
  55. CUSTOMIZATIONS = """
  56. """