aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-08-10 15:22:28 -0400
committerDonald Stufft <donald@stufft.io>2013-08-10 15:22:28 -0400
commitea8e9fc0bd807c49318e12f6bbd2c2b43456feab (patch)
tree144a58d74e66925fcf4c9e88622aff2b70399524
parent6a37d27953f2d6075c6834eea46bb762ca523c22 (diff)
downloadcryptography-ea8e9fc0bd807c49318e12f6bbd2c2b43456feab.tar.gz
cryptography-ea8e9fc0bd807c49318e12f6bbd2c2b43456feab.tar.bz2
cryptography-ea8e9fc0bd807c49318e12f6bbd2c2b43456feab.zip
Remove the padding from the BlockCipher API
-rw-r--r--cryptography/primitives/block/modes.py3
-rw-r--r--cryptography/primitives/block/padding.py16
-rw-r--r--tests/primitives/test_block.py10
-rw-r--r--tests/primitives/test_nist.py32
4 files changed, 22 insertions, 39 deletions
diff --git a/cryptography/primitives/block/modes.py b/cryptography/primitives/block/modes.py
index 329c8d50..02f0219c 100644
--- a/cryptography/primitives/block/modes.py
+++ b/cryptography/primitives/block/modes.py
@@ -15,7 +15,6 @@
class CBC(object):
name = "CBC"
- def __init__(self, initialization_vector, padding):
+ def __init__(self, initialization_vector):
super(CBC, self).__init__()
self.initialization_vector = initialization_vector
- self.padding = padding
diff --git a/cryptography/primitives/block/padding.py b/cryptography/primitives/block/padding.py
deleted file mode 100644
index ebd5e5c8..00000000
--- a/cryptography/primitives/block/padding.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-class NoPadding(object):
- pass
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()