Hardcode numwords in vli_mmod
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c
index e7558e9..508831c 100644
--- a/tinycrypt/ecc.c
+++ b/tinycrypt/ecc.c
@@ -444,12 +444,13 @@
/* Computes result = product % mod, where product is 2N words long. */
/* Currently only designed to work for curve_p or curve_n. */
void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
- const uECC_word_t *mod, wordcount_t num_words)
+ const uECC_word_t *mod)
{
uECC_word_t mod_multiple[2 * NUM_ECC_WORDS];
uECC_word_t tmp[2 * NUM_ECC_WORDS];
uECC_word_t *v[2] = {tmp, product};
uECC_word_t index;
+ const wordcount_t num_words = NUM_ECC_WORDS;
/* Shift mod so its highest set bit is at the maximum position. */
bitcount_t shift = (num_words * 2 * uECC_WORD_BITS) -
@@ -493,7 +494,8 @@
{
uECC_word_t product[2 * NUM_ECC_WORDS];
uECC_vli_mult_rnd(product, left, right, NULL);
- uECC_vli_mmod(result, product, mod, num_words);
+ uECC_vli_mmod(result, product, mod);
+ (void) num_words;
}
static void uECC_vli_modMult_rnd(uECC_word_t *result, const uECC_word_t *left,
diff --git a/tinycrypt/ecc_dh.c b/tinycrypt/ecc_dh.c
index 52208ad..71c51f5 100644
--- a/tinycrypt/ecc_dh.c
+++ b/tinycrypt/ecc_dh.c
@@ -123,7 +123,7 @@
}
/* computing modular reduction of _random (see FIPS 186.4 B.4.1): */
- uECC_vli_mmod(_private, _random, curve->n, BITS_TO_WORDS(curve->num_n_bits));
+ uECC_vli_mmod(_private, _random, curve->n);
/* Computing public-key from private: */
if (EccPoint_compute_public_key(_public, _private, curve)) {
diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c
index 77e3efe..ca07eb1 100644
--- a/tinycrypt/ecc_dsa.c
+++ b/tinycrypt/ecc_dsa.c
@@ -182,7 +182,7 @@
}
// computing k as modular reduction of _random (see FIPS 186.4 B.5.1):
- uECC_vli_mmod(k, _random, curve->n, BITS_TO_WORDS(curve->num_n_bits));
+ uECC_vli_mmod(k, _random, curve->n);
if (uECC_sign_with_k(private_key, message_hash, hash_size, k, signature,
curve)) {