aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-04-19 20:31:29 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-04-19 20:31:29 -0700
commit75db7f4902ffd756f06c14e4328ebeda6a527800 (patch)
tree2f589a4bffbe05facab0e821d3b07675ba904167 /tests/hazmat
parente6610ba910e3c7dc0ca55700c27f77c3029c83d3 (diff)
parent07827ebe994121262ab0d25936c443d81be7f9c4 (diff)
downloadcryptography-75db7f4902ffd756f06c14e4328ebeda6a527800.tar.gz
cryptography-75db7f4902ffd756f06c14e4328ebeda6a527800.tar.bz2
cryptography-75db7f4902ffd756f06c14e4328ebeda6a527800.zip
Merge pull request #840 from reaperhulk/pkcs1-key-size-checks
some checks for PKCS1 keys being too small for the payload to be signed
Diffstat (limited to 'tests/hazmat')
-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):