MCPcopy
hub / github.com/pyca/cryptography / test_rsa_pkcs1v15_signature

Function test_rsa_pkcs1v15_signature

tests/wycheproof/test_rsa.py:69–98  ·  view source on GitHub ↗
(backend, wycheproof)

Source from the content-addressed store, hash-verified

67 "rsa_signature_8192_sha512_test.json",
68)
69def test_rsa_pkcs1v15_signature(backend, wycheproof):
70 key = wycheproof.cache_value_to_group(
71 "cached_key",
72 lambda: serialization.load_der_public_key(
73 binascii.unhexlify(wycheproof.testgroup["publicKeyDer"]),
74 ),
75 )
76 assert isinstance(key, rsa.RSAPublicKey)
77 digest = _DIGESTS[wycheproof.testgroup["sha"]]
78
79 if digest is None or not backend.hash_supported(digest):
80 pytest.skip(
81 "Hash {} not supported".format(wycheproof.testgroup["sha"])
82 )
83
84 if should_verify(backend, wycheproof):
85 key.verify(
86 binascii.unhexlify(wycheproof.testcase["sig"]),
87 binascii.unhexlify(wycheproof.testcase["msg"]),
88 padding.PKCS1v15(),
89 digest,
90 )
91 else:
92 with pytest.raises(InvalidSignature):
93 key.verify(
94 binascii.unhexlify(wycheproof.testcase["sig"]),
95 binascii.unhexlify(wycheproof.testcase["msg"]),
96 padding.PKCS1v15(),
97 digest,
98 )
99
100
101@wycheproof_tests(

Callers

nothing calls this directly

Calls 5

should_verifyFunction · 0.85
cache_value_to_groupMethod · 0.80
unhexlifyMethod · 0.80
hash_supportedMethod · 0.80
verifyMethod · 0.45

Tested by

no test coverage detected