diff --git a/include/tinycrypt/ecc.h b/include/tinycrypt/ecc.h index 0d1d9ec98..7d57f0f43 100644 --- a/include/tinycrypt/ecc.h +++ b/include/tinycrypt/ecc.h @@ -131,10 +131,6 @@ struct uECC_Curve_t { uECC_word_t n[NUM_ECC_WORDS]; uECC_word_t G[NUM_ECC_WORDS * 2]; uECC_word_t b[NUM_ECC_WORDS]; - void (*double_jacobian)(uECC_word_t * X1, uECC_word_t * Y1, uECC_word_t * Z1, - uECC_Curve curve); - void (*x_side)(uECC_word_t *result, const uECC_word_t *x, uECC_Curve curve); - void (*mmod_fast)(uECC_word_t *result, uECC_word_t *product); }; /* @@ -147,15 +143,6 @@ struct uECC_Curve_t { void double_jacobian_default(uECC_word_t * X1, uECC_word_t * Y1, uECC_word_t * Z1, uECC_Curve curve); -/* - * @brief Computes x^3 + ax + b. result must not overlap x. - * @param result OUT -- x^3 + ax + b - * @param x IN -- value of x - * @param curve IN -- elliptic curve - */ -void x_side_default(uECC_word_t *result, const uECC_word_t *x, - uECC_Curve curve); - /* * @brief Computes result = product % curve_p * from http://www.nsa.gov/ia/_files/nist-routines.pdf @@ -201,9 +188,6 @@ static const struct uECC_Curve_t curve_secp256r1 = { BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3), BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A) }, - &double_jacobian_default, - &x_side_default, - &vli_mmod_fast_secp256r1 }; uECC_Curve uECC_secp256r1(void); diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c index b48083222..7659e5481 100644 --- a/tinycrypt/ecc.c +++ b/tinycrypt/ecc.c @@ -622,7 +622,13 @@ void double_jacobian_default(uECC_word_t * X1, uECC_word_t * Y1, uECC_vli_set(Y1, t4); } -void x_side_default(uECC_word_t *result, +/* + * @brief Computes x^3 + ax + b. result must not overlap x. + * @param result OUT -- x^3 + ax + b + * @param x IN -- value of x + * @param curve IN -- elliptic curve + */ +static void x_side_default(uECC_word_t *result, const uECC_word_t *x, uECC_Curve curve) { @@ -775,7 +781,7 @@ static void XYcZ_initial_double(uECC_word_t * X1, uECC_word_t * Y1, uECC_vli_set(Y2, Y1); apply_z(X1, Y1, z); - curve->double_jacobian(X1, Y1, z, curve); + double_jacobian_default(X1, Y1, z, curve); apply_z(X2, Y2, z); } @@ -1050,7 +1056,7 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve) } uECC_vli_modMult_fast(tmp1, point + num_words, point + num_words); - curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */ + x_side_default(tmp2, point, curve); /* tmp2 = x^3 + ax + b */ /* Make sure that y^2 == x^3 + ax + b */ if (uECC_vli_equal(tmp1, tmp2) != 0) diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c index 6c171c3a9..a3b91b873 100644 --- a/tinycrypt/ecc_dsa.c +++ b/tinycrypt/ecc_dsa.c @@ -280,7 +280,7 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash, for (i = num_bits - 2; i >= 0; --i) { uECC_word_t index; - curve->double_jacobian(rx, ry, z, curve); + double_jacobian_default(rx, ry, z, curve); index = (!!uECC_vli_testBit(u1, i)) | ((!!uECC_vli_testBit(u2, i)) << 1); point = points[index];