Skip to content

Commit c28bfb3

Browse files
authored
src/_cffi_src/openssl/evp.py: export EVP_PKEY_set_alias_type in FUNCTIONS (#7935)
In openssl 1.1.1 docs/man3/EVP_PKEY_set1_RSA.pod (https://github.com/openssl/openssl/blob/OpenSSL_1_1_1/doc/man3/EVP_PKEY_set1_RSA.pod) The EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2) API is possible to convert it to using SM2 algorithms After loading an ECC key. So the EVP_PKEY_set_alias_type API is important for people who want to use cryptography with using SM2 algorithms. Therefore, we need to export EVP_PKEY_set_alias_type in FUNCTIONS. Signed-off-by: YiLin.Li <[email protected]> Signed-off-by: YiLin.Li <[email protected]>
1 parent 438f781 commit c28bfb3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/_cffi_src/openssl/evp.py

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
static const int EVP_CTRL_AEAD_GET_TAG;
3232
static const int EVP_CTRL_AEAD_SET_TAG;
3333
34+
static const int Cryptography_HAS_EVP_PKEY_set_alias_type;
3435
static const int Cryptography_HAS_SCRYPT;
3536
static const int Cryptography_HAS_EVP_PKEY_DHX;
3637
static const int Cryptography_HAS_EVP_PKEY_get_set_tls_encodedpoint;
@@ -121,6 +122,7 @@
121122
int EVP_PKEY_derive_init(EVP_PKEY_CTX *);
122123
int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *, EVP_PKEY *);
123124
int EVP_PKEY_derive(EVP_PKEY_CTX *, unsigned char *, size_t *);
125+
int EVP_PKEY_set_alias_type(EVP_PKEY *, int);
124126
int EVP_PKEY_set_type(EVP_PKEY *, int);
125127
126128
int EVP_PKEY_id(const EVP_PKEY *);
@@ -180,6 +182,14 @@
180182
EVP_MD_CTX_free(md);
181183
}
182184
185+
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_OPENSSL_300_OR_GREATER || \
186+
CRYPTOGRAPHY_IS_BORINGSSL
187+
static const int Cryptography_HAS_EVP_PKEY_set_alias_type = 0;
188+
int (*EVP_PKEY_set_alias_type)(EVP_PKEY *, int) = NULL;
189+
#else
190+
static const int Cryptography_HAS_EVP_PKEY_set_alias_type = 1;
191+
#endif
192+
183193
#if CRYPTOGRAPHY_IS_LIBRESSL || defined(OPENSSL_NO_SCRYPT)
184194
static const long Cryptography_HAS_SCRYPT = 0;
185195
int (*EVP_PBE_scrypt)(const char *, size_t, const unsigned char *, size_t,

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

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def cryptography_has_tls_st() -> typing.List[str]:
4242
]
4343

4444

45+
def cryptography_has_evp_pkey_set_alias_type() -> typing.List[str]:
46+
return [
47+
"EVP_PKEY_set_alias_type",
48+
]
49+
50+
4551
def cryptography_has_scrypt() -> typing.List[str]:
4652
return [
4753
"EVP_PBE_scrypt",
@@ -303,6 +309,9 @@ def cryptography_has_get_extms_support() -> typing.List[str]:
303309
"Cryptography_HAS_SET_CERT_CB": cryptography_has_set_cert_cb,
304310
"Cryptography_HAS_SSL_ST": cryptography_has_ssl_st,
305311
"Cryptography_HAS_TLS_ST": cryptography_has_tls_st,
312+
"Cryptography_HAS_EVP_PKEY_set_alias_type": (
313+
cryptography_has_evp_pkey_set_alias_type
314+
),
306315
"Cryptography_HAS_SCRYPT": cryptography_has_scrypt,
307316
"Cryptography_HAS_EVP_PKEY_DHX": cryptography_has_evp_pkey_dhx,
308317
"Cryptography_HAS_MEM_FUNCTIONS": cryptography_has_mem_functions,

0 commit comments

Comments
 (0)