- 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
+ eng = libcrypto.ENGINE_by_id(engine)
+ if eng is None:
+ # Try load engine
+ eng = libcrypto.ENGINE_by_id("dynamic")
+ if eng is None:
+ raise LibCryptoError("Cannot get 'dynamic' engine")
+ if not libcrypto.ENGINE_ctrl_cmd_string(eng, "SO_PATH", engine, 0):
+ raise LibCryptoError("Cannot execute ctrl cmd SO_PATH")
+ if not libcrypto.ENGINE_ctrl_cmd_string(eng, "LOAD", None, 0):
+ raise LibCryptoError("Cannot execute ctrl cmd LOAD")
+ if eng is None:
+ raise ValueError("Cannot find engine " + engine)
+ libcrypto.ENGINE_set_default(eng, c_int(0xFFFF))
+ default = eng