aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen
diff options
context:
space:
mode:
authorJ08nY2025-10-01 14:29:05 +0200
committerJ08nY2025-10-01 14:29:05 +0200
commitf0811f0c99f4f5a0b9b3cfe8b463b4934879d505 (patch)
treeb028973b0d68aefd4deaf96097bf3bc4b3f99eb0 /pyecsca/codegen
parentb20d20c05f5fdc45e2a81bbbfa8cc8f0cd807500 (diff)
downloadpyecsca-codegen-f0811f0c99f4f5a0b9b3cfe8b463b4934879d505.tar.gz
pyecsca-codegen-f0811f0c99f4f5a0b9b3cfe8b463b4934879d505.tar.zst
pyecsca-codegen-f0811f0c99f4f5a0b9b3cfe8b463b4934879d505.zip
Fix FixedWindow with small window size.
Diffstat (limited to 'pyecsca/codegen')
-rw-r--r--pyecsca/codegen/templates/mult_fixed_w.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pyecsca/codegen/templates/mult_fixed_w.c b/pyecsca/codegen/templates/mult_fixed_w.c
index b683de0..e756af5 100644
--- a/pyecsca/codegen/templates/mult_fixed_w.c
+++ b/pyecsca/codegen/templates/mult_fixed_w.c
@@ -26,12 +26,16 @@ static void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, poin
point_t *dbl = point_new();
point_dbl(current, curve, dbl);
points[0] = point_copy(current);
- points[1] = point_copy(dbl);
+ {% if scalarmult.m > 2 %}
+ points[1] = point_copy(dbl);
+ {% endif %}
point_set(dbl, current);
- for (long i = 2; i < {{ scalarmult.m - 1 }}; i++) {
- point_add(current, point, curve, current);
- points[i] = point_copy(current);
- }
+ {% if scalarmult.m > 3 %}
+ for (long i = 2; i < {{ scalarmult.m - 1 }}; i++) {
+ point_add(current, point, curve, current);
+ points[i] = point_copy(current);
+ }
+ {% endif %}
point_free(current);
point_free(dbl);