aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-06 22:07:56 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-06 22:07:56 -0500
commitb2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6 (patch)
tree1839e533a1398f891d0c92f2f02b6b47781cc8c0 /tests
parentf1de2f78cfd2b19eb4e2485ff36008581b088292 (diff)
downloadcryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.tar.gz
cryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.tar.bz2
cryptography-b2fa4b7499e9ca70568bdb33eae99a22e9ed2cc6.zip
add load_rsa_*_numbers functions
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_serialization.py32
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