mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 13:41:04 +00:00
Move b from curve structure to its own constant
Same motivation as for the other parameters. This is the last one, making the curve structure empty, so it's left with a dummy parameter for legal reasons.
This commit is contained in:
parent
a6115087a0
commit
ffd13996fd
|
@ -124,7 +124,7 @@ typedef uint64_t uECC_dword_t;
|
|||
struct uECC_Curve_t;
|
||||
typedef const struct uECC_Curve_t * uECC_Curve;
|
||||
struct uECC_Curve_t {
|
||||
uECC_word_t b[NUM_ECC_WORDS];
|
||||
unsigned char dummy;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -155,15 +155,11 @@ void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product);
|
|||
extern const uECC_word_t curve_p[NUM_ECC_WORDS];
|
||||
extern const uECC_word_t curve_n[NUM_ECC_WORDS];
|
||||
extern const uECC_word_t curve_G[2 * NUM_ECC_WORDS];
|
||||
extern const uECC_word_t curve_b[NUM_ECC_WORDS];
|
||||
|
||||
/* definition of curve NIST p-256: */
|
||||
static const struct uECC_Curve_t curve_secp256r1 = {
|
||||
{
|
||||
BYTES_TO_WORDS_8(4B, 60, D2, 27, 3E, 3C, CE, 3B),
|
||||
BYTES_TO_WORDS_8(F6, B0, 53, CC, B0, 06, 1D, 65),
|
||||
BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3),
|
||||
BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A)
|
||||
},
|
||||
0
|
||||
};
|
||||
|
||||
uECC_Curve uECC_secp256r1(void);
|
||||
|
|
|
@ -91,6 +91,12 @@ const uECC_word_t curve_G[2 * NUM_ECC_WORDS] = {
|
|||
BYTES_TO_WORDS_8(16, 9E, 0F, 7C, 4A, EB, E7, 8E),
|
||||
BYTES_TO_WORDS_8(9B, 7F, 1A, FE, E2, 42, E3, 4F)
|
||||
};
|
||||
const uECC_word_t curve_b[NUM_ECC_WORDS] = {
|
||||
BYTES_TO_WORDS_8(4B, 60, D2, 27, 3E, 3C, CE, 3B),
|
||||
BYTES_TO_WORDS_8(F6, B0, 53, CC, B0, 06, 1D, 65),
|
||||
BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3),
|
||||
BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A)
|
||||
};
|
||||
|
||||
/* IMPORTANT: Make sure a cryptographically-secure PRNG is set and the platform
|
||||
* has access to enough entropy in order to feed the PRNG regularly. */
|
||||
|
@ -662,11 +668,13 @@ static void x_side_default(uECC_word_t *result,
|
|||
{
|
||||
uECC_word_t _3[NUM_ECC_WORDS] = {3}; /* -a = 3 */
|
||||
|
||||
(void) curve;
|
||||
|
||||
uECC_vli_modMult_fast(result, x, x); /* r = x^2 */
|
||||
uECC_vli_modSub(result, result, _3, curve_p); /* r = x^2 - 3 */
|
||||
uECC_vli_modMult_fast(result, result, x); /* r = x^3 - 3x */
|
||||
/* r = x^3 - 3x + b: */
|
||||
uECC_vli_modAdd(result, result, curve->b, curve_p);
|
||||
uECC_vli_modAdd(result, result, curve_b, curve_p);
|
||||
}
|
||||
|
||||
uECC_Curve uECC_secp256r1(void)
|
||||
|
|
Loading…
Reference in a new issue