Skip to content

Commit d19bf2f

Browse files
committed
use a macro for checking OPENSSL_VERSION_NUMBER >= 0x30000000L
1 parent 80284b5 commit d19bf2f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Modules/_hashopenssl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
#include <stdbool.h>
4040

41+
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
42+
# define Py_HAS_OPENSSL3_SUPPORT
43+
#endif
44+
4145
#ifndef OPENSSL_THREADS
4246
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
4347
#endif
@@ -55,7 +59,7 @@
5559
#define PY_OPENSSL_HAS_BLAKE2 1
5660
#endif
5761

58-
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
62+
#ifdef Py_HAS_OPENSSL3_SUPPORT
5963
#define PY_EVP_MD EVP_MD
6064
#define PY_EVP_MD_fetch(algorithm, properties) EVP_MD_fetch(NULL, algorithm, properties)
6165
#define PY_EVP_MD_up_ref(md) EVP_MD_up_ref(md)
@@ -1926,7 +1930,7 @@ typedef struct _internal_name_mapper_state {
19261930

19271931
/* A callback function to pass to OpenSSL's OBJ_NAME_do_all(...) */
19281932
static void
1929-
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
1933+
#ifdef Py_HAS_OPENSSL3_SUPPORT
19301934
_openssl_hash_name_mapper(EVP_MD *md, void *arg)
19311935
#else
19321936
_openssl_hash_name_mapper(const EVP_MD *md, const char *from,
@@ -1966,7 +1970,7 @@ hashlib_md_meth_names(PyObject *module)
19661970
return -1;
19671971
}
19681972

1969-
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
1973+
#ifdef Py_HAS_OPENSSL3_SUPPORT
19701974
// get algorithms from all activated providers in default context
19711975
EVP_MD_do_all_provided(NULL, &_openssl_hash_name_mapper, &state);
19721976
#else
@@ -1999,7 +2003,7 @@ _hashlib_get_fips_mode_impl(PyObject *module)
19992003
/*[clinic end generated code: output=87eece1bab4d3fa9 input=2db61538c41c6fef]*/
20002004

20012005
{
2002-
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2006+
#ifdef Py_HAS_OPENSSL3_SUPPORT
20032007
return EVP_default_properties_is_fips_enabled(NULL);
20042008
#else
20052009
ERR_clear_error();

0 commit comments

Comments
 (0)