aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-21 19:24:24 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-19 22:16:15 -0500
commit95c30fb8c7f72f28ba6460602b080b638b74f19c (patch)
tree11646a4ac860e5162806795673572f1560ad1fb8 /tests
parente6610ba910e3c7dc0ca55700c27f77c3029c83d3 (diff)
downloadcryptography-95c30fb8c7f72f28ba6460602b080b638b74f19c.tar.gz
cryptography-95c30fb8c7f72f28ba6460602b080b638b74f19c.tar.bz2
cryptography-95c30fb8c7f72f28ba6460602b080b638b74f19c.zip
some checks for PKCS1 keys being too small for the payload to be signed
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_rsa.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 236a3bb1..1cbd1636 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -655,6 +655,35 @@ class TestRSASignature(object):
private_key.signer(padding.PSS(mgf=DummyMGF()), hashes.SHA1(),
backend)
+ def test_pkcs1_digest_too_large_for_key_size(self, backend):
+ private_key = rsa.RSAPrivateKey.generate(
+ public_exponent=65537,
+ key_size=599,
+ backend=backend
+ )
+ signer = private_key.signer(
+ padding.PKCS1v15(),
+ hashes.SHA512(),
+ backend
+ )
+ signer.update(b"failure coming")
+ with pytest.raises(ValueError):
+ signer.finalize()
+
+ def test_pkcs1_minimum_key_size(self, backend):
+ private_key = rsa.RSAPrivateKey.generate(
+ public_exponent=65537,
+ key_size=745,
+ backend=backend
+ )
+ signer = private_key.signer(
+ padding.PKCS1v15(),
+ hashes.SHA512(),
+ backend
+ )
+ signer.update(b"no failure")
+ signer.finalize()
+
@pytest.mark.rsa
class TestRSAVerification(object):