Skip to content

Commit 864430c

Browse files
committed
crypto: break out fe_frombytes_vartime function
1 parent 8d4c625 commit 864430c

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/crypto/crypto-ops.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,16 +1328,9 @@ void ge_double_scalarmult_base_vartime_p3(ge_p3 *r3, const unsigned char *a, con
13281328
}
13291329
}
13301330

1331-
/* From ge_frombytes.c, modified */
1332-
1333-
int ge_frombytes_vartime(ge_p3 *h, const unsigned char *s) {
1334-
fe u;
1335-
fe v;
1336-
fe vxx;
1337-
fe check;
1338-
1339-
/* From fe_frombytes.c */
1331+
/* From fe_frombytes.c */
13401332

1333+
int fe_frombytes_vartime(fe y, const unsigned char *s) {
13411334
int64_t h0 = load_4(s);
13421335
int64_t h1 = load_3(s + 4) << 6;
13431336
int64_t h2 = load_3(s + 7) << 5;
@@ -1378,18 +1371,31 @@ int ge_frombytes_vartime(ge_p3 *h, const unsigned char *s) {
13781371
carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
13791372
carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
13801373

1381-
h->Y[0] = h0;
1382-
h->Y[1] = h1;
1383-
h->Y[2] = h2;
1384-
h->Y[3] = h3;
1385-
h->Y[4] = h4;
1386-
h->Y[5] = h5;
1387-
h->Y[6] = h6;
1388-
h->Y[7] = h7;
1389-
h->Y[8] = h8;
1390-
h->Y[9] = h9;
1374+
y[0] = h0;
1375+
y[1] = h1;
1376+
y[2] = h2;
1377+
y[3] = h3;
1378+
y[4] = h4;
1379+
y[5] = h5;
1380+
y[6] = h6;
1381+
y[7] = h7;
1382+
y[8] = h8;
1383+
y[9] = h9;
13911384

1392-
/* End fe_frombytes.c */
1385+
return 0;
1386+
}
1387+
1388+
/* From ge_frombytes.c, modified */
1389+
1390+
int ge_frombytes_vartime(ge_p3 *h, const unsigned char *s) {
1391+
fe u;
1392+
fe v;
1393+
fe vxx;
1394+
fe check;
1395+
1396+
if (fe_frombytes_vartime(h->Y, s) != 0) {
1397+
return -1;
1398+
}
13931399

13941400
fe_1(h->Z);
13951401
fe_sq(u, h->Y);

src/crypto/crypto-ops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void ge_double_scalarmult_base_vartime_p3(ge_p3 *, const unsigned char *, const
8888

8989
extern const fe fe_sqrtm1;
9090
extern const fe fe_d;
91+
int fe_frombytes_vartime(fe, const unsigned char *);
9192
int ge_frombytes_vartime(ge_p3 *, const unsigned char *);
9293

9394
/* From ge_p1p1_to_p2.c */

0 commit comments

Comments
 (0)