Remove function pointers from curve structure
They're not needed in practice, and removing them decreases the code size
slightly and provides less opportunities for an attacker.
diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c
index b480832..7659e54 100644
--- a/tinycrypt/ecc.c
+++ b/tinycrypt/ecc.c
@@ -622,7 +622,13 @@
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 @@
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 @@
}
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 6c171c3..a3b91b8 100644
--- a/tinycrypt/ecc_dsa.c
+++ b/tinycrypt/ecc_dsa.c
@@ -280,7 +280,7 @@
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];