aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:17:39 -0430
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-16 08:17:39 -0430
commite171c5fcf47263d4aee35c555844e4c4d7aec5f0 (patch)
tree10fd0e14053b0b467279dd40e6c722c647bed865 /tests/hazmat
parent1e7ce06edb9179cf2afc66b031767d9246242fad (diff)
parent68855e0611e70486ef1ae93a0936babb3fc80704 (diff)
downloadcryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.tar.gz
cryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.tar.bz2
cryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.zip
Merge pull request #807 from Ayrx/add-backend-check-to-rsa
Added backend check to rsa primitives
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/primitives/test_rsa.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 114dc415..155ec3a9 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -21,6 +21,7 @@ import os
import pytest
from cryptography import exceptions, utils
+from cryptography.exceptions import UnsupportedInterface
from cryptography.hazmat.primitives import hashes, interfaces
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric import padding
@@ -385,6 +386,13 @@ class TestRSA(object):
rsa.RSAPublicKey(public_exponent=6, modulus=15)
+def test_rsa_generate_invalid_backend():
+ pretend_backend = object()
+
+ with pytest.raises(UnsupportedInterface):
+ rsa.RSAPrivateKey.generate(65537, 2048, pretend_backend)
+
+
@pytest.mark.rsa
class TestRSASignature(object):
@pytest.mark.parametrize(
@@ -444,6 +452,14 @@ class TestRSASignature(object):
with pytest.raises(TypeError):
private_key.signer("notpadding", hashes.SHA1(), backend)
+ def test_rsa_signer_invalid_backend(self, backend):
+ pretend_backend = object()
+ private_key = rsa.RSAPrivateKey.generate(65537, 2048, backend)
+
+ with pytest.raises(UnsupportedInterface):
+ private_key.signer(
+ padding.PKCS1v15(), hashes.SHA256, pretend_backend)
+
@pytest.mark.rsa
class TestRSAVerification(object):
@@ -559,6 +575,15 @@ class TestRSAVerification(object):
with pytest.raises(TypeError):
public_key.verifier(b"sig", "notpadding", hashes.SHA1(), backend)
+ def test_rsa_verifier_invalid_backend(self, backend):
+ pretend_backend = object()
+ private_key = rsa.RSAPrivateKey.generate(65537, 2048, backend)
+ public_key = private_key.public_key()
+
+ with pytest.raises(UnsupportedInterface):
+ public_key.verifier(
+ b"foo", padding.PKCS1v15(), hashes.SHA256(), pretend_backend)
+
class TestMGF1(object):
def test_invalid_hash_algorithm(self):