aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_commoncrypto.py
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-22 17:10:22 -0800
committerDavid Reid <dreid@dreid.org>2014-01-22 17:10:22 -0800
commit7f57186cdbc6fb1482dc83500fc688af2fdc025e (patch)
treee498d70eb9ee6a98e28897513145a6f72ab4225b /tests/hazmat/backends/test_commoncrypto.py
parent692e3de12283e6e340a4c12078a8ebeb8d31cab9 (diff)
parent0437e8d0c85f0cf365026fac03cb32576492d406 (diff)
downloadcryptography-7f57186cdbc6fb1482dc83500fc688af2fdc025e.tar.gz
cryptography-7f57186cdbc6fb1482dc83500fc688af2fdc025e.tar.bz2
cryptography-7f57186cdbc6fb1482dc83500fc688af2fdc025e.zip
Merge pull request #495 from reaperhulk/commoncrypto-gcm-backend
CommonCrypto GCM backend support
Diffstat (limited to 'tests/hazmat/backends/test_commoncrypto.py')
-rw-r--r--tests/hazmat/backends/test_commoncrypto.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/hazmat/backends/test_commoncrypto.py b/tests/hazmat/backends/test_commoncrypto.py
index 68ab6bc1..cfa332d0 100644
--- a/tests/hazmat/backends/test_commoncrypto.py
+++ b/tests/hazmat/backends/test_commoncrypto.py
@@ -13,9 +13,19 @@
import pytest
+from cryptography import utils
+from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.bindings.commoncrypto.binding import Binding
+from cryptography.hazmat.primitives import interfaces
from cryptography.hazmat.primitives.ciphers.algorithms import AES
-from cryptography.hazmat.primitives.ciphers.modes import CBC
+from cryptography.hazmat.primitives.ciphers.base import Cipher
+from cryptography.hazmat.primitives.ciphers.modes import CBC, GCM
+
+
+@utils.register_interface(interfaces.CipherAlgorithm)
+class DummyCipher(object):
+ name = "dummy-cipher"
+ block_size = 128
@pytest.mark.skipif(not Binding.is_available(),
@@ -44,3 +54,12 @@ class TestCommonCrypto(object):
with pytest.raises(SystemError):
backend._check_response(backend._lib.kCCDecodeError)
+
+ def test_nonexistent_aead_cipher(self):
+ from cryptography.hazmat.backends.commoncrypto.backend import Backend
+ b = Backend()
+ cipher = Cipher(
+ DummyCipher(), GCM(b"fake_iv_here"), backend=b,
+ )
+ with pytest.raises(UnsupportedAlgorithm):
+ cipher.encryptor()