diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-04-30 18:57:15 -0400 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-04-30 17:57:15 -0500 |
commit | c16de483685b0d5afa77bd88bd4a561b09e899b1 (patch) | |
tree | 8294e8389f6ef9d1f010005d47cca89e8800055d /tests/hazmat | |
parent | 988df9ba0326f5adc84ee6ca51607674737f1469 (diff) | |
download | cryptography-c16de483685b0d5afa77bd88bd4a561b09e899b1.tar.gz cryptography-c16de483685b0d5afa77bd88bd4a561b09e899b1.tar.bz2 cryptography-c16de483685b0d5afa77bd88bd4a561b09e899b1.zip |
Fixed #2887 -- implement __hash__ on EC numbers classes (#2888)
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/primitives/test_ec.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 08619b48..8747ea4f 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -223,6 +223,30 @@ def test_ec_public_numbers_repr(): assert repr(pn) == "<EllipticCurvePublicNumbers(curve=secp256r1, x=2, y=3>" +def test_ec_public_numbers_hash(): + pn1 = ec.EllipticCurvePublicNumbers(2, 3, ec.SECP256R1()) + pn2 = ec.EllipticCurvePublicNumbers(2, 3, ec.SECP256R1()) + pn3 = ec.EllipticCurvePublicNumbers(1, 3, ec.SECP256R1()) + + assert hash(pn1) == hash(pn2) + assert hash(pn1) != hash(pn3) + + +def test_ec_private_numbers_hash(): + numbers1 = ec.EllipticCurvePrivateNumbers( + 1, ec.EllipticCurvePublicNumbers(2, 3, DummyCurve()) + ) + numbers2 = ec.EllipticCurvePrivateNumbers( + 1, ec.EllipticCurvePublicNumbers(2, 3, DummyCurve()) + ) + numbers3 = ec.EllipticCurvePrivateNumbers( + 2, ec.EllipticCurvePublicNumbers(2, 3, DummyCurve()) + ) + + assert hash(numbers1) == hash(numbers2) + assert hash(numbers1) != hash(numbers3) + + @pytest.mark.requires_backend_interface(interface=EllipticCurveBackend) class TestECWithNumbers(object): @pytest.mark.parametrize( |