diff options
-rw-r--r-- | cryptography/bindings/openssl/api.py | 4 | ||||
-rw-r--r-- | cryptography/primitives/block/ciphers.py | 2 | ||||
-rw-r--r-- | cryptography/primitives/block/modes.py | 2 |
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 |