mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-05-09 03:04:24 +02:00
Remove num_words member from curve structure
Saves code size, and makes the curve structure simpler.
This commit is contained in:
@@ -581,7 +581,7 @@ void double_jacobian_default(uECC_word_t * X1, uECC_word_t * Y1,
|
||||
/* t1 = X, t2 = Y, t3 = Z */
|
||||
uECC_word_t t4[NUM_ECC_WORDS];
|
||||
uECC_word_t t5[NUM_ECC_WORDS];
|
||||
wordcount_t num_words = curve->num_words;
|
||||
wordcount_t num_words = NUM_ECC_WORDS;
|
||||
|
||||
if (uECC_vli_isZero(Z1)) {
|
||||
return;
|
||||
@@ -1042,7 +1042,7 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
|
||||
{
|
||||
uECC_word_t tmp1[NUM_ECC_WORDS];
|
||||
uECC_word_t tmp2[NUM_ECC_WORDS];
|
||||
wordcount_t num_words = curve->num_words;
|
||||
wordcount_t num_words = NUM_ECC_WORDS;
|
||||
|
||||
/* The point at infinity is invalid. */
|
||||
if (EccPoint_isZero(point, curve)) {
|
||||
@@ -1072,7 +1072,7 @@ int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve)
|
||||
|
||||
uECC_vli_bytesToNative(_public, public_key, curve->num_bytes);
|
||||
uECC_vli_bytesToNative(
|
||||
_public + curve->num_words,
|
||||
_public + NUM_ECC_WORDS,
|
||||
public_key + curve->num_bytes,
|
||||
curve->num_bytes);
|
||||
|
||||
@@ -1112,7 +1112,7 @@ int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key,
|
||||
uECC_vli_nativeToBytes(public_key, curve->num_bytes, _public);
|
||||
uECC_vli_nativeToBytes(
|
||||
public_key +
|
||||
curve->num_bytes, curve->num_bytes, _public + curve->num_words);
|
||||
curve->num_bytes, curve->num_bytes, _public + NUM_ECC_WORDS);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -96,7 +96,7 @@ int uECC_make_key_with_d(uint8_t *public_key, uint8_t *private_key,
|
||||
_public);
|
||||
uECC_vli_nativeToBytes(public_key + curve->num_bytes,
|
||||
curve->num_bytes,
|
||||
_public + curve->num_words);
|
||||
_public + NUM_ECC_WORDS);
|
||||
|
||||
/* erasing temporary buffer used to store secret: */
|
||||
mbedtls_platform_memset(_private, 0, NUM_ECC_BYTES);
|
||||
@@ -137,7 +137,7 @@ int uECC_make_key(uint8_t *public_key, uint8_t *private_key, uECC_Curve curve)
|
||||
_public);
|
||||
uECC_vli_nativeToBytes(public_key + curve->num_bytes,
|
||||
curve->num_bytes,
|
||||
_public + curve->num_words);
|
||||
_public + NUM_ECC_WORDS);
|
||||
|
||||
/* erasing temporary buffer that stored secret: */
|
||||
mbedtls_platform_memset(_private, 0, NUM_ECC_BYTES);
|
||||
@@ -154,7 +154,7 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
|
||||
|
||||
uECC_word_t _public[NUM_ECC_WORDS * 2];
|
||||
uECC_word_t _private[NUM_ECC_WORDS];
|
||||
wordcount_t num_words = curve->num_words;
|
||||
wordcount_t num_words = NUM_ECC_WORDS;
|
||||
wordcount_t num_bytes = curve->num_bytes;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash,
|
||||
|
||||
uECC_word_t _public[NUM_ECC_WORDS * 2];
|
||||
uECC_word_t r[NUM_ECC_WORDS], s[NUM_ECC_WORDS];
|
||||
wordcount_t num_words = curve->num_words;
|
||||
wordcount_t num_words = NUM_ECC_WORDS;
|
||||
wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits);
|
||||
|
||||
if (curve != uECC_secp256r1())
|
||||
|
||||
Reference in New Issue
Block a user