replaces TABs with spaces

This commit is contained in:
Karel Miko 2018-12-02 13:16:44 +01:00
parent c9f1a0023f
commit f4ed78dce7
2 changed files with 100 additions and 100 deletions

View File

@ -1,20 +1,20 @@
const float s_logv_2[] = { const float s_logv_2[] = {
0.000000000, 0.000000000, 1.000000000, 0.630929754, /* 0 1 2 3 */ 0.000000000, 0.000000000, 1.000000000, 0.630929754, /* 0 1 2 3 */
0.500000000, 0.430676558, 0.386852807, 0.356207187, /* 4 5 6 7 */ 0.500000000, 0.430676558, 0.386852807, 0.356207187, /* 4 5 6 7 */
0.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8 9 10 11 */ 0.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8 9 10 11 */
0.278942946, 0.270238154, 0.262649535, 0.255958025, /* 12 13 14 15 */ 0.278942946, 0.270238154, 0.262649535, 0.255958025, /* 12 13 14 15 */
0.250000000, 0.244650542, 0.239812467, 0.235408913, /* 16 17 18 19 */ 0.250000000, 0.244650542, 0.239812467, 0.235408913, /* 16 17 18 19 */
0.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */ 0.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */
0.218104292, 0.215338279, 0.212746054, 0.210309918, /* 24 25 26 27 */ 0.218104292, 0.215338279, 0.212746054, 0.210309918, /* 24 25 26 27 */
0.208014598, 0.205846832, 0.203795047, 0.201849087, /* 28 29 30 31 */ 0.208014598, 0.205846832, 0.203795047, 0.201849087, /* 28 29 30 31 */
0.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */ 0.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */
0.193426404, 0.191958720, 0.190551412, 0.189200360, /* 36 37 38 39 */ 0.193426404, 0.191958720, 0.190551412, 0.189200360, /* 36 37 38 39 */
0.187901825, 0.186652411, 0.185449023, 0.184288833, /* 40 41 42 43 */ 0.187901825, 0.186652411, 0.185449023, 0.184288833, /* 40 41 42 43 */
0.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */ 0.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */
0.179052232, 0.178103594, 0.177183820, 0.176291434, /* 48 49 50 51 */ 0.179052232, 0.178103594, 0.177183820, 0.176291434, /* 48 49 50 51 */
0.175425064, 0.174583430, 0.173765343, 0.172969690, /* 52 53 54 55 */ 0.175425064, 0.174583430, 0.173765343, 0.172969690, /* 52 53 54 55 */
0.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */ 0.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */
0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */ 0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */
0.166666667 0.166666667
}; };

View File

