Hardcode numwords in semi-internal vli_clear()
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c
index 2846399..0039d2f 100644
--- a/tinycrypt/ecc.c
+++ b/tinycrypt/ecc.c
@@ -96,10 +96,10 @@
return 2 * curve->num_bytes;
}
-void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words)
+void uECC_vli_clear(uECC_word_t *vli)
{
wordcount_t i;
- for (i = 0; i < num_words; ++i) {
+ for (i = 0; i < NUM_ECC_WORDS; ++i) {
vli[i] = 0;
}
}
@@ -465,7 +465,7 @@
wordcount_t word_shift = shift / uECC_WORD_BITS;
wordcount_t bit_shift = shift % uECC_WORD_BITS;
uECC_word_t carry = 0;
- uECC_vli_clear(mod_multiple, word_shift);
+ uECC_vli_clear(mod_multiple);
if (bit_shift > 0) {
for(index = 0; index < (uECC_word_t)num_words; ++index) {
mod_multiple[word_shift + index] = (mod[index] << bit_shift) | carry;
@@ -545,15 +545,15 @@
cmpresult_t cmpResult;
if (uECC_vli_isZero(input)) {
- uECC_vli_clear(result, num_words);
+ uECC_vli_clear(result);
return;
}
uECC_vli_set(a, input, num_words);
uECC_vli_set(b, mod, num_words);
- uECC_vli_clear(u, num_words);
+ uECC_vli_clear(u);
u[0] = 1;
- uECC_vli_clear(v, num_words);
+ uECC_vli_clear(v);
while ((cmpResult = uECC_vli_cmp_unsafe(a, b, num_words)) != 0) {
if (EVEN(a)) {
uECC_vli_rshift1(a, num_words);
@@ -778,7 +778,7 @@
if (initial_Z) {
uECC_vli_set(z, initial_Z, num_words);
} else {
- uECC_vli_clear(z, num_words);
+ uECC_vli_clear(z);
z[0] = 1;
}
@@ -1016,7 +1016,7 @@
int num_bytes)
{
wordcount_t i;
- uECC_vli_clear(native, (num_bytes + (uECC_WORD_SIZE - 1)) / uECC_WORD_SIZE);
+ uECC_vli_clear(native);
for (i = 0; i < num_bytes; ++i) {
unsigned b = num_bytes - 1 - i;
native[b / uECC_WORD_SIZE] |=
diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c
index 8c32ee8..67b4ac7 100644
--- a/tinycrypt/ecc_dsa.c
+++ b/tinycrypt/ecc_dsa.c
@@ -87,7 +87,7 @@
bits_size = num_n_bytes;
}
- uECC_vli_clear(native, num_n_words);
+ uECC_vli_clear(native);
uECC_vli_bytesToNative(native, bits, bits_size);
if (bits_size * 8 <= (unsigned)curve->num_n_bits) {
return;
@@ -134,7 +134,7 @@
/* If an RNG function was specified, get a random number
to prevent side channel analysis of k. */
if (!g_rng_function) {
- uECC_vli_clear(tmp, num_n_words);
+ uECC_vli_clear(tmp);
tmp[0] = 1;
}
else if (!uECC_generate_random_int(tmp, curve->n, num_n_words)) {
@@ -271,7 +271,7 @@
((!!uECC_vli_testBit(u2, num_bits - 1)) << 1)];
uECC_vli_set(rx, point, num_words);
uECC_vli_set(ry, point + num_words, num_words);
- uECC_vli_clear(z, num_words);
+ uECC_vli_clear(z);
z[0] = 1;
for (i = num_bits - 2; i >= 0; --i) {