"""
try:
if self.ctx is not None:
- libcrypto.EVP_CIPHER_CTX_cleanup(self.ctx)
+ self.__ctxcleanup(self.ctx)
libcrypto.EVP_CIPHER_CTX_free(self.ctx)
del self.ctx
except AttributeError:
# Used C function block_size
#
libcrypto.EVP_CIPHER_block_size.argtypes = (c_void_p, )
-libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p, )
+
+#Function EVP_CIPHER_CTX_cleanup renamed to EVP_CIPHER_CTX_reset
+# in the OpenSSL 1.1.0
+if hasattr(libcrypto,"EVP_CIPHER_CTX_cleanup"):
+ Cipher.__ctxcleanup = libcrypto.EVP_CIPHER_CTX_cleanup.argtypes
+else:
+ Cipher.__ctxcleanup = libcrypto.EVP_CIPHER_CTX_reset
+Cipher.__ctxcleanup.argtypes = (c_void_p, )
libcrypto.EVP_CIPHER_CTX_free.argtypes = (c_void_p, )
libcrypto.EVP_CIPHER_CTX_new.restype = c_void_p
libcrypto.EVP_CIPHER_CTX_set_padding.argtypes = (c_void_p, c_int)
"""
Initializes digest using given type.
"""
- self.ctx = libcrypto.EVP_MD_CTX_create()
+ self.ctx = self.newctx()
if self.ctx is None:
raise DigestError("Unable to create digest context")
self.digest_out = None
"""
try:
if self.ctx is not None:
- libcrypto.EVP_MD_CTX_destroy(self.ctx)
+ libcrypto.EVP_MD_CTX_free(self.ctx)
del self.ctx
except AttributeError:
pass
# Declare function result and argument types
libcrypto.EVP_get_digestbyname.restype = c_void_p
libcrypto.EVP_get_digestbyname.argtypes = (c_char_p, )
-libcrypto.EVP_MD_CTX_create.restype = c_void_p
+# These two functions are renamed in OpenSSL 1.1.0
+if hasattr(libcrypto,"EVP_MD_CTX_create"):
+ Digest.newctx = libcrypto.EVP_MD_CTX_create
+ Digest.freectx = libcrypto.EVP_MD_CTX_destroy
+else:
+ Digest.newctx = libcrypto.EVP_MD_CTX_new
+ Digest.freectx = libcrypto.EVP_MD_CTX_free
+Digest.newctx.restype = c_void_p
+Digest.freectx.argtypes = (c_void_p, )
# libcrypto.EVP_MD_CTX_create has no arguments
-libcrypto.EVP_DigestInit_ex.restupe = c_int
+libcrypto.EVP_DigestInit_ex.restype = c_int
libcrypto.EVP_DigestInit_ex.argtypes = (c_void_p, c_void_p, c_void_p)
libcrypto.EVP_DigestUpdate.restype = c_int
libcrypto.EVP_DigestUpdate.argtypes = (c_void_p, c_char_p, c_longlong)
libcrypto.EVP_DigestFinal_ex.restype = c_int
libcrypto.EVP_DigestFinal_ex.argtypes = (c_void_p, c_char_p, POINTER(c_long))
-libcrypto.EVP_MD_CTX_destroy.argtypes = (c_void_p, )
libcrypto.EVP_MD_CTX_copy.restype = c_int
libcrypto.EVP_MD_CTX_copy.argtypes = (c_void_p, c_void_p)
libcrypto.EVP_MD_type.argtypes = (c_void_p, )
if self.key is None:
raise DigestError("EVP_PKEY_new_mac_key")
pctx=c_void_p()
- self.ctx = libcrypto.EVP_MD_CTX_create()
+ self.ctx = self.newctx()
if self.ctx == 0:
raise DigestError("Unable to create digest context")
if libcrypto.EVP_DigestSignInit(self.ctx,pointer(pctx),d,None,self.key) <= 0: