X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ctypescrypto%2F__init__.py;h=1213398b08ff7069421841fe090175cd9ff6f7de;hb=182740bfaccacd20d10148b7d9bf7ed588d31ce4;hp=7ae712565d643d6ac7621652cdc061e9976ba754;hpb=ff669c32aa77c9ebfb9c5371b2c8a9d41de614f8;p=oss%2Fctypescrypto.git diff --git a/ctypescrypto/__init__.py b/ctypescrypto/__init__.py index 7ae7125..1213398 100644 --- a/ctypescrypto/__init__.py +++ b/ctypescrypto/__init__.py @@ -1,20 +1,32 @@ """ - 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) + """ + Loads OpenSSL Config file. If none are specified, loads default + (compiled in) one + """ + libcrypto.OPENSSL_config(filename) __all__ = ['config'] -libcrypto = CDLL("libcrypto.so.1.0.0") -libcrypto.OPENSSL_config.argtypes=(c_char_p,) +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") + +#__libname__ = "/usr/local/ssl/lib/libcrypto.so.1.1" + +libcrypto = CDLL(__libname__) +libcrypto.OPENSSL_config.argtypes = (c_char_p, ) libcrypto.OPENSSL_add_all_algorithms_conf()