Add a fallback method for finding libcrypto DLL paths

This commit is contained in:
Adriano Caloiaro 2022-01-01 17:41:38 -08:00
parent 866d1130b8
commit 55987225bd
1 changed files with 11 additions and 0 deletions

View File

@ -124,17 +124,28 @@ if iswindows:
except ImportError:
import _winreg as winreg
def _licrypto_dll_path():
import sys
for p in sys.path:
if p.endswith("DLLs"):
return os.path.join(p, "libcrypto-1_1.dll")
return
def _load_crypto_libcrypto():
from ctypes.util import find_library
libcrypto = find_library('libcrypto-1_1')
if libcrypto is None:
libcrypto = find_library('libeay32')
if libcrypto is None:
libcrypto = _licrypto_dll_path()
if libcrypto is None:
raise ADEPTError('libcrypto not found')
libcrypto = CDLL(libcrypto)
AES_MAXNR = 14
c_char_pp = POINTER(c_char_p)
c_int_p = POINTER(c_int)
class AES_KEY(Structure):
_fields_ = [('rd_key', c_long * (4 * (AES_MAXNR + 1))),
('rounds', c_int)]