aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/bn
diff options
context:
space:
mode:
authorJ08nY2025-10-01 16:11:33 +0200
committerJ08nY2025-10-01 16:11:33 +0200
commit3a0ebdac2067e5695b632a12345fae0b6ba75c83 (patch)
treee74f78dbcfd759ae487778e2ac5784ad65cde523 /pyecsca/codegen/bn
parent67f8e7b36abed5cb1fca0c740632a6431b256e4b (diff)
downloadpyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.tar.gz
pyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.tar.zst
pyecsca-codegen-3a0ebdac2067e5695b632a12345fae0b6ba75c83.zip
Fix impls and most equivalence tests.
Diffstat (limited to 'pyecsca/codegen/bn')
-rw-r--r--pyecsca/codegen/bn/bn.c6
1 files changed, 3 insertions, 3 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);