@ -176,7 +176,7 @@ mp_err s_mp_add_d(mp_int *mp, mp_digit d); /* unsigned digit addition */
mp_err s_mp_sub_d(mp_int *mp, mp_digit d); /* unsigned digit subtract */ mp_err s_mp_sub_d(mp_int *mp, mp_digit d); /* unsigned digit subtract */
mp_err s_mp_mul_d(mp_int *mp, mp_digit d); /* unsigned digit multiply */ mp_err s_mp_mul_d(mp_int *mp, mp_digit d); /* unsigned digit multiply */
mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r); mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r);
/* unsigned digit divide */ /* unsigned digit divide */
mp_err s_mp_reduce(mp_int *x, mp_int *m, mp_int *mu); mp_err s_mp_reduce(mp_int *x, mp_int *m, mp_int *mu);
/* Barrett reduction */ /* Barrett reduction */
mp_err s_mp_add(mp_int *a, mp_int *b); /* magnitude addition */ mp_err s_mp_add(mp_int *a, mp_int *b); /* magnitude addition */
@ -358,15 +358,15 @@ mp_err mp_copy(mp_int *from, mp_int *to)
} else { } else {
if((tmp = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL) if((tmp = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL)
return MP_MEM; return MP_MEM;
s_mp_copy(DIGITS(from), tmp, USED(from)); s_mp_copy(DIGITS(from), tmp, USED(from));
if(DIGITS(to) != NULL) { if(DIGITS(to) != NULL) {
#if MP_CRYPTO #if MP_CRYPTO
s_mp_setz(DIGITS(to), ALLOC(to)); s_mp_setz(DIGITS(to), ALLOC(to));
#endif #endif
s_mp_free(DIGITS(to)); s_mp_free(DIGITS(to));
} }
DIGITS(to) = tmp; DIGITS(to) = tmp;
@ -507,7 +507,7 @@ mp_err mp_set_int(mp_int *mp, long z)
return res; return res;
res = s_mp_add_d(mp, res = s_mp_add_d(mp,
(mp_digit)((v >> (ix * CHAR_BIT)) & UCHAR_MAX)); (mp_digit)((v >> (ix * CHAR_BIT)) & UCHAR_MAX));
if(res != MP_OKAY) if(res != MP_OKAY)
return res; return res;
@ -772,7 +772,7 @@ mp_err mp_expt_d(mp_int *a, mp_digit d, mp_int *c)
while(d != 0) { while(d != 0) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY) if((res = s_mp_mul(&s, &x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d >>= 1; d >>= 1;
@ -875,13 +875,13 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
*/ */
if(c == b) { if(c == b) {
if((res = s_mp_add(c, a)) != MP_OKAY) if((res = s_mp_add(c, a)) != MP_OKAY)
return res; return res;
} else { } else {
if(c != a && (res = mp_copy(a, c)) != MP_OKAY) if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
return res; return res;
if((res = s_mp_add(c, b)) != MP_OKAY) if((res = s_mp_add(c, b)) != MP_OKAY)
return res; return res;
} }
} else if((cmp = s_mp_cmp(a, b)) > 0) { /* different sign: a > b */ } else if((cmp = s_mp_cmp(a, b)) > 0) { /* different sign: a > b */
@ -894,10 +894,10 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp; mp_int tmp;
if((res = mp_init_copy(&tmp, a)) != MP_OKAY) if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(&tmp, b)) != MP_OKAY) { if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
mp_clear(&tmp); mp_clear(&tmp);
return res; return res;
} }
s_mp_exch(&tmp, c); s_mp_exch(&tmp, c);
@ -906,9 +906,9 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
} else { } else {
if(c != a && (res = mp_copy(a, c)) != MP_OKAY) if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(c, b)) != MP_OKAY) if((res = s_mp_sub(c, b)) != MP_OKAY)
return res; return res;
} }
@ -924,10 +924,10 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp; mp_int tmp;
if((res = mp_init_copy(&tmp, b)) != MP_OKAY) if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(&tmp, a)) != MP_OKAY) { if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
mp_clear(&tmp); mp_clear(&tmp);
return res; return res;
} }
s_mp_exch(&tmp, c); s_mp_exch(&tmp, c);
@ -936,9 +936,9 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
} else { } else {
if(c != b && (res = mp_copy(b, c)) != MP_OKAY) if(c != b && (res = mp_copy(b, c)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(c, a)) != MP_OKAY) if((res = s_mp_sub(c, a)) != MP_OKAY)
return res; return res;
} }
} }
@ -970,12 +970,12 @@ mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c)
if(SIGN(a) != SIGN(b)) { if(SIGN(a) != SIGN(b)) {
if(c == a) { if(c == a) {
if((res = s_mp_add(c, b)) != MP_OKAY) if((res = s_mp_add(c, b)) != MP_OKAY)
return res; return res;
} else { } else {
if(c != b && ((res = mp_copy(b, c)) != MP_OKAY)) if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
return res; return res;
if((res = s_mp_add(c, a)) != MP_OKAY) if((res = s_mp_add(c, a)) != MP_OKAY)
return res; return res;
SIGN(c) = SIGN(a); SIGN(c) = SIGN(a);
} }
@ -984,20 +984,20 @@ mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp; mp_int tmp;
if((res = mp_init_copy(&tmp, a)) != MP_OKAY) if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(&tmp, b)) != MP_OKAY) { if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
mp_clear(&tmp); mp_clear(&tmp);
return res; return res;
} }
s_mp_exch(&tmp, c); s_mp_exch(&tmp, c);
mp_clear(&tmp); mp_clear(&tmp);
} else { } else {
if(c != a && ((res = mp_copy(a, c)) != MP_OKAY)) if(c != a && ((res = mp_copy(a, c)) != MP_OKAY))
return res; return res;
if((res = s_mp_sub(c, b)) != MP_OKAY) if((res = s_mp_sub(c, b)) != MP_OKAY)
return res; return res;
} }
} else if(cmp == 0) { /* Same sign, equal magnitude */ } else if(cmp == 0) { /* Same sign, equal magnitude */
@ -1009,21 +1009,21 @@ mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp; mp_int tmp;
if((res = mp_init_copy(&tmp, b)) != MP_OKAY) if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
return res; return res;
if((res = s_mp_sub(&tmp, a)) != MP_OKAY) { if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
mp_clear(&tmp); mp_clear(&tmp);
return res; return res;
} }
s_mp_exch(&tmp, c); s_mp_exch(&tmp, c);
mp_clear(&tmp); mp_clear(&tmp);
} else { } else {
if(c != b && ((res = mp_copy(b, c)) != MP_OKAY)) if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
return res; return res;
if((res = s_mp_sub(c, a)) != MP_OKAY) if((res = s_mp_sub(c, a)) != MP_OKAY)
return res; return res;
} }
SIGN(c) = !SIGN(b); SIGN(c) = !SIGN(b);
@ -1157,7 +1157,7 @@ mp_err mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r)
if((cmp = s_mp_cmp(a, b)) < 0) { if((cmp = s_mp_cmp(a, b)) < 0) {
if(r) { if(r) {
if((res = mp_copy(a, r)) != MP_OKAY) if((res = mp_copy(a, r)) != MP_OKAY)
return res; return res;
} }
if(q) if(q)
@ -1173,7 +1173,7 @@ mp_err mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r)
mp_set(q, 1); mp_set(q, 1);
if(qneg) if(qneg)
SIGN(q) = MP_NEG; SIGN(q) = MP_NEG;
} }
if(r) if(r)
@ -1286,14 +1286,14 @@ mp_err mp_expt(mp_int *a, mp_int *b, mp_int *c)
/* Loop over bits of each non-maximal digit */ /* Loop over bits of each non-maximal digit */
for(bit = 0; bit < DIGIT_BIT; bit++) { for(bit = 0; bit < DIGIT_BIT; bit++) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY) if((res = s_mp_mul(&s, &x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d >>= 1; d >>= 1;
if((res = s_mp_sqr(&x)) != MP_OKAY) if((res = s_mp_sqr(&x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
} }
@ -1303,7 +1303,7 @@ mp_err mp_expt(mp_int *a, mp_int *b, mp_int *c)
while(d) { while(d) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY) if((res = s_mp_mul(&s, &x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d >>= 1; d >>= 1;
@ -1379,7 +1379,7 @@ mp_err mp_mod(mp_int *a, mp_int *m, mp_int *c)
if(SIGN(c) == MP_NEG) { if(SIGN(c) == MP_NEG) {
if((res = mp_add(c, m, c)) != MP_OKAY) if((res = mp_add(c, m, c)) != MP_OKAY)
return res; return res;
} }
} else if(mag < 0) { } else if(mag < 0) {
@ -1388,7 +1388,7 @@ mp_err mp_mod(mp_int *a, mp_int *m, mp_int *c)
if(mp_cmp_z(a) < 0) { if(mp_cmp_z(a) < 0) {
if((res = mp_add(c, m, c)) != MP_OKAY) if((res = mp_add(c, m, c)) != MP_OKAY)
return res; return res;
} }
@ -1667,18 +1667,18 @@ mp_err mp_exptmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
/* Loop over the bits of the lower-order digits */ /* Loop over the bits of the lower-order digits */
for(bit = 0; bit < DIGIT_BIT; bit++) { for(bit = 0; bit < DIGIT_BIT; bit++) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY) if((res = s_mp_mul(&s, &x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY) if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d >>= 1; d >>= 1;
if((res = s_mp_sqr(&x)) != MP_OKAY) if((res = s_mp_sqr(&x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
if((res = s_mp_reduce(&x, m, &mu)) != MP_OKAY) if((res = s_mp_reduce(&x, m, &mu)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
} }
@ -1688,9 +1688,9 @@ mp_err mp_exptmod(mp_int *a, mp_int *b, mp_int *m, mp_int *c)
while(d) { while(d) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY) if((res = s_mp_mul(&s, &x)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY) if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d >>= 1; d >>= 1;
@ -1735,8 +1735,8 @@ mp_err mp_exptmod_d(mp_int *a, mp_digit d, mp_int *m, mp_int *c)
while(d != 0) { while(d != 0) {
if(d & 1) { if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY || if((res = s_mp_mul(&s, &x)) != MP_OKAY ||
(res = mp_mod(&s, m, &s)) != MP_OKAY) (res = mp_mod(&s, m, &s)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} }
d /= 2; d /= 2;
@ -1973,17 +1973,17 @@ mp_err mp_gcd(mp_int *a, mp_int *b, mp_int *c)
if(mp_cmp_z(&t) == MP_GT) { if(mp_cmp_z(&t) == MP_GT) {
if((res = mp_copy(&t, &u)) != MP_OKAY) if((res = mp_copy(&t, &u)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
} else { } else {
if((res = mp_copy(&t, &v)) != MP_OKAY) if((res = mp_copy(&t, &v)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
/* v = -t */ /* v = -t */
if(SIGN(&t) == MP_ZPOS) if(SIGN(&t) == MP_ZPOS)
SIGN(&v) = MP_NEG; SIGN(&v) = MP_NEG;
else else
SIGN(&v) = MP_ZPOS; SIGN(&v) = MP_ZPOS;
} }
if((res = mp_sub(&u, &v, &t)) != MP_OKAY) if((res = mp_sub(&u, &v, &t)) != MP_OKAY)
@ -2111,12 +2111,12 @@ mp_err mp_xgcd(mp_int *a, mp_int *b, mp_int *g, mp_int *x, mp_int *y)
s_mp_div_2(&u); s_mp_div_2(&u);
if(mp_iseven(&A) && mp_iseven(&B)) { if(mp_iseven(&A) && mp_iseven(&B)) {
s_mp_div_2(&A); s_mp_div_2(&B); s_mp_div_2(&A); s_mp_div_2(&B);
} else { } else {
if((res = mp_add(&A, &yc, &A)) != MP_OKAY) goto CLEANUP; if((res = mp_add(&A, &yc, &A)) != MP_OKAY) goto CLEANUP;
s_mp_div_2(&A); s_mp_div_2(&A);
if((res = mp_sub(&B, &xc, &B)) != MP_OKAY) goto CLEANUP; if((res = mp_sub(&B, &xc, &B)) != MP_OKAY) goto CLEANUP;
s_mp_div_2(&B); s_mp_div_2(&B);
} }
} }
@ -2124,12 +2124,12 @@ mp_err mp_xgcd(mp_int *a, mp_int *b, mp_int *g, mp_int *x, mp_int *y)
s_mp_div_2(&v); s_mp_div_2(&v);
if(mp_iseven(&C) && mp_iseven(&D)) { if(mp_iseven(&C) && mp_iseven(&D)) {
s_mp_div_2(&C); s_mp_div_2(&D); s_mp_div_2(&C); s_mp_div_2(&D);
} else { } else {
if((res = mp_add(&C, &yc, &C)) != MP_OKAY) goto CLEANUP; if((res = mp_add(&C, &yc, &C)) != MP_OKAY) goto CLEANUP;
s_mp_div_2(&C); s_mp_div_2(&C);
if((res = mp_sub(&D, &xc, &D)) != MP_OKAY) goto CLEANUP; if((res = mp_sub(&D, &xc, &D)) != MP_OKAY) goto CLEANUP;
s_mp_div_2(&D); s_mp_div_2(&D);
} }
} }
@ -2148,13 +2148,13 @@ mp_err mp_xgcd(mp_int *a, mp_int *b, mp_int *g, mp_int *x, mp_int *y)
/* If we're done, copy results to output */ /* If we're done, copy results to output */
if(mp_cmp_z(&u) == 0) { if(mp_cmp_z(&u) == 0) {
if(x) if(x)
if((res = mp_copy(&C, x)) != MP_OKAY) goto CLEANUP; if((res = mp_copy(&C, x)) != MP_OKAY) goto CLEANUP;
if(y) if(y)
if((res = mp_copy(&D, y)) != MP_OKAY) goto CLEANUP; if((res = mp_copy(&D, y)) != MP_OKAY) goto CLEANUP;
if(g) if(g)
if((res = mp_mul(&gx, &v, g)) != MP_OKAY) goto CLEANUP; if((res = mp_mul(&gx, &v, g)) != MP_OKAY) goto CLEANUP;
break; break;
} }
@ -2463,15 +2463,15 @@ mp_err mp_read_radix(mp_int *mp, unsigned char *str, int radix)
mp_sign sig = MP_ZPOS; mp_sign sig = MP_ZPOS;
ARGCHK(mp != NULL && str != NULL && radix >= 2 && radix <= MAX_RADIX, ARGCHK(mp != NULL && str != NULL && radix >= 2 && radix <= MAX_RADIX,
MP_BADARG); MP_BADARG);
mp_zero(mp); mp_zero(mp);
/* Skip leading non-digit characters until a digit or '-' or '+' */ /* Skip leading non-digit characters until a digit or '-' or '+' */
while(str[ix] && while(str[ix] &&
(s_mp_tovalue(str[ix], radix) < 0) && (s_mp_tovalue(str[ix], radix) < 0) &&
str[ix] != '-' && str[ix] != '-' &&
str[ix] != '+') { str[ix] != '+') {
++ix; ++ix;
} }
@ -2567,8 +2567,8 @@ mp_err mp_toradix(mp_int *mp, char *str, int radix)
/* Generate output digits in reverse order */ /* Generate output digits in reverse order */
while(mp_cmp_z(&tmp) != 0) { while(mp_cmp_z(&tmp) != 0) {
if((res = s_mp_div_d(&tmp, rdx, &rem)) != MP_OKAY) { if((res = s_mp_div_d(&tmp, rdx, &rem)) != MP_OKAY) {
mp_clear(&tmp); mp_clear(&tmp);
return res; return res;
} }
/* Generate digits, use capital letters */ /* Generate digits, use capital letters */
@ -2914,7 +2914,7 @@ mp_err s_mp_mul_2(mp_int *mp)
if(kin) { if(kin) {
if(ix >= ALLOC(mp)) { if(ix >= ALLOC(mp)) {
if((res = s_mp_grow(mp, ALLOC(mp) + 1)) != MP_OKAY) if((res = s_mp_grow(mp, ALLOC(mp) + 1)) != MP_OKAY)
return res; return res;
dp = DIGITS(mp); dp = DIGITS(mp);
} }
@ -3555,12 +3555,12 @@ mp_err s_mp_sqr(mp_int *a)
w = *pa1 * *pa2; w = *pa1 * *pa2;
/* If w is more than half MP_WORD_MAX, the doubling will /* If w is more than half MP_WORD_MAX, the doubling will
overflow, and we need to record a carry out into the next overflow, and we need to record a carry out into the next
word */ word */
u = (w >> (MP_WORD_BIT - 1)) & 1; u = (w >> (MP_WORD_BIT - 1)) & 1;
/* Double what we've got, overflow will be ignored as defined /* Double what we've got, overflow will be ignored as defined
for C arithmetic (we've already noted if it is to occur) for C arithmetic (we've already noted if it is to occur)
*/ */
w *= 2; w *= 2;
@ -3568,7 +3568,7 @@ mp_err s_mp_sqr(mp_int *a)
v = *pt + k; v = *pt + k;
/* If we do not already have an overflow carry, check to see /* If we do not already have an overflow carry, check to see
if the addition will cause one, and set the carry out if so if the addition will cause one, and set the carry out if so
*/ */
u |= ((MP_WORD_MAX - v) < w); u |= ((MP_WORD_MAX - v) < w);
@ -3579,7 +3579,7 @@ mp_err s_mp_sqr(mp_int *a)
*pt = ACCUM(w); *pt = ACCUM(w);
/* Save carry information for the next iteration of the loop. /* Save carry information for the next iteration of the loop.
This is why k must be an mp_word, instead of an mp_digit */ This is why k must be an mp_word, instead of an mp_digit */
k = CARRYOUT(w) | (u << DIGIT_BIT); k = CARRYOUT(w) | (u << DIGIT_BIT);
} /* for(jx ...) */ } /* for(jx ...) */
@ -3665,10 +3665,10 @@ mp_err s_mp_div(mp_int *a, mp_int *b)
/* Find a partial substring of a which is at least b */ /* Find a partial substring of a which is at least b */
while(s_mp_cmp(&rem, b) < 0 && ix >= 0) { while(s_mp_cmp(&rem, b) < 0 && ix >= 0) {
if((res = s_mp_lshd(&rem, 1)) != MP_OKAY) if((res = s_mp_lshd(&rem, 1)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
if((res = s_mp_lshd(&quot, 1)) != MP_OKAY) if((res = s_mp_lshd(&quot, 1)) != MP_OKAY)
goto CLEANUP; goto CLEANUP;
DIGIT(&rem, 0) = DIGIT(a, ix); DIGIT(&rem, 0) = DIGIT(a, ix);
s_mp_clamp(&rem); s_mp_clamp(&rem);
@ -3790,9 +3790,9 @@ int s_mp_cmp(mp_int *a, mp_int *b)
while(ix >= 0) { while(ix >= 0) {
if(*ap > *bp) if(*ap > *bp)
return MP_GT; return MP_GT;
else if(*ap < *bp) else if(*ap < *bp)
return MP_LT; return MP_LT;
--ap; --bp; --ix; --ap; --bp; --ix;
} }
@ -3851,7 +3851,7 @@ int s_mp_ispow2(mp_int *v)
while(ix >= 0) { while(ix >= 0) {
if(*dp) if(*dp)
return -1; /* not a power of two */ return -1; /* not a power of two */
--dp; --ix; --dp; --ix;
} }