Skip to content

Commit e74b5f9

Browse files
committed
Check for BoringSSL in the bignum bindings
1 parent b3e20a1 commit e74b5f9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: src/_cffi_src/openssl/bignum.py

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"""
99

1010
TYPES = """
11+
static const long Cryptography_HAS_BN_FLAGS;
12+
1113
typedef ... BN_CTX;
1214
typedef ... BN_MONT_CTX;
1315
typedef ... BIGNUM;
@@ -81,4 +83,13 @@
8183
"""
8284

8385
CUSTOMIZATIONS = """
86+
#if CRYPTOGRAPHY_IS_BORINGSSL
87+
static const long Cryptography_HAS_BN_FLAGS = 0;
88+
89+
static const int BN_FLG_CONSTTIME = 0;
90+
void (*BN_set_flags)(BIGNUM *, int) = NULL;
91+
int (*BN_prime_checks_for_size)(int) = NULL;
92+
#else
93+
static const long Cryptography_HAS_BN_FLAGS = 1;
94+
#endif
8495
"""

Diff for: src/cryptography/hazmat/bindings/openssl/_conditional.py

+10
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ def cryptography_has_pkcs7_funcs():
279279
"PKCS7_get0_signers",
280280
]
281281

282+
283+
def cryptography_has_bn_flags():
284+
return [
285+
"BN_FLG_CONSTTIME",
286+
"BN_set_flags",
287+
"BN_prime_checks_for_size",
288+
]
289+
290+
282291
# This is a mapping of
283292
# {condition: function-returning-names-dependent-on-that-condition} so we can
284293
# loop over them and delete unsupported names at runtime. It will be removed
@@ -333,4 +342,5 @@ def cryptography_has_pkcs7_funcs():
333342
"Cryptography_HAS_300_FIPS": cryptography_has_300_fips,
334343
"Cryptography_HAS_SSL_COOKIE": cryptography_has_ssl_cookie,
335344
"Cryptography_HAS_PKCS7_FUNCS": cryptography_has_pkcs7_funcs,
345+
"Cryptography_HAS_BN_FLAGS": cryptography_has_bn_flags,
336346
}

0 commit comments

Comments
 (0)