diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2024-02-19 19:44:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 16:44:28 -0800 |
commit | 8224447b1eba88038d9f9a760e9f2a7d91ede28e (patch) | |
tree | c4f2f4c88837b226c19cbd835830a7a7590408a3 /tests | |
parent | fb2d6ec75a704a503f305d24a0f34d9b2e08e4dc (diff) | |
download | pyca-cryptography-8224447b1eba88038d9f9a760e9f2a7d91ede28e.zip pyca-cryptography-8224447b1eba88038d9f9a760e9f2a7d91ede28e.tar.gz pyca-cryptography-8224447b1eba88038d9f9a760e9f2a7d91ede28e.tar.bz2 |
Convert PKCS#12 loading to Rust (#10434)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 9 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_pkcs12.py | 17 |
2 files changed, 15 insertions, 11 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 7cf98af..901eec5 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -201,15 +201,6 @@ class TestOpenSSLRSA: class TestOpenSSLSerializationWithOpenSSL: - def test_unsupported_evp_pkey_type(self): - key = backend._lib.EVP_PKEY_new() - key = backend._ffi.gc(key, backend._lib.EVP_PKEY_free) - with raises_unsupported_algorithm(None): - rust_openssl.keys.private_key_from_ptr( - int(backend._ffi.cast("uintptr_t", key)), - unsafe_skip_rsa_key_validation=False, - ) - def test_very_long_pem_serialization_password(self): password = b"x" * 1025 diff --git a/tests/hazmat/primitives/test_pkcs12.py b/tests/hazmat/primitives/test_pkcs12.py index d9f2cde..e096894 100644 --- a/tests/hazmat/primitives/test_pkcs12.py +++ b/tests/hazmat/primitives/test_pkcs12.py @@ -91,7 +91,7 @@ class TestPKCS12Loading: def test_load_pkcs12_ec_keys_rc2(self, filename, password, backend): self._test_load_pkcs12_ec_keys(filename, password, backend) - def test_load_pkcs12_cert_only(self, backend): + def test_load_key_and_cert_cert_only(self, backend): cert, _ = _load_ca(backend) parsed_key, parsed_cert, parsed_more_certs = load_vectors_from_file( os.path.join("pkcs12", "cert-aes256cbc-no-key.p12"), @@ -104,7 +104,7 @@ class TestPKCS12Loading: assert parsed_key is None assert parsed_more_certs == [cert] - def test_load_pkcs12_key_only(self, backend): + def test_load_key_and_certificates_key_only(self, backend): _, key = _load_ca(backend) assert isinstance(key, ec.EllipticCurvePrivateKey) parsed_key, parsed_cert, parsed_more_certs = load_vectors_from_file( @@ -119,6 +119,19 @@ class TestPKCS12Loading: assert parsed_cert is None assert parsed_more_certs == [] + def test_load_pkcs12_key_only(self, backend): + _, key = _load_ca(backend) + assert isinstance(key, ec.EllipticCurvePrivateKey) + p12 = load_vectors_from_file( + os.path.join("pkcs12", "no-cert-key-aes256cbc.p12"), + lambda data: load_pkcs12(data.read(), b"cryptography", backend), + mode="rb", + ) + assert isinstance(p12.key, ec.EllipticCurvePrivateKey) + assert p12.key.private_numbers() == key.private_numbers() + assert p12.cert is None + assert p12.additional_certs == [] + def test_non_bytes(self, backend): with pytest.raises(TypeError): load_key_and_certificates( |