mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-25 21:46:45 +00:00
Hardcode numwords in vli_modMult
This commit is contained in:
parent
10349e4912
commit
3e20adf533
|
@ -428,8 +428,7 @@ uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right);
|
|||
* @param num_words IN -- number of words
|
||||
*/
|
||||
void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left,
|
||||
const uECC_word_t *right, const uECC_word_t *mod,
|
||||
wordcount_t num_words);
|
||||
const uECC_word_t *right, const uECC_word_t *mod);
|
||||
|
||||
/*
|
||||
* @brief Computes (1 / input) % mod
|
||||
|
|
|
@ -489,13 +489,11 @@ void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
|
|||
}
|
||||
|
||||
void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left,
|
||||
const uECC_word_t *right, const uECC_word_t *mod,
|
||||
wordcount_t num_words)
|
||||
const uECC_word_t *right, const uECC_word_t *mod)
|
||||
{
|
||||
uECC_word_t product[2 * NUM_ECC_WORDS];
|
||||
uECC_vli_mult_rnd(product, left, right, NULL);
|
||||
uECC_vli_mmod(result, product, mod);
|
||||
(void) num_words;
|
||||
}
|
||||
|
||||
static void uECC_vli_modMult_rnd(uECC_word_t *result, const uECC_word_t *left,
|
||||
|
|
|
@ -142,9 +142,9 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
|
|||
|
||||
/* Prevent side channel analysis of uECC_vli_modInv() to determine
|
||||
bits of k / the private key by premultiplying by a random number */
|
||||
uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); /* k' = rand * k */
|
||||
uECC_vli_modMult(k, k, tmp, curve->n); /* k' = rand * k */
|
||||
uECC_vli_modInv(k, k, curve->n, num_n_words); /* k = 1 / k' */
|
||||
uECC_vli_modMult(k, k, tmp, curve->n, num_n_words); /* k = 1 / k */
|
||||
uECC_vli_modMult(k, k, tmp, curve->n); /* k = 1 / k */
|
||||
|
||||
uECC_vli_nativeToBytes(signature, curve->num_bytes, p); /* store r */
|
||||
|
||||
|
@ -153,11 +153,11 @@ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash,
|
|||
|
||||
s[num_n_words - 1] = 0;
|
||||
uECC_vli_set(s, p);
|
||||
uECC_vli_modMult(s, tmp, s, curve->n, num_n_words); /* s = r*d */
|
||||
uECC_vli_modMult(s, tmp, s, curve->n); /* s = r*d */
|
||||
|
||||
bits2int(tmp, message_hash, hash_size, curve);
|
||||
uECC_vli_modAdd(s, tmp, s, curve->n); /* s = e + r*d */
|
||||
uECC_vli_modMult(s, s, k, curve->n, num_n_words); /* s = (e + r*d) / k */
|
||||
uECC_vli_modMult(s, s, k, curve->n); /* s = (e + r*d) / k */
|
||||
if (uECC_vli_numBits(s) > (bitcount_t)curve->num_bytes * 8) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -245,8 +245,8 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash,
|
|||
uECC_vli_modInv(z, s, curve->n, num_n_words); /* z = 1/s */
|
||||
u1[num_n_words - 1] = 0;
|
||||
bits2int(u1, message_hash, hash_size, curve);
|
||||
uECC_vli_modMult(u1, u1, z, curve->n, num_n_words); /* u1 = e/s */
|
||||
uECC_vli_modMult(u2, r, z, curve->n, num_n_words); /* u2 = r/s */
|
||||
uECC_vli_modMult(u1, u1, z, curve->n); /* u1 = e/s */
|
||||
uECC_vli_modMult(u2, r, z, curve->n); /* u2 = r/s */
|
||||
|
||||
/* Calculate sum = G + Q. */
|
||||
uECC_vli_set(sum, _public);
|
||||
|
|
Loading…
Reference in a new issue