Skip to content

Commit

Permalink
Enable legacy provider with OpenSSL 3 so older algos are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Mar 9, 2022
1 parent a9c35c2 commit 5ae0e79
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions oscrypto/_openssl/_libcrypto_ctypes.py
Expand Up @@ -73,6 +73,8 @@
P_EVP_MD = c_void_p

P_ENGINE = c_void_p
OSSL_PROVIDER = c_void_p
OSSL_LIB_CTX = c_void_p

P_EVP_PKEY = c_void_p
EVP_PKEY_CTX = c_void_p
Expand All @@ -97,6 +99,12 @@
libcrypto.ERR_free_strings.argtypes = []
libcrypto.ERR_free_strings.restype = None

if version_info >= (3, 0):
libcrypto.OSSL_PROVIDER_load.argtypes = [OSSL_LIB_CTX, c_char_p]
libcrypto.OSSL_PROVIDER_load.restype = POINTER(OSSL_PROVIDER)

libcrypto.OSSL_PROVIDER_load(None, "legacy".encode("ascii"))

libcrypto.ERR_get_error.argtypes = []
libcrypto.ERR_get_error.restype = c_ulong

Expand Down Expand Up @@ -301,10 +309,17 @@
libcrypto.EVP_sha512.argtypes = []
libcrypto.EVP_sha512.restype = P_EVP_MD

libcrypto.EVP_PKEY_size.argtypes = [
P_EVP_PKEY
]
libcrypto.EVP_PKEY_size.restype = c_int
if version_info < (3, 0):
libcrypto.EVP_PKEY_size.argtypes = [
P_EVP_PKEY
]
libcrypto.EVP_PKEY_size.restype = c_int
else:
libcrypto.EVP_PKEY_get_size.argtypes = [
P_EVP_PKEY
]
libcrypto.EVP_PKEY_get_size.restype = c_int
libcrypto.EVP_PKEY_size = libcrypto.EVP_PKEY_get_size

libcrypto.EVP_PKEY_get1_RSA.argtypes = [
P_EVP_PKEY
Expand Down

0 comments on commit 5ae0e79

Please sign in to comment.