Hardcode numwords in vli_equal

This commit is contained in:
Manuel Pégourié-Gonnard 2019-11-04 14:33:09 +01:00
parent a752191191
commit 2eca3d367b
3 changed files with 5 additions and 7 deletions

View file

@ -419,8 +419,7 @@ uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left,
* @param num_words IN -- number of words
* @return Returns 0 if left == right, 1 otherwise.
*/
uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right,
wordcount_t num_words);
uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right);
/*
* @brief Computes (left * right) % mod

View file

@ -176,14 +176,13 @@ cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left,
return 0;
}
uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right,
wordcount_t num_words)
uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right)
{
uECC_word_t diff = 0;
wordcount_t i;
for (i = num_words - 1; i >= 0; --i) {
for (i = NUM_ECC_WORDS - 1; i >= 0; --i) {
diff |= (left[i] ^ right[i]);
}
return !(diff == 0);
@ -1066,7 +1065,7 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */
/* Make sure that y^2 == x^3 + ax + b */
if (uECC_vli_equal(tmp1, tmp2, num_words) != 0)
if (uECC_vli_equal(tmp1, tmp2) != 0)
return -3;
return 0;

View file

@ -298,7 +298,7 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash,
}
/* Accept only if v == r. */
return (int)(uECC_vli_equal(rx, r, num_words) == 0);
return (int)(uECC_vli_equal(rx, r) == 0);
}
#else
typedef int mbedtls_dummy_tinycrypt_def;