diff options
| author | J08nY | 2025-10-01 13:09:48 +0200 |
|---|---|---|
| committer | J08nY | 2025-10-01 13:09:48 +0200 |
| commit | 262bc2c9e33b00fc4073be79804e554f12d3ba13 (patch) | |
| tree | 64c941bb4dfc93bf9fa001f8f97dc1961506b0b7 | |
| parent | 1149b764e6932b8fdb23f4479bad6350c482b7ca (diff) | |
| download | pyecsca-codegen-262bc2c9e33b00fc4073be79804e554f12d3ba13.tar.gz pyecsca-codegen-262bc2c9e33b00fc4073be79804e554f12d3ba13.tar.zst pyecsca-codegen-262bc2c9e33b00fc4073be79804e554f12d3ba13.zip | |
Fix fixed-window over-computation.
| -rw-r--r-- | pyecsca/codegen/templates/mult_fixed_w.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pyecsca/codegen/templates/mult_fixed_w.c b/pyecsca/codegen/templates/mult_fixed_w.c index b0a4bb0..b683de0 100644 --- a/pyecsca/codegen/templates/mult_fixed_w.c +++ b/pyecsca/codegen/templates/mult_fixed_w.c @@ -20,7 +20,7 @@ void scalar_mult_by_m_base(point_t *point, curve_t *curve) { static void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, point_t *out) { point_t *q = point_copy(curve->neutral); - point_t *points[{{ scalarmult.m }}]; + point_t *points[{{ scalarmult.m - 1 }}]; point_t *current = point_copy(point); point_t *dbl = point_new(); @@ -28,7 +28,7 @@ static void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, poin points[0] = point_copy(current); points[1] = point_copy(dbl); point_set(dbl, current); - for (long i = 2; i < {{ scalarmult.m }}; i++) { + for (long i = 2; i < {{ scalarmult.m - 1 }}; i++) { point_add(current, point, curve, current); points[i] = point_copy(current); } @@ -56,7 +56,7 @@ static void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, poin point_scl(q, curve, q); {%- endif %} point_set(q, out); - for (long i = 0; i < {{ scalarmult.m }}; i++) { + for (long i = 0; i < {{ scalarmult.m - 1 }}; i++) { point_free(points[i]); } point_free(q); |
