mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 18:55:45 +00:00
Hardcode numwords in vli_mmod
This commit is contained in:
parent
1b0875d863
commit
10349e4912
|
@ -386,7 +386,7 @@ uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit);
|
||||||
* @warning Currently only designed to work for curve_p or curve_n.
|
* @warning Currently only designed to work for curve_p or curve_n.
|
||||||
*/
|
*/
|
||||||
void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
|
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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Computes modular product (using curve->mmod_fast)
|
* @brief Computes modular product (using curve->mmod_fast)
|
||||||
|
|
|
@ -444,12 +444,13 @@ void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left,
|
||||||
/* Computes result = product % mod, where product is 2N words long. */
|
/* Computes result = product % mod, where product is 2N words long. */
|
||||||
/* Currently only designed to work for curve_p or curve_n. */
|
/* Currently only designed to work for curve_p or curve_n. */
|
||||||
void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
|
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 mod_multiple[2 * NUM_ECC_WORDS];
|
||||||
uECC_word_t tmp[2 * NUM_ECC_WORDS];
|
uECC_word_t tmp[2 * NUM_ECC_WORDS];
|
||||||
uECC_word_t *v[2] = {tmp, product};
|
uECC_word_t *v[2] = {tmp, product};
|
||||||
uECC_word_t index;
|
uECC_word_t index;
|
||||||
|
const wordcount_t num_words = NUM_ECC_WORDS;
|
||||||
|
|
||||||
/* Shift mod so its highest set bit is at the maximum position. */
|
/* Shift mod so its highest set bit is at the maximum position. */
|
||||||
bitcount_t shift = (num_words * 2 * uECC_WORD_BITS) -
|
bitcount_t shift = (num_words * 2 * uECC_WORD_BITS) -
|
||||||
|
@ -493,7 +494,8 @@ void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left,
|
||||||
{
|
{
|
||||||
uECC_word_t product[2 * NUM_ECC_WORDS];
|
uECC_word_t product[2 * NUM_ECC_WORDS];
|
||||||
uECC_vli_mult_rnd(product, left, right, NULL);
|
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,
|
static void uECC_vli_modMult_rnd(uECC_word_t *result, const uECC_word_t *left,
|
||||||
|
|
|
@ -123,7 +123,7 @@ int uECC_make_key(uint8_t *public_key, uint8_t *private_key, uECC_Curve curve)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* computing modular reduction of _random (see FIPS 186.4 B.4.1): */
|
/* 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: */
|
/* Computing public-key from private: */
|
||||||
if (EccPoint_compute_public_key(_public, _private, curve)) {
|
if (EccPoint_compute_public_key(_public, _private, curve)) {
|
||||||
|
|
|
@ -182,7 +182,7 @@ int uECC_sign(const uint8_t *private_key, const uint8_t *message_hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
// computing k as modular reduction of _random (see FIPS 186.4 B.5.1):
|
// 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,
|
if (uECC_sign_with_k(private_key, message_hash, hash_size, k, signature,
|
||||||
curve)) {
|
curve)) {
|
||||||
|
|
Loading…
Reference in a new issue