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

Function test_rsa_pkcs1v15_signature_generation

tests/wycheproof/test_rsa.py:108–135  ·  tests/wycheproof/test_rsa.py::test_rsa_pkcs1v15_signature_generation
(backend, wycheproof)

Source from the content-addressed store, hash-verified

106 class="st">"rsa_pkcs1_4096_sig_gen_test.json",
107)
108def test_rsa_pkcs1v15_signature_generation(backend, wycheproof):
109 key = wycheproof.cache_value_to_group(
110 class="st">"cached_key",
111 lambda: serialization.load_der_private_key(
112 binascii.unhexlify(wycheproof.testgroup[class="st">"privateKeyPkcs8"]),
113 password=None,
114 unsafe_skip_rsa_key_validation=True,
115 ),
116 )
117 assert isinstance(key, rsa.RSAPrivateKey)
118
119 digest = _DIGESTS[wycheproof.testgroup[class="st">"sha"]]
120 assert digest is not None
121 if backend._fips_enabled:
122 if key.key_size < backend._fips_rsa_min_key_size or isinstance(
123 digest, hashes.SHA1
124 ):
125 pytest.skip(
126 fclass="st">"Invalid params for FIPS. key: {key.key_size} bits, "
127 fclass="st">"digest: {digest.name}"
128 )
129
130 sig = key.sign(
131 binascii.unhexlify(wycheproof.testcase[class="st">"msg"]),
132 padding.PKCS1v15(),
133 digest,
134 )
135 assert sig == binascii.unhexlify(wycheproof.testcase[class="st">"sig"])
136
137
138@wycheproof_tests(

Callers

nothing calls this directly

Calls 3

cache_value_to_groupMethod · 0.80
unhexlifyMethod · 0.80
signMethod · 0.45

Tested by

no test coverage detected