hardcode numwords in semi-internal vli_isZero
diff --git a/include/tinycrypt/ecc.h b/include/tinycrypt/ecc.h
index 026febc..1205eb1 100644
--- a/include/tinycrypt/ecc.h
+++ b/include/tinycrypt/ecc.h
@@ -303,7 +303,7 @@
* @param num_words IN -- number of words in the vli
* @return 1 if vli == 0, 0 otherwise.
*/
-uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words);
+uECC_word_t uECC_vli_isZero(const uECC_word_t *vli);
/*
* @brief Check if 'point' is the point at infinity
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c
index b9b55bc..2846399 100644
--- a/tinycrypt/ecc.c
+++ b/tinycrypt/ecc.c
@@ -104,11 +104,11 @@
}
}
-uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words)
+uECC_word_t uECC_vli_isZero(const uECC_word_t *vli)
{
uECC_word_t bits = 0;
wordcount_t i;
- for (i = 0; i < num_words; ++i) {
+ for (i = 0; i < NUM_ECC_WORDS; ++i) {
bits |= vli[i];
}
return (bits == 0);
@@ -236,7 +236,7 @@
{
uECC_word_t tmp[NUM_ECC_WORDS];
uECC_word_t neg = !!uECC_vli_sub(tmp, left, right, num_words);
- uECC_word_t equal = uECC_vli_isZero(tmp, num_words);
+ uECC_word_t equal = uECC_vli_isZero(tmp);
return (!equal - 2 * neg);
}
@@ -544,7 +544,7 @@
uECC_word_t u[NUM_ECC_WORDS], v[NUM_ECC_WORDS];
cmpresult_t cmpResult;
- if (uECC_vli_isZero(input, num_words)) {
+ if (uECC_vli_isZero(input)) {
uECC_vli_clear(result, num_words);
return;
}
@@ -592,7 +592,7 @@
uECC_word_t t5[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
- if (uECC_vli_isZero(Z1, num_words)) {
+ if (uECC_vli_isZero(Z1)) {
return;
}
@@ -753,7 +753,8 @@
uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve)
{
- return uECC_vli_isZero(point, curve->num_words * 2);
+ (void) curve;
+ return uECC_vli_isZero(point);
}
void apply_z(uECC_word_t * X1, uECC_word_t * Y1, const uECC_word_t * const Z)
@@ -1040,7 +1041,7 @@
}
random[num_words - 1] &=
mask >> ((bitcount_t)(num_words * uECC_WORD_SIZE * 8 - num_bits));
- if (!uECC_vli_isZero(random, num_words) &&
+ if (!uECC_vli_isZero(random) &&
uECC_vli_cmp(top, random, num_words) == 1) {
return 1;
}
@@ -1107,7 +1108,7 @@
BITS_TO_BYTES(curve->num_n_bits));
/* Make sure the private key is in the range [1, n-1]. */
- if (uECC_vli_isZero(_private, BITS_TO_WORDS(curve->num_n_bits))) {
+ if (uECC_vli_isZero(_private)) {
return 0;
}
diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c
index 2df89a5..8c32ee8 100644
--- a/tinycrypt/ecc_dsa.c
+++ b/tinycrypt/ecc_dsa.c
@@ -121,13 +121,13 @@
/* Make sure 0 < k < curve_n */
- if (uECC_vli_isZero(k, num_words) ||
+ if (uECC_vli_isZero(k) ||
uECC_vli_cmp(curve->n, k, num_n_words) != 1) {
return 0;
}
r = EccPoint_mult_safer(p, curve->G, k, curve);
- if (r == 0 || uECC_vli_isZero(p, num_words)) {
+ if (r == 0 || uECC_vli_isZero(p)) {
return 0;
}
@@ -232,7 +232,7 @@
uECC_vli_bytesToNative(s, signature + curve->num_bytes, curve->num_bytes);
/* r, s must not be 0. */
- if (uECC_vli_isZero(r, num_words) || uECC_vli_isZero(s, num_words)) {
+ if (uECC_vli_isZero(r) || uECC_vli_isZero(s)) {
return 0;
}