diff --git a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c index adcedcd9..20ea3fc8 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c +++ b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c @@ -422,6 +422,15 @@ ge25519_p3_0(ge25519_p3 *h) fe25519_0(h->T); } +static void +ge25519_cached_0(ge25519_cached *h) +{ + fe25519_1(h->YplusX); + fe25519_1(h->YminusX); + fe25519_1(h->Z); + fe25519_0(h->T2d); +} + /* r = p */ @@ -531,6 +540,15 @@ ge25519_cmov(ge25519_precomp *t, const ge25519_precomp *u, unsigned char b) fe25519_cmov(t->xy2d, u->xy2d, b); } +static void +ge25519_cmov_cached(ge25519_cached *t, const ge25519_cached *u, unsigned char b) +{ + fe25519_cmov(t->YplusX, u->YplusX, b); + fe25519_cmov(t->YminusX, u->YminusX, b); + fe25519_cmov(t->Z, u->Z, b); + fe25519_cmov(t->T2d, u->T2d, b); +} + static void ge25519_select(ge25519_precomp *t, const ge25519_precomp precomp[8], const signed char b) { @@ -554,21 +572,16 @@ ge25519_select(ge25519_precomp *t, const ge25519_precomp precomp[8], const signe } static void -ge25519_cached_0(ge25519_cached *h) +ge25519_select_base(ge25519_precomp *t, const int pos, const signed char b) { - fe25519_1(h->YplusX); - fe25519_1(h->YminusX); - fe25519_1(h->Z); - fe25519_0(h->T2d); -} - -static void -ge25519_cmov_cached(ge25519_cached *t, const ge25519_cached *u, unsigned char b) -{ - fe25519_cmov(t->YplusX, u->YplusX, b); - fe25519_cmov(t->YminusX, u->YminusX, b); - fe25519_cmov(t->Z, u->Z, b); - fe25519_cmov(t->T2d, u->T2d, b); + static const ge25519_precomp base[32][8] = { /* base[i][j] = (j+1)*256^i*B */ +#ifdef HAVE_TI_MODE +# include "fe_51/base.h" +#else +# include "fe_25_5/base.h" +#endif + }; + ge25519_select(t, base[pos], b); } static void @@ -594,19 +607,6 @@ ge25519_select_cached(ge25519_cached *t, const ge25519_cached cached[8], const s ge25519_cmov_cached(t, &minust, bnegative); } -static void -ge25519_select_base(ge25519_precomp *t, const int pos, const signed char b) -{ - static const ge25519_precomp base[32][8] = { /* base[i][j] = (j+1)*256^i*B */ -#ifdef HAVE_TI_MODE -# include "fe_51/base.h" -#else -# include "fe_25_5/base.h" -#endif - }; - ge25519_select(t, base[pos], b); -} - /* r = p - q */