aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/bindings/test_openssl.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
index fb01c10a..f283a7dd 100644
--- a/tests/hazmat/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -13,11 +13,21 @@
import pytest
+from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.bindings.openssl.backend import backend, Backend
+from cryptography.hazmat.primitives.block import BlockCipher
from cryptography.hazmat.primitives.block.ciphers import AES
from cryptography.hazmat.primitives.block.modes import CBC
+class FakeMode(object):
+ pass
+
+
+class FakeCipher(object):
+ pass
+
+
class TestOpenSSL(object):
def test_backend_exists(self):
assert backend
@@ -44,3 +54,16 @@ class TestOpenSSL(object):
b = Backend()
assert b.ffi is backend.ffi
assert b.lib is backend.lib
+
+ def test_nonexistent_cipher(self):
+ b = Backend()
+ b.ciphers.register_cipher_adapter(
+ FakeCipher,
+ FakeMode,
+ lambda backend, cipher, mode: backend.ffi.NULL
+ )
+ cipher = BlockCipher(
+ FakeCipher(), FakeMode(), backend=b,
+ )
+ with pytest.raises(UnsupportedAlgorithm):
+ cipher.encryptor()