From 95b8620e738b36a1e6e4bd015149bcb0851b3da9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 8 Aug 2013 19:36:44 -0700 Subject: Started stubbing stuff out, including a simple test, now is the part where we write some actual cryptographic software. So yeah. --- tests/primitives/test_block.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/primitives/test_block.py (limited to 'tests/primitives/test_block.py') diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py new file mode 100644 index 00000000..e22d05ef --- /dev/null +++ b/tests/primitives/test_block.py @@ -0,0 +1,23 @@ +import binascii + +import pytest + +from cryptography.primitives.block import BlockCipher, ciphers, modes, padding + + +class TestBlockCipher(object): + @pytest.mark.parametrize(("key", "iv", "plaintext", "ciphertext"), [ + ( + b"9dc2c84a37850c11699818605f47958c", + b"256953b2feab2a04ae0180d8335bbed6", + b"2e586692e647f5028ec6fa47a55a2aab", + b"1b1ebd1fc45ec43037fd4844241a437f" + ), + ]) + def test_aes_cbc_nopadding(self, key, iv, plaintext, ciphertext): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(key)), + modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + ) + actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize() + assert binascii.hexlify(actual_ciphertext) == ciphertext -- cgit v1.2.3