Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add binding for PKCS12_set_mac #7217

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/_cffi_src/openssl/pkcs12.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"""

TYPES = """
static const long Cryptography_HAS_PKCS12_SET_MAC;

typedef ... PKCS12;
"""

Expand All @@ -20,7 +22,16 @@
Cryptography_STACK_OF_X509 **);
PKCS12 *PKCS12_create(char *, char *, EVP_PKEY *, X509 *,
Cryptography_STACK_OF_X509 *, int, int, int, int, int);
int PKCS12_set_mac(PKCS12 *, const char *, int, unsigned char *, int, int,
const EVP_MD *);
"""

CUSTOMIZATIONS = """
#if CRYPTOGRAPHY_IS_BORINGSSL
static const long Cryptography_HAS_PKCS12_SET_MAC = 0;
int (*PKCS12_set_mac)(PKCS12 *, const char *, int, unsigned char *, int, int,
const EVP_MD *) = NULL;
#else
static const long Cryptography_HAS_PKCS12_SET_MAC = 1;
#endif
"""
5 changes: 5 additions & 0 deletions src/cryptography/hazmat/bindings/openssl/_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ def cryptography_has_unexpected_eof_while_reading() -> typing.List[str]:
return ["SSL_R_UNEXPECTED_EOF_WHILE_READING"]


def cryptography_has_pkcs12_set_mac() -> typing.List[str]:
return ["PKCS12_set_mac"]


# This is a mapping of
# {condition: function-returning-names-dependent-on-that-condition} so we can
# loop over them and delete unsupported names at runtime. It will be removed
Expand Down Expand Up @@ -364,4 +368,5 @@ def cryptography_has_unexpected_eof_while_reading() -> typing.List[str]:
"Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING": (
cryptography_has_unexpected_eof_while_reading
),
"Cryptography_HAS_PKCS12_SET_MAC": cryptography_has_pkcs12_set_mac,
}