aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_block.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-01-04 12:19:17 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-01-04 12:19:17 -0800
commitac6e02a0813e66f5e7cf75be0b3c7885a292c291 (patch)
treebc99e8f3f37e383d8ba166dec829fc1fe44ed92f /tests/hazmat/primitives/test_block.py
parent4969751fde0ef09cd72c738a80c32851c1b1f21d (diff)
parentd68fd37ec18c5adfa580d989730f7988d72d2bea (diff)
downloadcryptography-ac6e02a0813e66f5e7cf75be0b3c7885a292c291.tar.gz
cryptography-ac6e02a0813e66f5e7cf75be0b3c7885a292c291.tar.bz2
cryptography-ac6e02a0813e66f5e7cf75be0b3c7885a292c291.zip
Merge branch 'master' into setup-install-extension
Conflicts: cryptography/hazmat/bindings/openssl/binding.py
Diffstat (limited to 'tests/hazmat/primitives/test_block.py')
-rw-r--r--tests/hazmat/primitives/test_block.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index 30cf1d60..f758ffaa 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -35,6 +35,9 @@ from .utils import (
class DummyMode(object):
name = "dummy-mode"
+ def validate_for_algorithm(self, algorithm):
+ pass
+
@utils.register_interface(interfaces.CipherAlgorithm)
class DummyCipher(object):
@@ -152,3 +155,37 @@ class TestAEADCipherContext(object):
algorithms.AES,
modes.GCM,
)
+
+
+class TestModeValidation(object):
+ def test_cbc(self, backend):
+ with pytest.raises(ValueError):
+ Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.CBC(b"abc"),
+ backend,
+ )
+
+ def test_ofb(self, backend):
+ with pytest.raises(ValueError):
+ Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.OFB(b"abc"),
+ backend,
+ )
+
+ def test_cfb(self, backend):
+ with pytest.raises(ValueError):
+ Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.CFB(b"abc"),
+ backend,
+ )
+
+ def test_ctr(self, backend):
+ with pytest.raises(ValueError):
+ Cipher(
+ algorithms.AES(b"\x00" * 16),
+ modes.CTR(b"abc"),
+ backend,
+ )