From b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 6 Jun 2014 22:07:56 -0500 Subject: add load_rsa_*_numbers functions --- tests/hazmat/primitives/test_serialization.py | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py index b19990e0..53a5806f 100644 --- a/tests/hazmat/primitives/test_serialization.py +++ b/tests/hazmat/primitives/test_serialization.py @@ -23,9 +23,12 @@ from cryptography.exceptions import _Reasons from cryptography.hazmat.primitives.asymmetric import dsa, rsa from cryptography.hazmat.primitives.serialization import ( load_pem_pkcs8_private_key, - load_pem_traditional_openssl_private_key + load_pem_traditional_openssl_private_key, + load_rsa_private_numbers, + load_rsa_public_numbers ) +from .fixtures_rsa import RSA_KEY_1024 from .utils import _check_rsa_private_key, load_vectors_from_file from ...utils import raises_unsupported_algorithm @@ -544,3 +547,30 @@ class TestPKCS8Serialisation(object): pemfile.read().encode(), password, backend ) ) + + +@pytest.mark.rsa +class TestLoadRSANumbers(object): + def test_load_private_numbers(self, backend): + numbers = rsa.RSAPrivateNumbers( + p=RSA_KEY_1024["p"], + q=RSA_KEY_1024["q"], + d=RSA_KEY_1024["private_exponent"], + dmp1=RSA_KEY_1024["dmp1"], + dmq1=RSA_KEY_1024["dmq1"], + iqmp=RSA_KEY_1024["iqmp"], + public_numbers=rsa.RSAPublicNumbers( + n=RSA_KEY_1024["modulus"], + e=RSA_KEY_1024["public_exponent"] + ) + ) + private_key = load_rsa_private_numbers(numbers, backend) + assert private_key + + def test_load_public_numbers(self, backend): + numbers = rsa.RSAPublicNumbers( + n=RSA_KEY_1024["modulus"], + e=RSA_KEY_1024["public_exponent"] + ) + public_key = load_rsa_public_numbers(numbers, backend) + assert public_key -- cgit v1.2.3