Skip to content

Commit 3e243ab

Browse files
committed
Merge pull request pyca#2832 from reaperhulk/110-patch-38
in 1.1.0 OpenSSL does its own locking now! locking funcs are now macros
2 parents 09b768a + e55b381 commit 3e243ab

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/_cffi_src/openssl/crypto.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"""
1010

1111
TYPES = """
12+
static const long Cryptography_HAS_LOCKING_CALLBACKS;
13+
1214
typedef ... CRYPTO_THREADID;
1315
1416
static const int SSLEAY_VERSION;
@@ -28,7 +30,6 @@
2830
static const int CRYPTO_LOCK;
2931
static const int CRYPTO_UNLOCK;
3032
static const int CRYPTO_READ;
31-
static const int CRYPTO_WRITE;
3233
static const int CRYPTO_LOCK_SSL;
3334
"""
3435

@@ -38,14 +39,16 @@
3839
int CRYPTO_is_mem_check_on(void);
3940
void CRYPTO_mem_leaks(struct bio_st *);
4041
void CRYPTO_cleanup_all_ex_data(void);
41-
int CRYPTO_num_locks(void);
42-
void CRYPTO_set_locking_callback(void(*)(int, int, const char *, int));
43-
void (*CRYPTO_get_locking_callback(void))(int, int, const char *, int);
44-
void CRYPTO_lock(int, int, const char *, int);
4542
4643
"""
4744

4845
MACROS = """
46+
/* as of 1.1.0 OpenSSL does its own locking *angelic chorus*. These functions
47+
have become macros that are no ops */
48+
int CRYPTO_num_locks(void);
49+
void CRYPTO_set_locking_callback(void(*)(int, int, const char *, int));
50+
void (*CRYPTO_get_locking_callback(void))(int, int, const char *, int);
51+
4952
/* SSLeay was removed in 1.1.0 */
5053
unsigned long SSLeay(void);
5154
const char *SSLeay_version(int);
@@ -57,6 +60,9 @@
5760
5861
/* this is a macro in 1.1.0 */
5962
void OPENSSL_free(void *);
63+
64+
/* This was removed in 1.1.0 */
65+
void CRYPTO_lock(int, int, const char *, int);
6066
"""
6167

6268
CUSTOMIZATIONS = """
@@ -83,4 +89,14 @@
8389
# define OPENSSL_PLATFORM SSLEAY_PLATFORM
8490
# define OPENSSL_DIR SSLEAY_DIR
8591
#endif
92+
#if !defined(CRYPTO_LOCK)
93+
static const long Cryptography_HAS_LOCKING_CALLBACKS = 0;
94+
static const long CRYPTO_LOCK = 0;
95+
static const long CRYPTO_UNLOCK = 0;
96+
static const long CRYPTO_READ = 0;
97+
static const long CRYPTO_LOCK_SSL = 0;
98+
void (*CRYPTO_lock)(int, int, const char *, int) = NULL;
99+
#else
100+
static const long Cryptography_HAS_LOCKING_CALLBACKS = 1;
101+
#endif
86102
"""

src/cryptography/hazmat/bindings/openssl/_conditional.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,11 @@
412412
"TLS_ST_BEFORE",
413413
"TLS_ST_OK",
414414
],
415+
"Cryptography_HAS_LOCKING_CALLBACKS": [
416+
"CRYPTO_LOCK",
417+
"CRYPTO_UNLOCK",
418+
"CRYPTO_READ",
419+
"CRYPTO_LOCK_SSL",
420+
"CRYPTO_lock",
421+
]
415422
}

0 commit comments

Comments
 (0)