diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-03 08:06:53 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-06-03 08:06:53 -0500 |
commit | 395be8ba6b482f52c76713e2d01f29c824ae96de (patch) | |
tree | fbe8f8f8b5a5ef096cc4e61682fbc68d9056f007 /tests/hazmat | |
parent | a4a462dd3b9cee4c42f8d03352009a7461db2403 (diff) | |
parent | d2a69d27d0440d37eb00578527058fc535d621ba (diff) | |
download | cryptography-395be8ba6b482f52c76713e2d01f29c824ae96de.tar.gz cryptography-395be8ba6b482f52c76713e2d01f29c824ae96de.tar.bz2 cryptography-395be8ba6b482f52c76713e2d01f29c824ae96de.zip |
Merge pull request #984 from dreid/rsa-numbers
RSA numbers
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index ea72f916..ba668bff 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -1664,3 +1664,117 @@ class TestRSAEncryption(object): ), backend ) + + +class TestRSANumbers(object): + def test_rsa_public_numbers(self): + public_numbers = rsa.RSAPublicNumbers(e=1, n=15) + assert public_numbers.e == 1 + assert public_numbers.n == 15 + + def test_rsa_private_numbers(self): + public_numbers = rsa.RSAPublicNumbers(e=1, n=15) + private_numbers = rsa.RSAPrivateNumbers( + p=3, + q=5, + d=1, + dmp1=1, + dmq1=1, + iqmp=2, + public_numbers=public_numbers + ) + + assert private_numbers.p == 3 + assert private_numbers.q == 5 + assert private_numbers.d == 1 + assert private_numbers.dmp1 == 1 + assert private_numbers.dmq1 == 1 + assert private_numbers.iqmp == 2 + assert private_numbers.public_numbers == public_numbers + + def test_public_numbers_invalid_types(self): + with pytest.raises(TypeError): + rsa.RSAPublicNumbers(e=None, n=15) + + with pytest.raises(TypeError): + rsa.RSAPublicNumbers(e=1, n=None) + + def test_private_numbers_invalid_types(self): + public_numbers = rsa.RSAPublicNumbers(e=1, n=15) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=None, + q=5, + d=1, + dmp1=1, + dmq1=1, + iqmp=2, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=None, + d=1, + dmp1=1, + dmq1=1, + iqmp=2, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=5, + d=None, + dmp1=1, + dmq1=1, + iqmp=2, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=5, + d=1, + dmp1=None, + dmq1=1, + iqmp=2, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=5, + d=1, + dmp1=1, + dmq1=None, + iqmp=2, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=5, + d=1, + dmp1=1, + dmq1=1, + iqmp=None, + public_numbers=public_numbers + ) + + with pytest.raises(TypeError): + rsa.RSAPrivateNumbers( + p=3, + q=5, + d=1, + dmp1=1, + dmq1=1, + iqmp=2, + public_numbers=None + ) |