diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-10-27 23:48:45 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-10-27 23:48:45 -0400 |
commit | 064d02bd2cf79a958f210bd7aa0a70e426fadba5 (patch) | |
tree | 554457c88ab260fa90b27f8f1825820783f9cb05 | |
parent | d3f4ecdbefe20f4f9cb8b74701c5757557e476e1 (diff) | |
parent | 4ef99da4918d37ce34890c78a34f28755cb34ef7 (diff) | |
download | cryptography-064d02bd2cf79a958f210bd7aa0a70e426fadba5.tar.gz cryptography-064d02bd2cf79a958f210bd7aa0a70e426fadba5.tar.bz2 cryptography-064d02bd2cf79a958f210bd7aa0a70e426fadba5.zip |
Merge pull request #2450 from reaperhulk/numbers-repr
add ellipticcurvepublicnumbers repr
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/ec.py | 6 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_ec.py | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index 7782133c..eda7df0c 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -302,6 +302,12 @@ class EllipticCurvePublicNumbers(object): def __ne__(self, other): return not self == other + def __repr__(self): + return ( + "<EllipticCurvePublicNumbers(curve={0.curve.name}, x={0.x}, " + "y={0.y}>".format(self) + ) + class EllipticCurvePrivateNumbers(object): def __init__(self, private_value, public_numbers): diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 5baaa3cd..d420e9c9 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -215,6 +215,11 @@ def test_from_encoded_point_not_a_curve(): ) +def test_ec_public_numbers_repr(): + pn = ec.EllipticCurvePublicNumbers(2, 3, ec.SECP256R1()) + assert repr(pn) == "<EllipticCurvePublicNumbers(curve=secp256r1, x=2, y=3>" + + @pytest.mark.requires_backend_interface(interface=EllipticCurveBackend) class TestECWithNumbers(object): @pytest.mark.parametrize( |