aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/backends/test_commoncrypto.py5
-rw-r--r--tests/hazmat/backends/test_openssl.py24
-rw-r--r--tests/hazmat/primitives/test_block.py11
-rw-r--r--tests/hazmat/primitives/test_rsa.py2
-rw-r--r--tests/utils.py4
5 files changed, 24 insertions, 22 deletions
diff --git a/tests/hazmat/backends/test_commoncrypto.py b/tests/hazmat/backends/test_commoncrypto.py
index 7ccc1aff..f7200016 100644
--- a/tests/hazmat/backends/test_commoncrypto.py
+++ b/tests/hazmat/backends/test_commoncrypto.py
@@ -9,15 +9,14 @@ import pytest
from cryptography import utils
from cryptography.exceptions import InternalError, _Reasons
from cryptography.hazmat.backends import _available_backends
-from cryptography.hazmat.primitives import interfaces
+from cryptography.hazmat.primitives.ciphers import Cipher, CipherAlgorithm
from cryptography.hazmat.primitives.ciphers.algorithms import AES
-from cryptography.hazmat.primitives.ciphers.base import Cipher
from cryptography.hazmat.primitives.ciphers.modes import CBC, GCM
from ...utils import raises_unsupported_algorithm
-@utils.register_interface(interfaces.CipherAlgorithm)
+@utils.register_interface(CipherAlgorithm)
class DummyCipher(object):
name = "dummy-cipher"
block_size = None
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index 97d58085..2bf66a0c 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -19,18 +19,19 @@ from cryptography.hazmat.backends.openssl.backend import (
Backend, backend
)
from cryptography.hazmat.backends.openssl.ec import _sn_to_elliptic_curve
-from cryptography.hazmat.primitives import hashes, interfaces
+from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import dsa, padding
-from cryptography.hazmat.primitives.ciphers import Cipher
+from cryptography.hazmat.primitives.ciphers import (
+ BlockCipherAlgorithm, Cipher, CipherAlgorithm
+)
from cryptography.hazmat.primitives.ciphers.algorithms import AES
-from cryptography.hazmat.primitives.ciphers.modes import CBC, CTR
-from cryptography.hazmat.primitives.interfaces import BlockCipherAlgorithm
+from cryptography.hazmat.primitives.ciphers.modes import CBC, CTR, Mode
from ..primitives.fixtures_rsa import RSA_KEY_512
from ...utils import load_vectors_from_file, raises_unsupported_algorithm
-@utils.register_interface(interfaces.Mode)
+@utils.register_interface(Mode)
class DummyMode(object):
name = "dummy-mode"
@@ -38,13 +39,13 @@ class DummyMode(object):
pass
-@utils.register_interface(interfaces.CipherAlgorithm)
+@utils.register_interface(CipherAlgorithm)
class DummyCipher(object):
name = "dummy-cipher"
key_size = None
-@utils.register_interface(interfaces.AsymmetricPadding)
+@utils.register_interface(padding.AsymmetricPadding)
class DummyPadding(object):
name = "dummy-cipher"
@@ -70,10 +71,13 @@ class TestOpenSSL(object):
Unfortunately, this define does not appear to have a
formal content definition, so for now we'll test to see
- if it starts with OpenSSL as that appears to be true
- for every OpenSSL.
+ if it starts with OpenSSL or LibreSSL as that appears
+ to be true for every OpenSSL-alike.
"""
- assert backend.openssl_version_text().startswith("OpenSSL")
+ assert (
+ backend.openssl_version_text().startswith("OpenSSL") or
+ backend.openssl_version_text().startswith("LibreSSL")
+ )
def test_supports_cipher(self):
assert backend.cipher_supported(None, None) is False
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index 22e6d0e9..1b3fc1cb 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -13,9 +13,8 @@ from cryptography.exceptions import (
AlreadyFinalized, _Reasons
)
from cryptography.hazmat.backends.interfaces import CipherBackend
-from cryptography.hazmat.primitives import interfaces
from cryptography.hazmat.primitives.ciphers import (
- Cipher, algorithms, modes
+ Cipher, algorithms, base, modes
)
from .utils import (
@@ -24,7 +23,7 @@ from .utils import (
from ...utils import raises_unsupported_algorithm
-@utils.register_interface(interfaces.Mode)
+@utils.register_interface(modes.Mode)
class DummyMode(object):
name = "dummy-mode"
@@ -32,7 +31,7 @@ class DummyMode(object):
pass
-@utils.register_interface(interfaces.CipherAlgorithm)
+@utils.register_interface(base.CipherAlgorithm)
class DummyCipher(object):
name = "dummy-cipher"
key_size = None
@@ -46,7 +45,7 @@ class TestCipher(object):
modes.CBC(binascii.unhexlify(b"0" * 32)),
backend
)
- assert isinstance(cipher.encryptor(), interfaces.CipherContext)
+ assert isinstance(cipher.encryptor(), base.CipherContext)
def test_creates_decryptor(self, backend):
cipher = Cipher(
@@ -54,7 +53,7 @@ class TestCipher(object):
modes.CBC(binascii.unhexlify(b"0" * 32)),
backend
)
- assert isinstance(cipher.decryptor(), interfaces.CipherContext)
+ assert isinstance(cipher.decryptor(), base.CipherContext)
def test_instantiate_with_non_algorithm(self, backend):
algorithm = object()
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 33e5373b..6d8e6874 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -37,7 +37,7 @@ from ...utils import (
)
-@utils.register_interface(interfaces.AsymmetricPadding)
+@utils.register_interface(padding.AsymmetricPadding)
class DummyPadding(object):
name = "UNSUPPORTED-PADDING"
diff --git a/tests/utils.py b/tests/utils.py
index 37efc580..65c99fbf 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -83,8 +83,8 @@ def load_nist_vectors(vector_data):
line = line.strip()
# Blank lines, comments, and section headers are ignored
- if not line or line.startswith("#") or (line.startswith("[")
- and line.endswith("]")):
+ if not line or line.startswith("#") or (line.startswith("[") and
+ line.endswith("]")):
continue
if line.strip() == "FAIL":