]> www.wagner.pp.ru Git - oss/ctypescrypto.git/blob - ctypescrypto/__init__.py
1213398b08ff7069421841fe090175cd9ff6f7de
[oss/ctypescrypto.git] / ctypescrypto / __init__.py
1 """
2     Interface to some libcrypto functions
3
4 """
5
6
7 from ctypes import CDLL, c_char_p
8 from ctypes.util import find_library
9 import sys
10
11 def config(filename=None):
12     """
13         Loads OpenSSL Config file. If none are specified, loads default
14         (compiled in) one
15     """
16     libcrypto.OPENSSL_config(filename)
17
18 __all__ = ['config']
19
20 if sys.platform.startswith('win'):
21     __libname__ = find_library('libeay32')
22 else:
23     __libname__ = find_library('crypto')
24
25 if __libname__ is None:
26     raise OSError("Cannot find OpenSSL crypto library")
27
28 #__libname__ = "/usr/local/ssl/lib/libcrypto.so.1.1"
29
30 libcrypto = CDLL(__libname__)
31 libcrypto.OPENSSL_config.argtypes = (c_char_p, )
32 libcrypto.OPENSSL_add_all_algorithms_conf()