diff options
author | David Reid <dreid@dreid.org> | 2013-11-12 15:46:49 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2013-11-12 15:46:49 -0800 |
commit | 4faa094526f49c83a75d21a6e796546d4d539c6c (patch) | |
tree | 6544eb15030b279f49b930012a47868fc85e02cd | |
parent | 79a47162c95439db74f51c5e332f2904dd1ef3ae (diff) | |
parent | 3f3921e2d082fd99c6186ed7bb174caf481819bd (diff) | |
download | cryptography-4faa094526f49c83a75d21a6e796546d4d539c6c.tar.gz cryptography-4faa094526f49c83a75d21a6e796546d4d539c6c.tar.bz2 cryptography-4faa094526f49c83a75d21a6e796546d4d539c6c.zip |
Merge pull request #251 from alex/dont-query-openssl
Don't query OpenSSL for block sizes, we already know them
-rw-r--r-- | cryptography/hazmat/bindings/openssl/backend.py | 7 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/ciphers/algorithms.py | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index b65583df..71b94abe 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -140,6 +140,7 @@ class _CipherContext(object): def __init__(self, backend, cipher, mode, operation): self._backend = backend + self._cipher = cipher ctx = self._backend.lib.EVP_CIPHER_CTX_new() ctx = self._backend.ffi.gc(ctx, self._backend.lib.EVP_CIPHER_CTX_free) @@ -185,9 +186,8 @@ class _CipherContext(object): self._ctx = ctx def update(self, data): - block_size = self._backend.lib.EVP_CIPHER_CTX_block_size(self._ctx) buf = self._backend.ffi.new("unsigned char[]", - len(data) + block_size - 1) + len(data) + self._cipher.block_size - 1) outlen = self._backend.ffi.new("int *") res = self._backend.lib.EVP_CipherUpdate(self._ctx, buf, outlen, data, len(data)) @@ -195,8 +195,7 @@ class _CipherContext(object): return self._backend.ffi.buffer(buf)[:outlen[0]] def finalize(self): - block_size = self._backend.lib.EVP_CIPHER_CTX_block_size(self._ctx) - buf = self._backend.ffi.new("unsigned char[]", block_size) + buf = self._backend.ffi.new("unsigned char[]", self._cipher.block_size) outlen = self._backend.ffi.new("int *") res = self._backend.lib.EVP_CipherFinal_ex(self._ctx, buf, outlen) assert res != 0 diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py index 32acab14..c135f563 100644 --- a/cryptography/hazmat/primitives/ciphers/algorithms.py +++ b/cryptography/hazmat/primitives/ciphers/algorithms.py @@ -115,6 +115,7 @@ class CAST5(object): class ARC4(object): name = "RC4" + block_size = 1 key_sizes = frozenset([40, 56, 64, 80, 128, 192, 256]) def __init__(self, key): |