aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJ08nY2023-10-03 23:29:18 +0200
committerJ08nY2023-10-03 23:29:18 +0200
commit07026a90ba04e164fadeb40dc2ba80e7743abf00 (patch)
treeb7011593d35684a2bf3191f44b068e5ac8574f3d /test
parent7889941ce0c198113509738c1f0e84bb7826080f (diff)
downloadpyecsca-codegen-07026a90ba04e164fadeb40dc2ba80e7743abf00.tar.gz
pyecsca-codegen-07026a90ba04e164fadeb40dc2ba80e7743abf00.tar.zst
pyecsca-codegen-07026a90ba04e164fadeb40dc2ba80e7743abf00.zip
Add fixed width scalarmult.
Diffstat (limited to 'test')
-rw-r--r--test/test_bn.c39
-rw-r--r--test/test_impl.py19
2 files changed, 56 insertions, 2 deletions
diff --git a/test/test_bn.c b/test/test_bn.c
index a77fe9a..9e3fd6f 100644
--- a/test/test_bn.c
+++ b/test/test_bn.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "bn/bn.h"
int test_wsliding_ltr() {
@@ -23,6 +24,9 @@ int test_wsliding_ltr() {
}
}
printf("OK\n");
+ bn_clear(&bn);
+ free(ws->data);
+ free(ws);
return 0;
}
@@ -48,9 +52,40 @@ int test_wsliding_rtl() {
}
}
printf("OK\n");
+ bn_clear(&bn);
+ free(ws->data);
+ free(ws);
+ return 0;
+}
+
+int test_convert_base() {
+ printf("test_convert-base: ");
+ bn_t bn;
+ bn_init(&bn);
+ bn_from_int(5, &bn);
+ base_t *bs = bn_convert_base(&bn, 2);
+ if (bs == NULL) {
+ printf("NULL\n");
+ return 1;
+ }
+ if (bs->length != 3) {
+ printf("Bad length (%li instead of 3)\n", bs->length);
+ return 1;
+ }
+ uint8_t expected[3] = {1, 0, 1};
+ for (int i = 0; i < 3; i++) {
+ if (bs->data[i] != expected[i]) {
+ printf("Bad data (%i insead of %i)\n", bs->data[i], expected[i]);
+ return 1;
+ }
+ }
+ printf("OK\n");
+ bn_clear(&bn);
+ free(bs->data);
+ free(bs);
return 0;
}
int main(void) {
- return test_wsliding_ltr() + test_wsliding_rtl();
-} \ No newline at end of file
+ return test_wsliding_ltr() + test_wsliding_rtl() + test_convert_base();
+}
diff --git a/test/test_impl.py b/test/test_impl.py
index 147792e..c125ce6 100644
--- a/test/test_impl.py
+++ b/test/test_impl.py
@@ -15,6 +15,7 @@ from pyecsca.ec.mult import (
AccumulationOrder,
ProcessingDirection,
ScalarMultiplier,
+ FixedWindowLTRMultiplier,
)
from pyecsca.ec.signature import ECDSA_SHA1, SignatureResult
@@ -148,6 +149,24 @@ def additional(request):
),
id="SLI2",
),
+ pytest.param(
+ (
+ FixedWindowLTRMultiplier,
+ "fixed",
+ ["add-1998-cmo", "dbl-1998-cmo"],
+ {"m": 4},
+ ),
+ id="FIX1",
+ ),
+ pytest.param(
+ (
+ FixedWindowLTRMultiplier,
+ "fixed",
+ ["add-1998-cmo", "dbl-1998-cmo"],
+ {"m": 5},
+ ),
+ id="FIX2",
+ ),
],
)
def target(request, additional, secp128r1) -> ImplTarget: