diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2020-04-26 13:36:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 12:36:11 -0500 |
commit | 263bad82edd237ec32863068f4a76e24c083a61d (patch) | |
tree | 378a549ea7267ab4abd95b3d6072cfaa7f46f14f | |
parent | 069691a27b98bbca13faa843a1408d631b691bea (diff) | |
download | cryptography-263bad82edd237ec32863068f4a76e24c083a61d.tar.gz cryptography-263bad82edd237ec32863068f4a76e24c083a61d.tar.bz2 cryptography-263bad82edd237ec32863068f4a76e24c083a61d.zip |
Refs #5075 -- added the remainder of the wycheproof rsa tests (#5237)
-rw-r--r-- | tests/wycheproof/test_rsa.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/wycheproof/test_rsa.py b/tests/wycheproof/test_rsa.py index f17eff69..a7c26e6a 100644 --- a/tests/wycheproof/test_rsa.py +++ b/tests/wycheproof/test_rsa.py @@ -99,11 +99,32 @@ def test_rsa_pkcs1v15_signature(backend, wycheproof): ) +@pytest.mark.wycheproof_tests( + "rsa_sig_gen_misc_test.json" +) +def test_rsa_pkcs1v15_signature_generation(backend, wycheproof): + key = serialization.load_pem_private_key( + wycheproof.testgroup["privateKeyPem"].encode(), + password=None, + backend=backend, + ) + digest = _DIGESTS[wycheproof.testgroup["sha"]] + + sig = key.sign( + binascii.unhexlify(wycheproof.testcase["msg"]), + padding.PKCS1v15(), + digest, + ) + assert sig == binascii.unhexlify(wycheproof.testcase["sig"]) + + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.wycheproof_tests( "rsa_pss_2048_sha1_mgf1_20_test.json", "rsa_pss_2048_sha256_mgf1_0_test.json", "rsa_pss_2048_sha256_mgf1_32_test.json", + "rsa_pss_2048_sha512_256_mgf1_28_test.json", + "rsa_pss_2048_sha512_256_mgf1_32_test.json", "rsa_pss_3072_sha256_mgf1_32_test.json", "rsa_pss_4096_sha256_mgf1_32_test.json", "rsa_pss_4096_sha512_mgf1_32_test.json", @@ -116,6 +137,13 @@ def test_rsa_pss_signature(backend, wycheproof): digest = _DIGESTS[wycheproof.testgroup["sha"]] mgf_digest = _DIGESTS[wycheproof.testgroup["mgfSha"]] + if digest is None or mgf_digest is None: + pytest.skip( + "PSS with digest={} and MGF digest={} not supported".format( + wycheproof.testgroup["sha"], wycheproof.testgroup["mgfSha"], + ) + ) + if wycheproof.valid or wycheproof.acceptable: key.verify( binascii.unhexlify(wycheproof.testcase["sig"]), |