crypt: use the py3 builtin openssl
With Python 3.7+, the Python installer has the libcrypto and libssl dlls in the DLLs Python folder, namely libcrypto-1_1.dll and libssl-1_1.dll, which can be used directly. Change-Id: I245c377dc8a9ec9a2e8548806bacd757bfdf27b6
This commit is contained in:
parent
072bee9c5d
commit
da0c0dc7bd
@ -26,12 +26,20 @@ if sys.platform == "win32":
|
||||
else:
|
||||
clib = ctypes.cdll.ucrtbase
|
||||
|
||||
# Note(mbivolan): The library name has changed in OpenSSL 1.1.0
|
||||
# Keeping the old name for backward compatibility
|
||||
try:
|
||||
openssl = ctypes.cdll.libeay32
|
||||
except Exception:
|
||||
openssl = ctypes.cdll.libcrypto
|
||||
# for backwards compatibility, try the older names
|
||||
# libcrypto-1_1 comes bundled with PY 3.7 to 3.12
|
||||
ssl_lib_names = [
|
||||
"libcrypto-1_1",
|
||||
"libcrypto",
|
||||
"libeay32"
|
||||
]
|
||||
|
||||
for ssl_lib_name in ssl_lib_names:
|
||||
try:
|
||||
openssl = ctypes.CDLL(ssl_lib_name)
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
clib = ctypes.CDLL(clib_path)
|
||||
openssl_lib_path = ctypes.util.find_library("ssl")
|
||||
@ -64,6 +72,7 @@ class RSA(ctypes.Structure):
|
||||
("mt_blinding", ctypes.c_void_p)
|
||||
]
|
||||
|
||||
|
||||
openssl.RSA_PKCS1_PADDING = 1
|
||||
|
||||
openssl.RSA_new.restype = ctypes.POINTER(RSA)
|
||||
|
Loading…
Reference in New Issue
Block a user