aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_ec.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_ec.py')
-rw-r--r--tests/hazmat/primitives/test_ec.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py
index a006f01f..84c447c1 100644
--- a/tests/hazmat/primitives/test_ec.py
+++ b/tests/hazmat/primitives/test_ec.py
@@ -360,3 +360,40 @@ class TestECDSAVectors(object):
numbers = ec.EllipticCurvePrivateNumbers(1, pub_numbers)
assert numbers.private_key(b) == b"private_key"
assert pub_numbers.public_key(b) == b"public_key"
+
+
+class TestECNumbersEquality(object):
+ def test_public_numbers_eq(self):
+ pub = ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ assert pub == ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+
+ def test_public_numbers_ne(self):
+ pub = ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ assert pub != ec.EllipticCurvePublicNumbers(1, 2, ec.SECP384R1())
+ assert pub != ec.EllipticCurvePublicNumbers(1, 3, ec.SECP192R1())
+ assert pub != ec.EllipticCurvePublicNumbers(2, 2, ec.SECP192R1())
+ assert pub != object()
+
+ def test_private_numbers_eq(self):
+ pub = ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ priv = ec.EllipticCurvePrivateNumbers(1, pub)
+ assert priv == ec.EllipticCurvePrivateNumbers(
+ 1, ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ )
+
+ def test_private_numbers_ne(self):
+ pub = ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ priv = ec.EllipticCurvePrivateNumbers(1, pub)
+ assert priv != ec.EllipticCurvePrivateNumbers(
+ 2, ec.EllipticCurvePublicNumbers(1, 2, ec.SECP192R1())
+ )
+ assert priv != ec.EllipticCurvePrivateNumbers(
+ 1, ec.EllipticCurvePublicNumbers(2, 2, ec.SECP192R1())
+ )
+ assert priv != ec.EllipticCurvePrivateNumbers(
+ 1, ec.EllipticCurvePublicNumbers(1, 3, ec.SECP192R1())
+ )
+ assert priv != ec.EllipticCurvePrivateNumbers(
+ 1, ec.EllipticCurvePublicNumbers(1, 2, ec.SECP521R1())
+ )
+ assert priv != object()