diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-20 12:15:58 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-20 12:15:58 -0500 |
commit | d873f0fc7fd87c5a9029c1b6a3fd97c390175a21 (patch) | |
tree | fef9ea7ca95e46442fd03faab2fc24f7356144fe | |
parent | 7abcb9c0e87787d58f4754c079a3296aaedae657 (diff) | |
download | cryptography-d873f0fc7fd87c5a9029c1b6a3fd97c390175a21.tar.gz cryptography-d873f0fc7fd87c5a9029c1b6a3fd97c390175a21.tar.bz2 cryptography-d873f0fc7fd87c5a9029c1b6a3fd97c390175a21.zip |
use _new and _free on EVP_CIPHER_CTX rather than initing manually
-rw-r--r-- | cryptography/bindings/openssl/api.py | 6 | ||||
-rw-r--r-- | cryptography/bindings/openssl/evp.py | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 3c2cf2e2..ee4fbff1 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -99,10 +99,8 @@ class API(object): self.lib.EVP_get_cipherbyname(ciphername.encode("ascii"))) def create_block_cipher_context(self, cipher, mode): - ctx = self.ffi.new("EVP_CIPHER_CTX *") - res = self.lib.EVP_CIPHER_CTX_init(ctx) - assert res != 0 - ctx = self.ffi.gc(ctx, self.lib.EVP_CIPHER_CTX_cleanup) + ctx = self.lib.EVP_CIPHER_CTX_new() + ctx = self.ffi.gc(ctx, self.lib.EVP_CIPHER_CTX_free) # TODO: compute name using a better algorithm ciphername = "{0}-{1}-{2}".format( cipher.name, cipher.key_size, mode.name diff --git a/cryptography/bindings/openssl/evp.py b/cryptography/bindings/openssl/evp.py index 20159906..2bb5b0f7 100644 --- a/cryptography/bindings/openssl/evp.py +++ b/cryptography/bindings/openssl/evp.py @@ -45,6 +45,8 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *); int EVP_CIPHER_block_size(const EVP_CIPHER *); void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *); EVP_MD_CTX *EVP_MD_CTX_create(); int EVP_MD_CTX_copy_ex(EVP_MD_CTX *, const EVP_MD_CTX *); |