| 192 | |
| 193 | @pytest.mark.skipif(PurePythonRSAKey is None, reason="python-rsa backend not available") |
| 194 | class TestPurePythonRsa: |
| 195 | def test_python_rsa_legacy_pem_read(self): |
| 196 | key = PurePythonRSAKey(LEGACY_INVALID_PRIVATE_KEY_PKCS8_PEM, ALGORITHMS.RS256) |
| 197 | new_pem = key.to_pem(pem_format="PKCS8") |
| 198 | assert new_pem != LEGACY_INVALID_PRIVATE_KEY_PKCS8_PEM |
| 199 | |
| 200 | def test_python_rsa_legacy_pem_invalid(self): |
| 201 | with pytest.raises(JWKError) as excinfo: |
| 202 | PurePythonRSAKey(_actually_invalid_private_key_pkcs8_pem(), ALGORITHMS.RS256) |
| 203 | |
| 204 | excinfo.match("Invalid private key encoding") |
| 205 | |
| 206 | def test_python_rsa_legacy_private_key_pkcs8_to_pkcs1(self): |
| 207 | legacy_key = _legacy_invalid_private_key_pkcs8_der() |
| 208 | legacy_pkcs1 = legacy_key[len(rsa_backend.LEGACY_INVALID_PKCS8_RSA_HEADER) :] |
| 209 | |
| 210 | assert rsa_backend._legacy_private_key_pkcs8_to_pkcs1(legacy_key) == legacy_pkcs1 |
| 211 | |
| 212 | def test_python_rsa_legacy_private_key_pkcs8_to_pkcs1_invalid(self): |
| 213 | invalid_key = _actually_invalid_private_key_pkcs8_der() |
| 214 | |
| 215 | with pytest.raises(ValueError) as excinfo: |
| 216 | rsa_backend._legacy_private_key_pkcs8_to_pkcs1(invalid_key) |
| 217 | |
| 218 | excinfo.match("Invalid private key encoding") |
| 219 | |
| 220 | |
| 221 | @pytest.mark.cryptography |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…