X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ctypescrypto%2F__init__.py;h=c55ae11842d566a6e66b3e772012db690602b9ba;hb=0c13b5994f8512985cf989a8c44d7c2a6933f414;hp=27ad0c50b8a9efa0f91a851a7381e83cb9f7a809;hpb=b4ee51a0aca14c0af5853545b9e524cc1b57b656;p=oss%2Fctypescrypto.git diff --git a/ctypescrypto/__init__.py b/ctypescrypto/__init__.py index 27ad0c5..c55ae11 100644 --- a/ctypescrypto/__init__.py +++ b/ctypescrypto/__init__.py @@ -1,17 +1,30 @@ """ - Interface to some libcrypto functions + Interface to some libcrypto functions """ -from ctypes import CDLL,c_char_p + +from ctypes import CDLL, c_char_p +from ctypes.util import find_library +import sys def config(filename=None): - """ - Loads OpenSSL Config file. If none are specified, loads default - (compiled in) one - """ - libcrypto.OPENSSL_config(filename) - -libcrypto = CDLL("libcrypto.so.1.0.0") -libcrypto.OPENSSL_config.argtypes=(c_char_p,) + """ + Loads OpenSSL Config file. If none are specified, loads default + (compiled in) one + """ + libcrypto.OPENSSL_config(filename) + +__all__ = ['config'] + +if sys.platform.startswith('win'): + __libname__ = find_library('libeay32') +else: + __libname__ = find_library('crypto') + +if __libname__ is None: + raise OSError("Cannot find OpenSSL crypto library") + +libcrypto = CDLL(__libname__) +libcrypto.OPENSSL_config.argtypes = (c_char_p, ) libcrypto.OPENSSL_add_all_algorithms_conf()