aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/bn
diff options
context:
space:
mode:
authorJ08nY2025-10-02 14:20:32 +0200
committerJ08nY2025-10-02 14:20:32 +0200
commitbb51b7890448201679878fe7df1bb79df8e336e0 (patch)
tree6abd6c911732981d137bc15f522fe0ce616d6670 /pyecsca/codegen/bn
parentdc1241a76f5658a481613817a71c62fbb9234250 (diff)
downloadpyecsca-codegen-bb51b7890448201679878fe7df1bb79df8e336e0.tar.gz
pyecsca-codegen-bb51b7890448201679878fe7df1bb79df8e336e0.tar.zst
pyecsca-codegen-bb51b7890448201679878fe7df1bb79df8e336e0.zip
Use bn clear functions.
Diffstat (limited to 'pyecsca/codegen/bn')
-rw-r--r--pyecsca/codegen/bn/bn.c36
-rw-r--r--pyecsca/codegen/bn/bn.h4
2 files changed, 40 insertions, 0 deletions
diff --git a/pyecsca/codegen/bn/bn.c b/pyecsca/codegen/bn/bn.c
index d3b7968..6dea91c 100644
--- a/pyecsca/codegen/bn/bn.c
+++ b/pyecsca/codegen/bn/bn.c
@@ -548,6 +548,14 @@ void bn_naf_reverse(wnaf_t *naf) {
}
}
+void bn_naf_clear(wnaf_t *naf) {
+ if (naf == NULL) {
+ return;
+ }
+ free(naf->data);
+ free(naf);
+}
+
wsliding_t *bn_wsliding_ltr(const bn_t *bn, int w) {
if (w > 8 || w < 2) {
return NULL;
@@ -679,6 +687,14 @@ exit_k:
return result;
}
+void bn_wsliding_clear(wsliding_t *wsliding) {
+ if (wsliding == NULL) {
+ return;
+ }
+ free(wsliding->data);
+ free(wsliding);
+}
+
small_base_t *bn_convert_base_small(const bn_t *bn, int m) {
small_base_t *result = NULL;
@@ -717,6 +733,14 @@ exit_k:
return result;
}
+void bn_small_base_clear(small_base_t *sb) {
+ if (sb == NULL) {
+ return;
+ }
+ free(sb->data);
+ free(sb);
+}
+
large_base_t *bn_convert_base_large(const bn_t *bn, const bn_t *m) {
large_base_t *result = NULL;
@@ -755,4 +779,16 @@ exit_len:
bn_clear(&k);
exit_k:
return result;
+}
+
+void bn_large_base_clear(large_base_t *lb) {
+ if (lb == NULL) {
+ return;
+ }
+ for (int i = 0; i < lb->length; i++) {
+ bn_clear(&lb->data[i]);
+ }
+ free(lb->data);
+ bn_clear(&lb->m);
+ free(lb);
} \ No newline at end of file
diff --git a/pyecsca/codegen/bn/bn.h b/pyecsca/codegen/bn/bn.h
index 78d2d94..d6a6add 100644
--- a/pyecsca/codegen/bn/bn.h
+++ b/pyecsca/codegen/bn/bn.h
@@ -143,11 +143,15 @@ void bn_naf_pad_right(wnaf_t *naf, int8_t value, size_t amount);
void bn_naf_strip_left(wnaf_t *naf, int8_t value);
void bn_naf_strip_right(wnaf_t *naf, int8_t value);
void bn_naf_reverse(wnaf_t *naf);
+void bn_naf_clear(wnaf_t *naf);
wsliding_t *bn_wsliding_ltr(const bn_t *bn, int w);
wsliding_t *bn_wsliding_rtl(const bn_t *bn, int w);
+void bn_wsliding_clear(wsliding_t *wsliding);
small_base_t *bn_convert_base_small(const bn_t *bn, int m);
+void bn_small_base_clear(small_base_t *sb);
large_base_t *bn_convert_base_large(const bn_t *bn, const bn_t *m);
+void bn_large_base_clear(large_base_t *lb);
#endif //BN_H_ \ No newline at end of file