From 20456e96ed510f96c5bdc24b799b89200e3dba4c Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 27 Feb 2015 22:45:24 -0600 Subject: [PATCH] add exact byte test --- tests/hazmat/primitives/test_rsa.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 8dcb64504568..dde73b064e2a 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -1798,6 +1798,23 @@ def test_as_bytes_unencrypted_pem(self, backend, fmt): priv_num = key.private_numbers() assert loaded_priv_num == priv_num + def test_as_bytes_traditional_openssl_unencrypted_pem(self, backend): + key_bytes = load_vectors_from_file( + os.path.join( + "asymmetric", + "Traditional_OpenSSL_Serialization", + "testrsa.pem" + ), + lambda pemfile: pemfile.read().encode() + ) + key = serialization.load_pem_private_key(key_bytes, None, backend) + serialized = key.as_bytes( + serialization.Encoding.PEM, + serialization.Format.TraditionalOpenSSL, + serialization.NoEncryption() + ) + assert serialized == key_bytes + def test_as_bytes_invalid_encoding(self, backend): key = RSA_KEY_2048.private_key(backend) _skip_if_no_serialization(key, backend)