aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJ08nY2019-04-23 19:05:27 +0200
committerJ08nY2019-04-23 19:05:27 +0200
commit28390ec1575e0af026be2bfea6fd0bca8f55c008 (patch)
treefefdb02a66c2811be4dd95da4751a9b3756b740c /test
parent06b421731616099cc42d19e345aa71e5d6708167 (diff)
downloadpyecsca-28390ec1575e0af026be2bfea6fd0bca8f55c008.tar.gz
pyecsca-28390ec1575e0af026be2bfea6fd0bca8f55c008.tar.zst
pyecsca-28390ec1575e0af026be2bfea6fd0bca8f55c008.zip
Add proper context management.
Diffstat (limited to '')
-rw-r--r--test/ec/test_context.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ec/test_context.py b/test/ec/test_context.py
new file mode 100644
index 0000000..51fefd7
--- /dev/null
+++ b/test/ec/test_context.py
@@ -0,0 +1,23 @@
+from unittest import TestCase
+
+from pyecsca.ec.context import local, DefaultContext
+from pyecsca.ec.mult import LTRMultiplier
+from test.ec.curves import get_secp128r1
+
+
+class ContextTests(TestCase):
+
+ def setUp(self):
+ self.secp128r1 = get_secp128r1()
+ self.base = self.secp128r1.generator
+ self.coords = self.secp128r1.curve.coordinate_model
+ self.mult = LTRMultiplier(self.secp128r1, self.coords.formulas["add-1998-cmo"],
+ self.coords.formulas["dbl-1998-cmo"], self.coords.formulas["z"])
+
+ def test_null(self):
+ self.mult.multiply(59, self.base)
+
+ def test_default(self):
+ with local(DefaultContext()) as ctx:
+ self.mult.multiply(59, self.base)
+ self.assertEqual(len(ctx.actions), 10)