aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/backends/test_backendinit.py17
-rw-r--r--tests/hazmat/backends/test_commoncrypto.py54
-rw-r--r--tests/hazmat/bindings/test_commoncrypto.py26
-rw-r--r--tests/hazmat/primitives/test_cast5.py17
-rw-r--r--tests/hazmat/primitives/utils.py5
5 files changed, 2 insertions, 117 deletions
diff --git a/tests/hazmat/backends/test_backendinit.py b/tests/hazmat/backends/test_backendinit.py
deleted file mode 100644
index b930f99f..00000000
--- a/tests/hazmat/backends/test_backendinit.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-from cryptography.hazmat.backends import _backend_import_fallback
-
-
-def test_backend_import_fallback_empty_backends():
- backends = _backend_import_fallback([])
- assert len(backends) >= 1
-
-
-def test_backend_import_fallback_existing_backends():
- backend_list = [1, 2, 3, 4]
- assert backend_list == _backend_import_fallback(backend_list)
diff --git a/tests/hazmat/backends/test_commoncrypto.py b/tests/hazmat/backends/test_commoncrypto.py
deleted file mode 100644
index 2b730e93..00000000
--- a/tests/hazmat/backends/test_commoncrypto.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-import pytest
-
-from cryptography.exceptions import InternalError, _Reasons
-from cryptography.hazmat.backends import _available_backends
-from cryptography.hazmat.primitives.ciphers import Cipher
-from cryptography.hazmat.primitives.ciphers.algorithms import AES
-from cryptography.hazmat.primitives.ciphers.modes import CBC, GCM
-
-from ...doubles import DummyCipherAlgorithm
-from ...utils import raises_unsupported_algorithm
-
-
-@pytest.mark.skipif("commoncrypto" not in
- [i.name for i in _available_backends()],
- reason="CommonCrypto not available")
-class TestCommonCrypto(object):
- def test_supports_cipher(self):
- from cryptography.hazmat.backends.commoncrypto.backend import backend
- assert backend.cipher_supported(None, None) is False
-
- def test_register_duplicate_cipher_adapter(self):
- from cryptography.hazmat.backends.commoncrypto.backend import backend
- with pytest.raises(ValueError):
- backend._register_cipher_adapter(
- AES, backend._lib.kCCAlgorithmAES128,
- CBC, backend._lib.kCCModeCBC
- )
-
- def test_handle_response(self):
- from cryptography.hazmat.backends.commoncrypto.backend import backend
-
- with pytest.raises(ValueError):
- backend._check_cipher_response(backend._lib.kCCAlignmentError)
-
- with pytest.raises(InternalError):
- backend._check_cipher_response(backend._lib.kCCMemoryFailure)
-
- with pytest.raises(InternalError):
- backend._check_cipher_response(backend._lib.kCCDecodeError)
-
- def test_nonexistent_aead_cipher(self):
- from cryptography.hazmat.backends.commoncrypto.backend import Backend
- b = Backend()
- cipher = Cipher(
- DummyCipherAlgorithm(), GCM(b"fake_iv_here"), backend=b,
- )
- with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
- cipher.encryptor()
diff --git a/tests/hazmat/bindings/test_commoncrypto.py b/tests/hazmat/bindings/test_commoncrypto.py
deleted file mode 100644
index b0a2dc43..00000000
--- a/tests/hazmat/bindings/test_commoncrypto.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-import pytest
-
-
-ccbinding = pytest.importorskip(
- "cryptography.hazmat.bindings.commoncrypto.binding"
-)
-
-
-class TestCommonCrypto(object):
- def test_binding_loads(self):
- binding = ccbinding.Binding()
- assert binding
- assert binding.lib
- assert binding.ffi
-
- def test_binding_returns_same_lib(self):
- binding = ccbinding.Binding()
- binding2 = ccbinding.Binding()
- assert binding.lib == binding2.lib
- assert binding.ffi == binding2.ffi
diff --git a/tests/hazmat/primitives/test_cast5.py b/tests/hazmat/primitives/test_cast5.py
index 59af84f5..ec51659d 100644
--- a/tests/hazmat/primitives/test_cast5.py
+++ b/tests/hazmat/primitives/test_cast5.py
@@ -82,20 +82,3 @@ class TestCAST5ModeCFB(object):
lambda key, **kwargs: algorithms.CAST5(binascii.unhexlify((key))),
lambda iv, **kwargs: modes.CFB(binascii.unhexlify(iv))
)
-
-
-@pytest.mark.supported(
- only_if=lambda backend: backend.cipher_supported(
- algorithms.CAST5(b"\x00" * 16), modes.CTR(b"\x00" * 8)
- ),
- skip_message="Does not support CAST5 CTR",
-)
-@pytest.mark.requires_backend_interface(interface=CipherBackend)
-class TestCAST5ModeCTR(object):
- test_CTR = generate_encrypt_test(
- load_nist_vectors,
- os.path.join("ciphers", "CAST5"),
- ["cast5-ctr.txt"],
- lambda key, **kwargs: algorithms.CAST5(binascii.unhexlify((key))),
- lambda iv, **kwargs: modes.CTR(binascii.unhexlify(iv))
- )
diff --git a/tests/hazmat/primitives/utils.py b/tests/hazmat/primitives/utils.py
index 59326367..b8200123 100644
--- a/tests/hazmat/primitives/utils.py
+++ b/tests/hazmat/primitives/utils.py
@@ -47,10 +47,9 @@ def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
def encrypt_test(backend, cipher_factory, mode_factory, params):
- if not backend.cipher_supported(
+ assert backend.cipher_supported(
cipher_factory(**params), mode_factory(**params)
- ):
- pytest.skip("cipher/mode combo is unsupported by this backend")
+ )
plaintext = params["plaintext"]
ciphertext = params["ciphertext"]