diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-06 22:07:56 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-06 22:07:56 -0500 |
commit | b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6 (patch) | |
tree | 1839e533a1398f891d0c92f2f02b6b47781cc8c0 /tests/hazmat/primitives | |
parent | f1de2f78cfd2b19eb4e2485ff36008581b088292 (diff) | |
download | cryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.tar.gz cryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.tar.bz2 cryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.zip |
add load_rsa_*_numbers functions
Diffstat (limited to 'tests/hazmat/primitives')
-rw-r--r-- | tests/hazmat/primitives/test_serialization.py | 32 |
1 files changed, 31 insertions, 1 deletions
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 |