@@ -12500,9 +12500,9 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
1250012500 c = -c;
1250112501 y = (byte)(n << c);
1250212502 n = e[i--];
12503- y |= (byte)(n >> (64 - c));
12503+ y |= (byte)(n >> (32 - c));
1250412504 n <<= c;
12505- c = 64 - c;
12505+ c = 32 - c;
1250612506 }
1250712507 else if (c == 0) {
1250812508 /* All bits in top word used. */
@@ -12653,9 +12653,9 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
1265312653 c = -c;
1265412654 y = (byte)(n << c);
1265512655 n = e[i--];
12656- y |= (byte)(n >> (64 - c));
12656+ y |= (byte)(n >> (32 - c));
1265712657 n <<= c;
12658- c = 64 - c;
12658+ c = 32 - c;
1265912659 }
1266012660 else if (c == 0) {
1266112661 /* All bits in top word used. */
@@ -17366,9 +17366,9 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
1736617366 c = -c;
1736717367 y = (byte)(n << c);
1736817368 n = e[i--];
17369- y |= (byte)(n >> (64 - c));
17369+ y |= (byte)(n >> (32 - c));
1737017370 n <<= c;
17371- c = 64 - c;
17371+ c = 32 - c;
1737217372 }
1737317373 else if (c == 0) {
1737417374 /* All bits in top word used. */
@@ -17502,9 +17502,9 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
1750217502 c = -c;
1750317503 y = (byte)(n << c);
1750417504 n = e[i--];
17505- y |= (byte)(n >> (64 - c));
17505+ y |= (byte)(n >> (32 - c));
1750617506 n <<= c;
17507- c = 64 - c;
17507+ c = 32 - c;
1750817508 }
1750917509 else if (c == 0) {
1751017510 /* All bits in top word used. */
@@ -18648,9 +18648,9 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits,
1864818648 c = -c;
1864918649 y = (byte)(n << c);
1865018650 n = e[i--];
18651- y |= (byte)(n >> (64 - c));
18651+ y |= (byte)(n >> (32 - c));
1865218652 n <<= c;
18653- c = 64 - c;
18653+ c = 32 - c;
1865418654 }
1865518655 else if (c == 0) {
1865618656 /* All bits in top word used. */
@@ -38355,9 +38355,9 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
3835538355 c = -c;
3835638356 y = (byte)(n << c);
3835738357 n = e[i--];
38358- y |= (byte)(n >> (64 - c));
38358+ y |= (byte)(n >> (32 - c));
3835938359 n <<= c;
38360- c = 64 - c;
38360+ c = 32 - c;
3836138361 }
3836238362 else if (c == 0) {
3836338363 /* All bits in top word used. */
@@ -38508,9 +38508,9 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
3850838508 c = -c;
3850938509 y = (byte)(n << c);
3851038510 n = e[i--];
38511- y |= (byte)(n >> (64 - c));
38511+ y |= (byte)(n >> (32 - c));
3851238512 n <<= c;
38513- c = 64 - c;
38513+ c = 32 - c;
3851438514 }
3851538515 else if (c == 0) {
3851638516 /* All bits in top word used. */
@@ -45090,9 +45090,9 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
4509045090 c = -c;
4509145091 y = (byte)(n << c);
4509245092 n = e[i--];
45093- y |= (byte)(n >> (64 - c));
45093+ y |= (byte)(n >> (32 - c));
4509445094 n <<= c;
45095- c = 64 - c;
45095+ c = 32 - c;
4509645096 }
4509745097 else if (c == 0) {
4509845098 /* All bits in top word used. */
@@ -45226,9 +45226,9 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
4522645226 c = -c;
4522745227 y = (byte)(n << c);
4522845228 n = e[i--];
45229- y |= (byte)(n >> (64 - c));
45229+ y |= (byte)(n >> (32 - c));
4523045230 n <<= c;
45231- c = 64 - c;
45231+ c = 32 - c;
4523245232 }
4523345233 else if (c == 0) {
4523445234 /* All bits in top word used. */
@@ -46620,9 +46620,9 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits,
4662046620 c = -c;
4662146621 y = (byte)(n << c);
4662246622 n = e[i--];
46623- y |= (byte)(n >> (64 - c));
46623+ y |= (byte)(n >> (32 - c));
4662446624 n <<= c;
46625- c = 64 - c;
46625+ c = 32 - c;
4662646626 }
4662746627 else if (c == 0) {
4662846628 /* All bits in top word used. */
@@ -60698,9 +60698,9 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
6069860698 c = -c;
6069960699 y = (byte)(n << c);
6070060700 n = e[i--];
60701- y |= (byte)(n >> (64 - c));
60701+ y |= (byte)(n >> (32 - c));
6070260702 n <<= c;
60703- c = 64 - c;
60703+ c = 32 - c;
6070460704 }
6070560705 else if (c == 0) {
6070660706 /* All bits in top word used. */
@@ -60834,9 +60834,9 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
6083460834 c = -c;
6083560835 y = (byte)(n << c);
6083660836 n = e[i--];
60837- y |= (byte)(n >> (64 - c));
60837+ y |= (byte)(n >> (32 - c));
6083860838 n <<= c;
60839- c = 64 - c;
60839+ c = 32 - c;
6084060840 }
6084160841 else if (c == 0) {
6084260842 /* All bits in top word used. */
@@ -62476,9 +62476,9 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits,
6247662476 c = -c;
6247762477 y = (byte)(n << c);
6247862478 n = e[i--];
62479- y |= (byte)(n >> (64 - c));
62479+ y |= (byte)(n >> (32 - c));
6248062480 n <<= c;
62481- c = 64 - c;
62481+ c = 32 - c;
6248262482 }
6248362483 else if (c == 0) {
6248462484 /* All bits in top word used. */
@@ -120421,7 +120421,17 @@ static int sp_521_ecc_mulmod_fast_17(sp_point_521* r, const sp_point_521* g, con
120421120421 }
120422120422 y = k[0] & 0x1;
120423120423 sp_521_proj_point_dbl_17(rt, rt, tmp);
120424- sp_521_proj_point_add_17(rt, rt, &t[y], tmp);
120424+ #ifndef WC_NO_CACHE_RESISTANT
120425+ if (ct) {
120426+ sp_521_get_point_16_17(p, t, y);
120427+ p->infinity = !y;
120428+ sp_521_proj_point_add_17(rt, rt, p, tmp);
120429+ }
120430+ else
120431+ #endif
120432+ {
120433+ sp_521_proj_point_add_17(rt, rt, &t[y], tmp);
120434+ }
120425120435
120426120436 if (map != 0) {
120427120437 sp_521_map_17(r, rt, tmp);
0 commit comments