diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-07-10 08:10:17 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-07-10 08:10:17 -0500 |
commit | a9d14965880829535859343db2494822580dd884 (patch) | |
tree | 1af7cf880ad9cb30b1d22c3722086c8038f3fef2 | |
parent | 3fbdd4a63c3089b527bf9c1d48fc37a1b689243a (diff) | |
parent | 20c85a52c48c09942285ca7f870595c5973c7a55 (diff) | |
download | cryptography-a9d14965880829535859343db2494822580dd884.tar.gz cryptography-a9d14965880829535859343db2494822580dd884.tar.bz2 cryptography-a9d14965880829535859343db2494822580dd884.zip |
Merge pull request #1244 from Ayrx/add-rsa-repr
Add a sensible repr to RSAPublicNumbers
-rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 3 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index 15ec52ac..398b3763 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -402,3 +402,6 @@ class RSAPublicNumbers(object): def public_key(self, backend): return backend.load_rsa_public_numbers(self) + + def __repr__(self): + return "<RSAPublicNumbers(e={0}, n={1})>".format(self._e, self._n) diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 8e850737..e53ff06b 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -27,6 +27,7 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.primitives import hashes, interfaces from cryptography.hazmat.primitives.asymmetric import padding, rsa +from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicNumbers from .fixtures_rsa import ( RSA_KEY_1024, RSA_KEY_1025, RSA_KEY_1026, RSA_KEY_1027, RSA_KEY_1028, @@ -1973,3 +1974,7 @@ class TestRSANumbers(object): n=33 ) ).private_key(backend) + + def test_public_number_repr(self): + num = RSAPublicNumbers(1, 1) + assert repr(num) == "<RSAPublicNumbers(e=1, n=1)>" |