From 2f34994fe909d8862225c03427c7b4525fff4190 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 15 Jan 2019 20:52:38 -0600 Subject: add support for byteslike on password and data for pkcs12 loading (#4690) * add support for byteslike on password and data for pkcs12 loading * use a contextmanager to yield a null terminated buffer we can zero * review feedback * updated text * one last change --- tests/hazmat/primitives/test_pkcs12.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/hazmat/primitives/test_pkcs12.py') diff --git a/tests/hazmat/primitives/test_pkcs12.py b/tests/hazmat/primitives/test_pkcs12.py index 85be3b51..f084d578 100644 --- a/tests/hazmat/primitives/test_pkcs12.py +++ b/tests/hazmat/primitives/test_pkcs12.py @@ -108,3 +108,16 @@ class TestPKCS12(object): derfile.read(), b"invalid", backend ), mode="rb" ) + + def test_buffer_protocol(self, backend): + p12 = load_vectors_from_file( + os.path.join("pkcs12", "cert-key-aes256cbc.p12"), + lambda derfile: derfile.read(), mode="rb" + ) + p12buffer = bytearray(p12) + parsed_key, parsed_cert, parsed_more_certs = load_key_and_certificates( + p12buffer, bytearray(b"cryptography"), backend + ) + assert parsed_key is not None + assert parsed_cert is not None + assert parsed_more_certs == [] -- cgit v1.2.3