diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-08-08 19:36:44 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-08-08 19:36:44 -0700 |
commit | 95b8620e738b36a1e6e4bd015149bcb0851b3da9 (patch) | |
tree | 779d7b8198cd4300f06857cd770f64a8f1befc86 /tests | |
parent | 4bc451924ce0f98c0300aa13463ea8e995ea8c93 (diff) | |
download | cryptography-95b8620e738b36a1e6e4bd015149bcb0851b3da9.tar.gz cryptography-95b8620e738b36a1e6e4bd015149bcb0851b3da9.tar.bz2 cryptography-95b8620e738b36a1e6e4bd015149bcb0851b3da9.zip |
Started stubbing stuff out, including a simple test, now is the part where we
write some actual cryptographic software. So yeah.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/primitives/test_block.py | 23 |
1 files changed, 23 insertions, 0 deletions
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 |