aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-22 16:14:54 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-22 16:14:54 -0600
commit9eca43c41000bd3e7985e39854881e3a61e99803 (patch)
tree47c5bf197b25dbe6a7e4efba7ce5d7c41efcecad /tests
parentcd9dc6d9e4253fcac423114c26a7ca32dfe7ac05 (diff)
downloadcryptography-9eca43c41000bd3e7985e39854881e3a61e99803.tar.gz
cryptography-9eca43c41000bd3e7985e39854881e3a61e99803.tar.bz2
cryptography-9eca43c41000bd3e7985e39854881e3a61e99803.zip
GCM support for CommonCrypto backend
Diffstat (limited to 'tests')
-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()