aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_aes.py
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2019-07-08 16:42:01 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2019-07-08 15:42:00 -0500
commit9a09f9690890c4b6fa6d4d1625e78dcbaffbf734 (patch)
tree8b5224be0decccc0efc22da14323c59dd6c5acea /tests/hazmat/primitives/test_aes.py
parent1e8c5a64190db6611889f45f7f8af543b291383b (diff)
downloadcryptography-9a09f9690890c4b6fa6d4d1625e78dcbaffbf734.tar.gz
cryptography-9a09f9690890c4b6fa6d4d1625e78dcbaffbf734.tar.bz2
cryptography-9a09f9690890c4b6fa6d4d1625e78dcbaffbf734.zip
Fix some backend feature checks in tests (#4931)
* Remove irrelevant DHBackend test conditions DHBackend provides functions for plain finite-field Diffie-Hellman. X25519 and X448 are their own algorithms, and Ed25519 and Ed448 aren't even Diffie-Hellman primitives. * Add missing backend support checks. Some new AES and EC tests did not check for whether the corresponding mode or curve was supported by the backend. * Add a DummyMode for coverage
Diffstat (limited to 'tests/hazmat/primitives/test_aes.py')
-rw-r--r--tests/hazmat/primitives/test_aes.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/hazmat/primitives/test_aes.py b/tests/hazmat/primitives/test_aes.py
index 565cc11d..f1d434f1 100644
--- a/tests/hazmat/primitives/test_aes.py
+++ b/tests/hazmat/primitives/test_aes.py
@@ -13,6 +13,7 @@ from cryptography.hazmat.backends.interfaces import CipherBackend
from cryptography.hazmat.primitives.ciphers import algorithms, base, modes
from .utils import _load_all_params, generate_aead_test, generate_encrypt_test
+from ...doubles import DummyMode
from ...utils import load_nist_vectors
@@ -484,14 +485,17 @@ class TestAESModeGCM(object):
modes.CFB(bytearray(b"\x00" * 16)),
modes.CFB8(bytearray(b"\x00" * 16)),
modes.XTS(bytearray(b"\x00" * 16)),
+ # Add a dummy mode for coverage of the cipher_supported check.
+ DummyMode(),
]
)
@pytest.mark.requires_backend_interface(interface=CipherBackend)
def test_buffer_protocol_alternate_modes(mode, backend):
data = bytearray(b"sixteen_byte_msg")
- cipher = base.Cipher(
- algorithms.AES(bytearray(os.urandom(32))), mode, backend
- )
+ key = algorithms.AES(bytearray(os.urandom(32)))
+ if not backend.cipher_supported(key, mode):
+ pytest.skip("AES in {} mode not supported".format(mode.name))
+ cipher = base.Cipher(key, mode, backend)
enc = cipher.encryptor()
ct = enc.update(data) + enc.finalize()
dec = cipher.decryptor()