mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-25 21:26:53 +00:00
Hardcode numwords in vli_cmp
This commit is contained in:
parent
129b42ea2e
commit
2cb3eea922
|
@ -320,8 +320,7 @@ uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve);
|
|||
* @param num_words IN -- number of words
|
||||
* @return the sign of left - right
|
||||
*/
|
||||
cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right,
|
||||
wordcount_t num_words);
|
||||
cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right);
|
||||
|
||||
/*
|
||||
* @brief computes sign of left - right, not in constant time.
|
||||
|
|
|
@ -226,13 +226,11 @@ static uECC_word_t uECC_vli_add(uECC_word_t *result, const uECC_word_t *left,
|
|||
return carry;
|
||||
}
|
||||
|
||||
cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right,
|
||||
wordcount_t num_words)
|
||||
cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right)
|
||||
{
|
||||
uECC_word_t tmp[NUM_ECC_WORDS];
|
||||
uECC_word_t neg = !!uECC_vli_sub(tmp, left, right);
|
||||
uECC_word_t equal = uECC_vli_isZero(tmp);
|
||||
(void) num_words;
|
||||
return (!equal - 2 * neg);
|
||||
}
|
||||
|
||||
|
@ -1039,7 +1037,7 @@ int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top,
|
|||
random[num_words - 1] &=
|
||||
mask >> ((bitcount_t)(num_words * uECC_WORD_SIZE * 8 - num_bits));
|
||||
if (!uECC_vli_isZero(random) &&
|
||||
uECC_vli_cmp(top, random, num_words) == 1) {
|
||||
uECC_vli_cmp(top, random) == 1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1109,7 +1107,7 @@ int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (uECC_vli_cmp(curve->n, _private, BITS_TO_WORDS(curve->num_n_bits)) != 1) {
|
||||
if (uECC_vli_cmp(curve->n, _private) != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
|
|||
|
||||
/* Make sure 0 < k < curve_n */
|
||||
if (uECC_vli_isZero(k) ||
|
||||
uECC_vli_cmp(curve->n, k, num_n_words) != 1) {
|
||||
uECC_vli_cmp(curve->n, k) != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue