]> www.wagner.pp.ru Git - oss/ctypescrypto.git/blobdiff - ctypescrypto/engine.py
Converted tabs to spaces to make pylint happy
[oss/ctypescrypto.git] / ctypescrypto / engine.py
index dd7c0281b34a255670d55ab868322128b10a3d93..0446d48c2649426fef33ba16ca10b19ae6b0c7d0 100644 (file)
@@ -4,28 +4,31 @@ engine loading and configuration
 from ctypes import *
 from ctypescrypto import libcrypto
 from ctypescrypto.exception import LibCryptoError
+
+__all__=['default','set_default']
+
 default=None
 
 def set_default(engine):
-       """
-               Loads specified engine and sets it as default for all 
-               algorithms, supported by it
-       """
-       global default
-       e=libcrypto.ENGINE_by_id(engine)
-       if e is None:
-               # Try load engine
-               e = libcrypto.ENGINE_by_id("dynamic")
-               if  e is None:
-                       raise LibCryptoError("Cannot get 'dynamic' engine")
-               if not libcrypto.ENGINE_ctrl_cmd_string(e,"SO_PATH",engine,0):
-                       raise LibCryptoError("Cannot execute ctrl cmd SO_PATH")
-               if not libcrypto.ENGINE_ctrl_cmd_string(e,"LOAD",None,0):
-                       raise LibCryptoError("Cannot execute ctrl cmd LOAD")
-       if e is None:
-               raise ValueError("Cannot find engine "+engine)
-       libcrypto.ENGINE_set_default(e,c_int(0xFFFF))
-       default=e
+    """
+        Loads specified engine and sets it as default for all 
+        algorithms, supported by it
+    """
+    global default
+    e=libcrypto.ENGINE_by_id(engine)
+    if e is None:
+        # Try load engine
+        e = libcrypto.ENGINE_by_id("dynamic")
+        if  e is None:
+            raise LibCryptoError("Cannot get 'dynamic' engine")
+        if not libcrypto.ENGINE_ctrl_cmd_string(e,"SO_PATH",engine,0):
+            raise LibCryptoError("Cannot execute ctrl cmd SO_PATH")
+        if not libcrypto.ENGINE_ctrl_cmd_string(e,"LOAD",None,0):
+            raise LibCryptoError("Cannot execute ctrl cmd LOAD")
+    if e is None:
+        raise ValueError("Cannot find engine "+engine)
+    libcrypto.ENGINE_set_default(e,c_int(0xFFFF))
+    default=e
 
 # Declare function result and arguments for used functions
 libcrypto.ENGINE_by_id.restype=c_void_p