aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-08-09 10:18:44 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-08-09 10:18:44 -0700
commit92c1f35054c79f3aef26712ac7ca16480f1847a0 (patch)
treeb0161d0768ad1a794ea6a12ea192172da1571322
parentdfb76e49b6e957ee367f67be4507974bbc48173f (diff)
downloadcryptography-92c1f35054c79f3aef26712ac7ca16480f1847a0.tar.gz
cryptography-92c1f35054c79f3aef26712ac7ca16480f1847a0.tar.bz2
cryptography-92c1f35054c79f3aef26712ac7ca16480f1847a0.zip
Compute the cipher name slightly (only slightly) better
-rw-r--r--cryptography/bindings/openssl/api.py4
-rw-r--r--cryptography/primitives/block/ciphers.py2
-rw-r--r--cryptography/primitives/block/modes.py2
3 files changed, 6 insertions, 2 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index ba6fbb83..24679966 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -60,8 +60,8 @@ class API(object):
def create_block_cipher_context(self, cipher, mode):
ctx = self._ffi.new("EVP_CIPHER_CTX *")
- # TODO: compute real cipher
- ciphername = b"AES-{}-CBC".format(len(cipher.key) * 8)
+ # TODO: compute name using a better algorithm
+ ciphername = b"{}-{}-{}".format(cipher.name, len(cipher.key) * 8, mode.name)
evp_cipher = self._lib.EVP_get_cipherbyname(ciphername)
if evp_cipher == self._ffi.NULL:
raise OpenSSLError(self)
diff --git a/cryptography/primitives/block/ciphers.py b/cryptography/primitives/block/ciphers.py
index e4e570d7..87dfa733 100644
--- a/cryptography/primitives/block/ciphers.py
+++ b/cryptography/primitives/block/ciphers.py
@@ -1,4 +1,6 @@
class AES(object):
+ name = "AES"
+
def __init__(self, key):
super(AES, self).__init__()
self.key = key
diff --git a/cryptography/primitives/block/modes.py b/cryptography/primitives/block/modes.py
index d336ed37..08d411f4 100644
--- a/cryptography/primitives/block/modes.py
+++ b/cryptography/primitives/block/modes.py
@@ -1,4 +1,6 @@
class CBC(object):
+ name = "CBC"
+
def __init__(self, initialization_vector, padding):
super(CBC, self).__init__()
self.initialization_vector = initialization_vector