Skip to content
Snippets Groups Projects
Commit f6596142 authored by Simon Tatham's avatar Simon Tatham
Browse files

ecc.[ch]: add elliptic-curve point_copy_into functions.

This will let my upcoming new test of memory access patterns run a
sequence of tests on different elliptic-curve data which is stored at
the same address each time.
parent 30117bff
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,14 @@ WeierstrassPoint *ecc_weierstrass_point_new_identity(WeierstrassCurve *wc)
return wp;
}
void ecc_weierstrass_point_copy_into(
WeierstrassPoint *dest, WeierstrassPoint *src)
{
mp_copy_into(dest->X, src->X);
mp_copy_into(dest->Y, src->Y);
mp_copy_into(dest->Z, src->Z);
}
WeierstrassPoint *ecc_weierstrass_point_copy(WeierstrassPoint *orig)
{
WeierstrassPoint *wp = ecc_weierstrass_point_new_empty(orig->wc);
......@@ -610,6 +618,13 @@ MontgomeryPoint *ecc_montgomery_point_new(MontgomeryCurve *mc, mp_int *x)
return mp;
}
void ecc_montgomery_point_copy_into(
MontgomeryPoint *dest, MontgomeryPoint *src)
{
mp_copy_into(dest->X, src->X);
mp_copy_into(dest->Z, src->Z);
}
MontgomeryPoint *ecc_montgomery_point_copy(MontgomeryPoint *orig)
{
MontgomeryPoint *mp = ecc_montgomery_point_new_empty(orig->mc);
......@@ -904,6 +919,14 @@ EdwardsPoint *ecc_edwards_point_new(
ec, monty_import(ec->mc, x), monty_import(ec->mc, y));
}
void ecc_edwards_point_copy_into(EdwardsPoint *dest, EdwardsPoint *src)
{
mp_copy_into(dest->X, src->X);
mp_copy_into(dest->Y, src->Y);
mp_copy_into(dest->Z, src->Z);
mp_copy_into(dest->T, src->T);
}
EdwardsPoint *ecc_edwards_point_copy(EdwardsPoint *orig)
{
EdwardsPoint *ep = ecc_edwards_point_new_empty(orig->ec);
......
......@@ -61,6 +61,8 @@ WeierstrassPoint *ecc_weierstrass_point_new_from_x(
WeierstrassCurve *curve, mp_int *x, unsigned desired_y_parity);
/* Memory management: copy and free points. */
void ecc_weierstrass_point_copy_into(
WeierstrassPoint *dest, WeierstrassPoint *src);
WeierstrassPoint *ecc_weierstrass_point_copy(WeierstrassPoint *wc);
void ecc_weierstrass_point_free(WeierstrassPoint *point);
......@@ -143,6 +145,8 @@ void ecc_montgomery_curve_free(MontgomeryCurve *);
* explicitly represent the identity for this application.
*/
MontgomeryPoint *ecc_montgomery_point_new(MontgomeryCurve *mc, mp_int *x);
void ecc_montgomery_point_copy_into(
MontgomeryPoint *dest, MontgomeryPoint *src);
MontgomeryPoint *ecc_montgomery_point_copy(MontgomeryPoint *orig);
void ecc_montgomery_point_free(MontgomeryPoint *mp);
......@@ -213,6 +217,7 @@ EdwardsPoint *ecc_edwards_point_new_from_y(
EdwardsCurve *curve, mp_int *y, unsigned desired_x_parity);
/* Copy and free points. */
void ecc_edwards_point_copy_into(EdwardsPoint *dest, EdwardsPoint *src);
EdwardsPoint *ecc_edwards_point_copy(EdwardsPoint *ec);
void ecc_edwards_point_free(EdwardsPoint *point);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment