1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-31 22:42:57 -07:00

cmov() -> ge_cmov() ; ge_select() -> ge_select_base()

This commit is contained in:
Frank Denis 2017-10-19 22:57:09 +02:00
parent a944db7a76
commit fc3a62a493

View File

@ -1648,7 +1648,7 @@ negative(signed char b)
} }
static void static void
cmov(ge_precomp *t, const ge_precomp *u, unsigned char b) ge_cmov(ge_precomp *t, const ge_precomp *u, unsigned char b)
{ {
fe_cmov(t->yplusx, u->yplusx, b); fe_cmov(t->yplusx, u->yplusx, b);
fe_cmov(t->yminusx, u->yminusx, b); fe_cmov(t->yminusx, u->yminusx, b);
@ -1661,25 +1661,25 @@ static const ge_precomp base[32][8] = {
}; };
static void static void
ge_select(ge_precomp *t, int pos, signed char b) ge_select_base(ge_precomp *t, int pos, signed char b)
{ {
ge_precomp minust; ge_precomp minust;
unsigned char bnegative = negative(b); unsigned char bnegative = negative(b);
unsigned char babs = b - (((-bnegative) & b) * ((signed char) 1 << 1)); unsigned char babs = b - (((-bnegative) & b) * ((signed char) 1 << 1));
ge_precomp_0(t); ge_precomp_0(t);
cmov(t, &base[pos][0], equal(babs, 1)); ge_cmov(t, &base[pos][0], equal(babs, 1));
cmov(t, &base[pos][1], equal(babs, 2)); ge_cmov(t, &base[pos][1], equal(babs, 2));
cmov(t, &base[pos][2], equal(babs, 3)); ge_cmov(t, &base[pos][2], equal(babs, 3));
cmov(t, &base[pos][3], equal(babs, 4)); ge_cmov(t, &base[pos][3], equal(babs, 4));
cmov(t, &base[pos][4], equal(babs, 5)); ge_cmov(t, &base[pos][4], equal(babs, 5));
cmov(t, &base[pos][5], equal(babs, 6)); ge_cmov(t, &base[pos][5], equal(babs, 6));
cmov(t, &base[pos][6], equal(babs, 7)); ge_cmov(t, &base[pos][6], equal(babs, 7));
cmov(t, &base[pos][7], equal(babs, 8)); ge_cmov(t, &base[pos][7], equal(babs, 8));
fe_copy(minust.yplusx, t->yminusx); fe_copy(minust.yplusx, t->yminusx);
fe_copy(minust.yminusx, t->yplusx); fe_copy(minust.yminusx, t->yplusx);
fe_neg(minust.xy2d, t->xy2d); fe_neg(minust.xy2d, t->xy2d);
cmov(t, &minust, bnegative); ge_cmov(t, &minust, bnegative);
} }
/* /*
@ -1901,7 +1901,7 @@ ge_scalarmult_base(ge_p3 *h, const unsigned char *a)
ge_p3_0(h); ge_p3_0(h);
for (i = 1; i < 64; i += 2) { for (i = 1; i < 64; i += 2) {
ge_select(&t, i / 2, e[i]); ge_select_base(&t, i / 2, e[i]);
ge_madd(&r, h, &t); ge_madd(&r, h, &t);
ge_p1p1_to_p3(h, &r); ge_p1p1_to_p3(h, &r);
} }
@ -1916,7 +1916,7 @@ ge_scalarmult_base(ge_p3 *h, const unsigned char *a)
ge_p1p1_to_p3(h, &r); ge_p1p1_to_p3(h, &r);
for (i = 0; i < 64; i += 2) { for (i = 0; i < 64; i += 2) {
ge_select(&t, i / 2, e[i]); ge_select_base(&t, i / 2, e[i]);
ge_madd(&r, h, &t); ge_madd(&r, h, &t);
ge_p1p1_to_p3(h, &r); ge_p1p1_to_p3(h, &r);
} }