aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test_render.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_render.py')
-rw-r--r--test/test_render.py67
1 files changed, 41 insertions, 26 deletions
diff --git a/test/test_render.py b/test/test_render.py
index b8d6075..b190e35 100644
--- a/test/test_render.py
+++ b/test/test_render.py
@@ -1,34 +1,49 @@
import tempfile
-from unittest import TestCase
-from pyecsca.ec.configuration import (HashType, RandomMod, Multiplication, Squaring, Reduction,
- Inversion)
-from pyecsca.ec.params import get_params
+from pyecsca.ec.configuration import (
+ HashType,
+ RandomMod,
+ Multiplication,
+ Squaring,
+ Reduction,
+ Inversion,
+)
from pyecsca.ec.mult import LTRMultiplier
from pyecsca.codegen.common import Platform, DeviceConfiguration
from pyecsca.codegen.render import render_and_build
-class RenderTests(TestCase):
-
- def test_basic_build(self):
- platform = Platform.HOST
- hash_type = HashType.SHA1
- mod_rand = RandomMod.REDUCE
- mult = Multiplication.BASE
- sqr = Squaring.BASE
- red = Reduction.BASE
- inv = Inversion.GCD
- params = get_params("secg", "secp128r1", "projective")
- model = params.curve.model
- coords = params.curve.coordinate_model
- add = coords.formulas["add-1998-cmo"]
- dbl = coords.formulas["dbl-1998-cmo"]
- scl = coords.formulas["z"]
- formulas = [add, dbl, scl]
- scalarmult = LTRMultiplier(add, dbl, scl)
- config = DeviceConfiguration(model, coords, formulas, scalarmult, hash_type, mod_rand, mult,
- sqr, red, inv, platform, True, True, True)
- temp = tempfile.mkdtemp()
- render_and_build(config, temp, True)
+def test_basic_build(secp128r1, tmp_path):
+ platform = Platform.HOST
+ hash_type = HashType.SHA1
+ mod_rand = RandomMod.REDUCE
+ mult = Multiplication.BASE
+ sqr = Squaring.BASE
+ red = Reduction.BASE
+ inv = Inversion.GCD
+ model = secp128r1.curve.model
+ coords = secp128r1.curve.coordinate_model
+ add = coords.formulas["add-1998-cmo"]
+ dbl = coords.formulas["dbl-1998-cmo"]
+ scl = coords.formulas["z"]
+ formulas = [add, dbl, scl]
+ scalarmult = LTRMultiplier(add, dbl, scl)
+ config = DeviceConfiguration(
+ model,
+ coords,
+ formulas,
+ scalarmult,
+ hash_type,
+ mod_rand,
+ mult,
+ sqr,
+ red,
+ inv,
+ platform,
+ True,
+ True,
+ True,
+ )
+ dir, elf_file, hex_file, res = render_and_build(config, str(tmp_path), True)
+ assert res.returncode == 0