From 3e35387deafd024b67513db3bd26b287d0e7e5a4 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 10 Oct 2023 16:45:08 +0200 Subject: Add regression test for #5. --- test/test_regress.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/test_regress.py diff --git a/test/test_regress.py b/test/test_regress.py new file mode 100644 index 0000000..d85d6f6 --- /dev/null +++ b/test/test_regress.py @@ -0,0 +1,49 @@ +import pytest +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 + + +@pytest.mark.xfail(reason="Issue not resolved yet.") +def test_regress_5(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-2015-rcb"] + dbl = coords.formulas["dbl-2015-rcb"] + 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 -- cgit v1.3.1 From 9987dc7dd762c44c56cca8b80379bfdc0b515bb3 Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 16 Oct 2023 14:16:31 +0200 Subject: Fix ladder mults. --- pyecsca/codegen/templates/mult_diff_ldr.c | 2 +- pyecsca/codegen/templates/mult_simple_ldr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyecsca/codegen/templates/mult_diff_ldr.c b/pyecsca/codegen/templates/mult_diff_ldr.c index ae74053..b6d2b97 100644 --- a/pyecsca/codegen/templates/mult_diff_ldr.c +++ b/pyecsca/codegen/templates/mult_diff_ldr.c @@ -2,7 +2,7 @@ #include "point.h" void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, point_t *out) { - point_t *p0 = point_copy(&curve->neutral); + point_t *p0 = point_copy(curve->neutral); point_t *p1 = point_copy(point); {%- if scalarmult.complete %} int nbits = bn_bit_length(&curve->n) - 1; diff --git a/pyecsca/codegen/templates/mult_simple_ldr.c b/pyecsca/codegen/templates/mult_simple_ldr.c index c393290..ceb257a 100644 --- a/pyecsca/codegen/templates/mult_simple_ldr.c +++ b/pyecsca/codegen/templates/mult_simple_ldr.c @@ -2,7 +2,7 @@ #include "point.h" void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, point_t *out) { - point_t *p0 = point_copy(&curve->neutral); + point_t *p0 = point_copy(curve->neutral); point_t *p1 = point_copy(point); {%- if scalarmult.complete %} int nbits = bn_bit_length(&curve->n) - 1; -- cgit v1.3.1