Skip to content

Commit 263bad8

Browse files
authored
Refs pyca#5075 -- added the remainder of the wycheproof rsa tests (pyca#5237)
1 parent 069691a commit 263bad8

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/wycheproof/test_rsa.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,32 @@ def test_rsa_pkcs1v15_signature(backend, wycheproof):
9999
)
100100

101101

102+
@pytest.mark.wycheproof_tests(
103+
"rsa_sig_gen_misc_test.json"
104+
)
105+
def test_rsa_pkcs1v15_signature_generation(backend, wycheproof):
106+
key = serialization.load_pem_private_key(
107+
wycheproof.testgroup["privateKeyPem"].encode(),
108+
password=None,
109+
backend=backend,
110+
)
111+
digest = _DIGESTS[wycheproof.testgroup["sha"]]
112+
113+
sig = key.sign(
114+
binascii.unhexlify(wycheproof.testcase["msg"]),
115+
padding.PKCS1v15(),
116+
digest,
117+
)
118+
assert sig == binascii.unhexlify(wycheproof.testcase["sig"])
119+
120+
102121
@pytest.mark.requires_backend_interface(interface=RSABackend)
103122
@pytest.mark.wycheproof_tests(
104123
"rsa_pss_2048_sha1_mgf1_20_test.json",
105124
"rsa_pss_2048_sha256_mgf1_0_test.json",
106125
"rsa_pss_2048_sha256_mgf1_32_test.json",
126+
"rsa_pss_2048_sha512_256_mgf1_28_test.json",
127+
"rsa_pss_2048_sha512_256_mgf1_32_test.json",
107128
"rsa_pss_3072_sha256_mgf1_32_test.json",
108129
"rsa_pss_4096_sha256_mgf1_32_test.json",
109130
"rsa_pss_4096_sha512_mgf1_32_test.json",
@@ -116,6 +137,13 @@ def test_rsa_pss_signature(backend, wycheproof):
116137
digest = _DIGESTS[wycheproof.testgroup["sha"]]
117138
mgf_digest = _DIGESTS[wycheproof.testgroup["mgfSha"]]
118139

140+
if digest is None or mgf_digest is None:
141+
pytest.skip(
142+
"PSS with digest={} and MGF digest={} not supported".format(
143+
wycheproof.testgroup["sha"], wycheproof.testgroup["mgfSha"],
144+
)
145+
)
146+
119147
if wycheproof.valid or wycheproof.acceptable:
120148
key.verify(
121149
binascii.unhexlify(wycheproof.testcase["sig"]),

0 commit comments

Comments
 (0)