aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_ciphers.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-10-02 10:03:20 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-10-01 22:03:20 -0400
commita397d75a1e091299d012035655bdc30376378b4c (patch)
tree6cc453b672db069abe64838ec3d4d990777f20fc /tests/hazmat/primitives/test_ciphers.py
parentdd567cbf732d310e8a79aa05d7001c8639e9e6f3 (diff)
downloadcryptography-a397d75a1e091299d012035655bdc30376378b4c.tar.gz
cryptography-a397d75a1e091299d012035655bdc30376378b4c.tar.bz2
cryptography-a397d75a1e091299d012035655bdc30376378b4c.zip
Add support for AES XTS (#3900)
* Add support for AES XTS We drop the non-byte aligned test vectors because according to NIST http://csrc.nist.gov/groups/STM/cavp/documents/aes/XTSVS.pdf "An implementation may support a data unit length that is not a multiple of 8 bits." OpenSSL does not support this, so we can't use those test vectors. * fix docs and pep8 * docs fix * the spellchecker is so frustrating * add note about AES 192 for XTS (it's not supported) * docs work * enforce key length on ECB mode in AES as well (thanks XTS) * a few more words about why we exclude some test vectors for XTS
Diffstat (limited to 'tests/hazmat/primitives/test_ciphers.py')
-rw-r--r--tests/hazmat/primitives/test_ciphers.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py
index f1718c07..2f58c9fc 100644
--- a/tests/hazmat/primitives/test_ciphers.py
+++ b/tests/hazmat/primitives/test_ciphers.py
@@ -37,6 +37,30 @@ class TestAES(object):
AES(binascii.unhexlify(b"0" * 12))
+class TestAESXTS(object):
+ @pytest.mark.requires_backend_interface(interface=CipherBackend)
+ @pytest.mark.parametrize(
+ "mode",
+ (modes.CBC, modes.CTR, modes.CFB, modes.CFB8, modes.OFB)
+ )
+ def test_invalid_key_size_with_mode(self, mode, backend):
+ with pytest.raises(ValueError):
+ ciphers.Cipher(AES(b"0" * 64), mode(b"0" * 16), backend)
+
+ def test_xts_tweak_not_bytes(self):
+ with pytest.raises(TypeError):
+ modes.XTS(32)
+
+ def test_xts_tweak_too_small(self):
+ with pytest.raises(ValueError):
+ modes.XTS(b"0")
+
+ @pytest.mark.requires_backend_interface(interface=CipherBackend)
+ def test_xts_wrong_key_size(self, backend):
+ with pytest.raises(ValueError):
+ ciphers.Cipher(AES(b"0" * 16), modes.XTS(b"0" * 16), backend)
+
+
class TestCamellia(object):
@pytest.mark.parametrize(("key", "keysize"), [
(b"0" * 32, 128),