diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-05-21 10:34:49 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-05-21 10:34:49 -0500 |
commit | 3211d16da6e9a90567248208164b0e7e9e4e3bcb (patch) | |
tree | 8abc6f2c2522ada35da7a43ef777ca8dfadfdfbc | |
parent | 9e233139790599a3d779330bb351ba1da984ae60 (diff) | |
download | cryptography-3211d16da6e9a90567248208164b0e7e9e4e3bcb.tar.gz cryptography-3211d16da6e9a90567248208164b0e7e9e4e3bcb.tar.bz2 cryptography-3211d16da6e9a90567248208164b0e7e9e4e3bcb.zip |
add test to verify AES CTR is always available in 0.9.8+, comment updates
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 10 | ||||
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index d9165492..c66f0452 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -132,14 +132,14 @@ class Backend(object): return _HashContext(self, algorithm) def cipher_supported(self, cipher, mode): - if self._cipher_supported(cipher, mode): + if self._evp_cipher_supported(cipher, mode): return True elif isinstance(mode, CTR) and isinstance(cipher, AES): return True else: return False - def _cipher_supported(self, cipher, mode): + def _evp_cipher_supported(self, cipher, mode): try: adapter = self._cipher_registry[type(cipher), type(mode)] except KeyError: @@ -856,10 +856,12 @@ class _CipherContext(object): return self._tag -# This is needed to provide support for AES CTR mode in OpenSSL 0.9.8. It can -# be removed when we drop 0.9.8 support (RHEL5 extended life ends 2020). @utils.register_interface(interfaces.CipherContext) class _AESCTRCipherContext(object): + """ + This is needed to provide support for AES CTR mode in OpenSSL 0.9.8. It can + be removed when we drop 0.9.8 support (RHEL5 extended life ends 2020). + """ def __init__(self, backend, cipher, mode): self._backend = backend diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 154af00f..fb2ca19f 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -22,7 +22,7 @@ from cryptography.hazmat.primitives import hashes, interfaces from cryptography.hazmat.primitives.asymmetric import dsa, padding, rsa from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers.algorithms import AES -from cryptography.hazmat.primitives.ciphers.modes import CBC +from cryptography.hazmat.primitives.ciphers.modes import CBC, CTR from cryptography.hazmat.primitives.interfaces import BlockCipherAlgorithm from ...utils import raises_unsupported_algorithm @@ -64,6 +64,11 @@ class TestOpenSSL(object): def test_supports_cipher(self): assert backend.cipher_supported(None, None) is False + def test_aes_ctr_always_available(self): + # AES CTR should always be available in both 0.9.8 and 1.0.0+ + assert backend.cipher_supported(AES(b"\x00" * 16), + CTR(b"\x00" * 16)) is True + def test_register_duplicate_cipher_adapter(self): with pytest.raises(ValueError): backend.register_cipher_adapter(AES, CBC, None) |