Skip to content

Commit b3e20a1

Browse files
committed
Check for BoringSSL in the pkcs7 bindings
1 parent 983ec6e commit b3e20a1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/_cffi_src/openssl/pkcs7.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"""
99

1010
TYPES = """
11+
static const long Cryptography_HAS_PKCS7_FUNCS;
12+
1113
typedef struct {
1214
Cryptography_STACK_OF_X509 *cert;
1315
Cryptography_STACK_OF_X509_CRL *crl;
@@ -80,4 +82,22 @@
8082
int PKCS7_type_is_data(PKCS7 *);
8183
"""
8284

83-
CUSTOMIZATIONS = ""
85+
CUSTOMIZATIONS = """
86+
#if CRYPTOGRAPHY_IS_BORINGSSL
87+
static const long Cryptography_HAS_PKCS7_FUNCS = 0;
88+
89+
int (*SMIME_write_PKCS7)(BIO *, PKCS7 *, BIO *, int) = NULL;
90+
int (*PEM_write_bio_PKCS7_stream)(BIO *, PKCS7 *, BIO *, int) = NULL;
91+
PKCS7_SIGNER_INFO *(*PKCS7_sign_add_signer)(PKCS7 *, X509 *, EVP_PKEY *,
92+
const EVP_MD *, int) = NULL;
93+
int (*PKCS7_final)(PKCS7 *, BIO *, int);
94+
int (*PKCS7_verify)(PKCS7 *, Cryptography_STACK_OF_X509 *, X509_STORE *, BIO *,
95+
BIO *, int) = NULL;
96+
PKCS7 *(*SMIME_read_PKCS7)(BIO *, BIO **) = NULL;
97+
Cryptography_STACK_OF_X509 *(*PKCS7_get0_signers)(PKCS7 *,
98+
Cryptography_STACK_OF_X509 *,
99+
int) = NULL;
100+
#else
101+
static const long Cryptography_HAS_PKCS7_FUNCS = 1;
102+
#endif
103+
"""

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,17 @@ def cryptography_has_ssl_cookie():
268268
]
269269

270270

271+
def cryptography_has_pkcs7_funcs():
272+
return [
273+
"SMIME_write_PKCS7",
274+
"PEM_write_bio_PKCS7_stream",
275+
"PKCS7_sign_add_signer",
276+
"PKCS7_final",
277+
"PKCS7_verify",
278+
"SMIME_read_PKCS7",
279+
"PKCS7_get0_signers",
280+
]
281+
271282
# This is a mapping of
272283
# {condition: function-returning-names-dependent-on-that-condition} so we can
273284
# loop over them and delete unsupported names at runtime. It will be removed
@@ -321,4 +332,5 @@ def cryptography_has_ssl_cookie():
321332
"Cryptography_HAS_DTLS_GET_DATA_MTU": cryptography_has_dtls_get_data_mtu,
322333
"Cryptography_HAS_300_FIPS": cryptography_has_300_fips,
323334
"Cryptography_HAS_SSL_COOKIE": cryptography_has_ssl_cookie,
335+
"Cryptography_HAS_PKCS7_FUNCS": cryptography_has_pkcs7_funcs,
324336
}

0 commit comments

Comments
 (0)