From 513b7cb41671ccf7d9345075534bfa3d92c1c05e Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 12 Feb 2015 17:31:24 -0600 Subject: move cipher and mode interfaces --- tests/hazmat/backends/test_commoncrypto.py | 5 ++--- tests/hazmat/backends/test_openssl.py | 10 ++++++---- tests/hazmat/primitives/test_block.py | 11 +++++------ 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/backends/test_commoncrypto.py b/tests/hazmat/backends/test_commoncrypto.py index 7ccc1aff..c867804e 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.algorithms import AES -from cryptography.hazmat.primitives.ciphers.base import Cipher +from cryptography.hazmat.primitives.ciphers.base import Cipher, CipherAlgorithm 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..878d71bb 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -23,14 +23,16 @@ from cryptography.hazmat.primitives import hashes, interfaces from cryptography.hazmat.primitives.asymmetric import dsa, padding from cryptography.hazmat.primitives.ciphers import Cipher 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.base import ( + BlockCipherAlgorithm, CipherAlgorithm +) +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,7 +40,7 @@ class DummyMode(object): pass -@utils.register_interface(interfaces.CipherAlgorithm) +@utils.register_interface(CipherAlgorithm) class DummyCipher(object): name = "dummy-cipher" key_size = None 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() -- cgit v1.2.3 From 7c5c9fedd513f4ef66b62fcf5fdcde8dc30fe532 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 14 Feb 2015 10:27:14 -0600 Subject: export interfaces from base in ciphers, update docs --- tests/hazmat/backends/test_commoncrypto.py | 2 +- tests/hazmat/backends/test_openssl.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/backends/test_commoncrypto.py b/tests/hazmat/backends/test_commoncrypto.py index c867804e..f7200016 100644 --- a/tests/hazmat/backends/test_commoncrypto.py +++ b/tests/hazmat/backends/test_commoncrypto.py @@ -9,8 +9,8 @@ import pytest from cryptography import utils from cryptography.exceptions import InternalError, _Reasons from cryptography.hazmat.backends import _available_backends +from cryptography.hazmat.primitives.ciphers import Cipher, CipherAlgorithm from cryptography.hazmat.primitives.ciphers.algorithms import AES -from cryptography.hazmat.primitives.ciphers.base import Cipher, CipherAlgorithm from cryptography.hazmat.primitives.ciphers.modes import CBC, GCM from ...utils import raises_unsupported_algorithm diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 878d71bb..6e3d80e9 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -21,11 +21,10 @@ from cryptography.hazmat.backends.openssl.backend import ( from cryptography.hazmat.backends.openssl.ec import _sn_to_elliptic_curve from cryptography.hazmat.primitives import hashes, interfaces from cryptography.hazmat.primitives.asymmetric import dsa, padding -from cryptography.hazmat.primitives.ciphers import Cipher -from cryptography.hazmat.primitives.ciphers.algorithms import AES -from cryptography.hazmat.primitives.ciphers.base import ( - BlockCipherAlgorithm, CipherAlgorithm +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, Mode from ..primitives.fixtures_rsa import RSA_KEY_512 -- cgit v1.2.3