aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/primitives/block/base.py6
-rw-r--r--tests/primitives/test_block.py7
2 files changed, 13 insertions, 0 deletions
diff --git a/cryptography/primitives/block/base.py b/cryptography/primitives/block/base.py
index 2a6a5c37..207c83d9 100644
--- a/cryptography/primitives/block/base.py
+++ b/cryptography/primitives/block/base.py
@@ -23,6 +23,12 @@ class BlockCipher(object):
self._ctx = api.create_block_cipher_context(cipher, mode)
self._operation = None
+ @property
+ def name(self):
+ return "{0}-{1}-{2}".format(
+ self.cipher.name, self.cipher.key_size, self.mode.name,
+ )
+
def encrypt(self, plaintext):
if self._ctx is None:
raise ValueError("BlockCipher was already finalized")
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py
index 7dccda4b..aa670be3 100644
--- a/tests/primitives/test_block.py
+++ b/tests/primitives/test_block.py
@@ -19,6 +19,13 @@ from cryptography.primitives.block import BlockCipher, ciphers, modes, padding
class TestBlockCipher(object):
+ def test_cipher_name(self):
+ cipher = BlockCipher(
+ ciphers.AES(binascii.unhexlify(b"0" * 32)),
+ modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding())
+ )
+ assert cipher.name == "AES-128-CBC"
+
def test_use_after_finalize(self):
cipher = BlockCipher(
ciphers.AES(binascii.unhexlify(b"0" * 32)),