diff options
author | David Reid <dreid@dreid.org> | 2014-05-06 21:39:15 -0700 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2014-05-06 21:39:15 -0700 |
commit | 2d50118e682703a564a01c1c00ad5f414e2eee74 (patch) | |
tree | a27dbc6c2c1312927ced1f80162e2e40e05f0c1c /tests/hazmat | |
parent | 6994ff0da7076ab161c91bfa5df09290faf1cec4 (diff) | |
download | cryptography-2d50118e682703a564a01c1c00ad5f414e2eee74.tar.gz cryptography-2d50118e682703a564a01c1c00ad5f414e2eee74.tar.bz2 cryptography-2d50118e682703a564a01c1c00ad5f414e2eee74.zip |
Check types.
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 6d3bf2ec..b9011e1e 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -1510,3 +1510,91 @@ class TestRSANumbers(object): 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 + ) + |