|
38 | 38 |
|
39 | 39 | #include <stdbool.h> |
40 | 40 |
|
| 41 | +#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 42 | +# define Py_HAS_OPENSSL3_SUPPORT |
| 43 | +#endif |
| 44 | + |
41 | 45 | #ifndef OPENSSL_THREADS |
42 | 46 | # error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" |
43 | 47 | #endif |
|
55 | 59 | #define PY_OPENSSL_HAS_BLAKE2 1 |
56 | 60 | #endif |
57 | 61 |
|
58 | | -#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 62 | +#ifdef Py_HAS_OPENSSL3_SUPPORT |
59 | 63 | #define PY_EVP_MD EVP_MD |
60 | 64 | #define PY_EVP_MD_fetch(algorithm, properties) EVP_MD_fetch(NULL, algorithm, properties) |
61 | 65 | #define PY_EVP_MD_up_ref(md) EVP_MD_up_ref(md) |
@@ -1926,7 +1930,7 @@ typedef struct _internal_name_mapper_state { |
1926 | 1930 |
|
1927 | 1931 | /* A callback function to pass to OpenSSL's OBJ_NAME_do_all(...) */ |
1928 | 1932 | static void |
1929 | | -#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 1933 | +#ifdef Py_HAS_OPENSSL3_SUPPORT |
1930 | 1934 | _openssl_hash_name_mapper(EVP_MD *md, void *arg) |
1931 | 1935 | #else |
1932 | 1936 | _openssl_hash_name_mapper(const EVP_MD *md, const char *from, |
@@ -1966,7 +1970,7 @@ hashlib_md_meth_names(PyObject *module) |
1966 | 1970 | return -1; |
1967 | 1971 | } |
1968 | 1972 |
|
1969 | | -#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 1973 | +#ifdef Py_HAS_OPENSSL3_SUPPORT |
1970 | 1974 | // get algorithms from all activated providers in default context |
1971 | 1975 | EVP_MD_do_all_provided(NULL, &_openssl_hash_name_mapper, &state); |
1972 | 1976 | #else |
@@ -1999,7 +2003,7 @@ _hashlib_get_fips_mode_impl(PyObject *module) |
1999 | 2003 | /*[clinic end generated code: output=87eece1bab4d3fa9 input=2db61538c41c6fef]*/ |
2000 | 2004 |
|
2001 | 2005 | { |
2002 | | -#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 2006 | +#ifdef Py_HAS_OPENSSL3_SUPPORT |
2003 | 2007 | return EVP_default_properties_is_fips_enabled(NULL); |
2004 | 2008 | #else |
2005 | 2009 | ERR_clear_error(); |
|
0 commit comments