diff options
| author | J08nY | 2025-10-01 16:11:33 +0200 |
|---|---|---|
| committer | J08nY | 2025-10-01 16:11:33 +0200 |
| commit | 3a0ebdac2067e5695b632a12345fae0b6ba75c83 (patch) | |
| tree | e74f78dbcfd759ae487778e2ac5784ad65cde523 /pyecsca/codegen | |
| parent | 67f8e7b36abed5cb1fca0c740632a6431b256e4b (diff) | |
| download | pyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.tar.gz pyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.tar.zst pyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.zip | |
Fix impls and most equivalence tests.
Diffstat (limited to 'pyecsca/codegen')
| -rw-r--r-- | pyecsca/codegen/bn/bn.c | 6 | ||||
| -rw-r--r-- | pyecsca/codegen/templates/mult_simple_ldr.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/pyecsca/codegen/bn/bn.c b/pyecsca/codegen/bn/bn.c index f41a1d7..7f91cfd 100644 --- a/pyecsca/codegen/bn/bn.c +++ b/pyecsca/codegen/bn/bn.c @@ -542,8 +542,8 @@ wsliding_t *bn_wsliding_rtl(const bn_t *bn, int w) { wsliding_t *result = NULL; int blen = bn_bit_length(bn); - uint8_t arr[blen + 2]; - memset(arr, 0, (blen + 2) * sizeof(uint8_t)); + uint8_t arr[blen + w]; + memset(arr, 0, (blen + w) * sizeof(uint8_t)); bn_t k; if (mp_init(&k) != BN_OKAY) { @@ -557,7 +557,7 @@ wsliding_t *bn_wsliding_rtl(const bn_t *bn, int w) { } int i = 0; - while (!bn_is_0(&k) && !(bn_get_sign(&k) == BN_NEG)) { + while (mp_cmp_d(&k, 0) == MP_GT) { if (!bn_get_bit(&k, 0)) { arr[i++] = 0; bn_rsh(&k, 1, &k); diff --git a/pyecsca/codegen/templates/mult_simple_ldr.c b/pyecsca/codegen/templates/mult_simple_ldr.c index ceb257a..33bfcd9 100644 --- a/pyecsca/codegen/templates/mult_simple_ldr.c +++ b/pyecsca/codegen/templates/mult_simple_ldr.c @@ -11,7 +11,7 @@ void scalar_mult_inner(bn_t *scalar, point_t *point, curve_t *curve, point_t *ou {%- endif %} for (int i = nbits; i >= 0; i--) { - if (bn_get_bit(scalar, i) == 1) { + if (bn_get_bit(scalar, i) == 0) { point_add(p0, p1, curve, p1); point_dbl(p0, curve, p0); } else { |
