aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/ec/test_params.py
diff options
context:
space:
mode:
authorJ08nY2020-03-16 19:33:15 +0100
committerJ08nY2020-03-16 19:33:15 +0100
commit9d4d881d6d847b044959b3c080dac1c9488445e8 (patch)
tree312e9b1bc8d5aeb1b89942a9043368bec8b871b2 /test/ec/test_params.py
parentf84a5abc37d5803123ee291d7bc3ba30fd9545e0 (diff)
downloadpyecsca-9d4d881d6d847b044959b3c080dac1c9488445e8.tar.gz
pyecsca-9d4d881d6d847b044959b3c080dac1c9488445e8.tar.zst
pyecsca-9d4d881d6d847b044959b3c080dac1c9488445e8.zip
Add tests for affine coords.
Diffstat (limited to 'test/ec/test_params.py')
-rw-r--r--test/ec/test_params.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/ec/test_params.py b/test/ec/test_params.py
index 3dfb0c2..9de813b 100644
--- a/test/ec/test_params.py
+++ b/test/ec/test_params.py
@@ -1,5 +1,8 @@
from unittest import TestCase
+from parameterized import parameterized
+
+from pyecsca.ec.coordinates import AffineCoordinateModel
from pyecsca.ec.params import get_params
@@ -16,3 +19,46 @@ class DomainParameterTests(TestCase):
def test_str(self):
self.assertEqual(str(self.secp128r1), "DomainParameters(secg/secp128r1)")
+
+ @parameterized.expand([
+ ("secg/secp128r1", "projective"),
+ ("secg/secp256r1", "projective"),
+ ("secg/secp521r1", "projective"),
+ ("other/Curve25519", "xz"),
+ ("other/Ed25519", "projective"),
+ ("other/Ed448", "projective"),
+ ("other/E-222", "projective")
+ ])
+ def test_get_params(self, name, coords):
+ params = get_params(*name.split("/"), coords)
+ try:
+ assert params.curve.is_on_curve(params.generator)
+ except NotImplementedError:
+ pass
+
+ @parameterized.expand([
+ ("no_category/some", "else"),
+ ("secg/no_curve", "else"),
+ ("secg/secp128r1", "some")
+ ])
+ def test_unknown(self, name, coords):
+ with self.assertRaises(ValueError):
+ get_params(*name.split("/"), coords)
+
+ def test_assumption(self):
+ with self.assertRaises(ValueError):
+ get_params("secg", "secp128r1", "projective-1")
+ self.assertIsNotNone(get_params("secg", "secp128r1", "projective-3"))
+
+ def test_infty(self):
+ with self.assertRaises(ValueError):
+ get_params("secg", "secp128r1", "modified", False)
+ self.assertIsNotNone(get_params("secg", "secp128r1", "projective", False))
+
+ def test_no_binary(self):
+ with self.assertRaises(ValueError):
+ get_params("secg", "sect163r1", "something")
+
+ def test_affine(self):
+ aff = get_params("secg", "secp128r1", "affine")
+ self.assertIsInstance(aff.curve.coordinate_model, AffineCoordinateModel) \ No newline at end of file