From ea8e9fc0bd807c49318e12f6bbd2c2b43456feab Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sat, 10 Aug 2013 15:22:28 -0400 Subject: Remove the padding from the BlockCipher API --- tests/primitives/test_block.py | 10 +++++----- tests/primitives/test_nist.py | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'tests/primitives') diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py index aa670be3..799e5f03 100644 --- a/tests/primitives/test_block.py +++ b/tests/primitives/test_block.py @@ -15,21 +15,21 @@ import binascii import pytest -from cryptography.primitives.block import BlockCipher, ciphers, modes, padding +from cryptography.primitives.block import BlockCipher, ciphers, modes 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()) + modes.CBC(binascii.unhexlify(b"0" * 32)) ) assert cipher.name == "AES-128-CBC" def test_use_after_finalize(self): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding()) + modes.CBC(binascii.unhexlify(b"0" * 32)) ) cipher.encrypt(b"a" * 16) cipher.finalize() @@ -41,7 +41,7 @@ class TestBlockCipher(object): def test_encrypt_with_invalid_operation(self): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding()) + modes.CBC(binascii.unhexlify(b"0" * 32)) ) cipher._operation = "decrypt" @@ -51,7 +51,7 @@ class TestBlockCipher(object): def test_finalize_with_invalid_operation(self): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(b"0" * 32)), - modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding()) + modes.CBC(binascii.unhexlify(b"0" * 32)) ) cipher._operation = "wat" diff --git a/tests/primitives/test_nist.py b/tests/primitives/test_nist.py index 4452e936..8b63665c 100644 --- a/tests/primitives/test_nist.py +++ b/tests/primitives/test_nist.py @@ -19,7 +19,7 @@ import os import pytest -from cryptography.primitives.block import BlockCipher, ciphers, modes, padding +from cryptography.primitives.block import BlockCipher, ciphers, modes from ..utils import load_nist_vectors_from_file @@ -49,7 +49,7 @@ class TestAES_CBC(object): def test_KAT_GFSbox_128_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -59,7 +59,7 @@ class TestAES_CBC(object): def test_KAT_GFSbox_192_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -69,7 +69,7 @@ class TestAES_CBC(object): def test_KAT_GFSbox_256_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -79,7 +79,7 @@ class TestAES_CBC(object): def test_KAT_KeySbox_128_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -89,7 +89,7 @@ class TestAES_CBC(object): def test_KAT_KeySbox_192_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -99,7 +99,7 @@ class TestAES_CBC(object): def test_KAT_KeySbox_256_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -109,7 +109,7 @@ class TestAES_CBC(object): def test_KAT_VarKey_128_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -119,7 +119,7 @@ class TestAES_CBC(object): def test_KAT_VarKey_192_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -129,7 +129,7 @@ class TestAES_CBC(object): def test_KAT_VarKey_256_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -139,7 +139,7 @@ class TestAES_CBC(object): def test_KAT_VarTxt_128_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -149,7 +149,7 @@ class TestAES_CBC(object): def test_KAT_VarTxt_192_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -159,7 +159,7 @@ class TestAES_CBC(object): def test_KAT_VarTxt_256_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -169,7 +169,7 @@ class TestAES_CBC(object): def test_MMT_128_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -179,7 +179,7 @@ class TestAES_CBC(object): def test_MMT_192_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() @@ -189,7 +189,7 @@ class TestAES_CBC(object): def test_MMT_256_encrypt(self, key, iv, plaintext, ciphertext): cipher = BlockCipher( ciphers.AES(binascii.unhexlify(key)), - modes.CBC(binascii.unhexlify(iv), padding.NoPadding()) + modes.CBC(binascii.unhexlify(iv)), ) actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() -- cgit v1.2.3