replaces TABs with spaces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
diff --git a/mtest/logtab.h b/mtest/logtab.h
index 751111e..dae3344 100644
--- a/mtest/logtab.h
+++ b/mtest/logtab.h
@@ -1,20 +1,20 @@
const float s_logv_2[] = {
- 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.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8 9 10 11 */
- 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.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */
- 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.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */
- 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.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */
- 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.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */
- 0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */
+ 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.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8 9 10 11 */
+ 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.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */
+ 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.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */
+ 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.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */
+ 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.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */
+ 0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */
0.166666667
};
diff --git a/mtest/mpi.c b/mtest/mpi.c
index 48dbe27..47083a3 100644
--- a/mtest/mpi.c
+++ b/mtest/mpi.c
@@ -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_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);
- /* unsigned digit divide */
+ /* unsigned digit divide */
mp_err s_mp_reduce(mp_int *x, mp_int *m, mp_int *mu);
/* Barrett reduction */
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 {
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));
if(DIGITS(to) != NULL) {
#if MP_CRYPTO
- s_mp_setz(DIGITS(to), ALLOC(to));
+ s_mp_setz(DIGITS(to), ALLOC(to));
#endif
- s_mp_free(DIGITS(to));
+ s_mp_free(DIGITS(to));
}
DIGITS(to) = tmp;
@@ -507,7 +507,7 @@ mp_err mp_set_int(mp_int *mp, long z)
return res;
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)
return res;
@@ -772,7 +772,7 @@ mp_err mp_expt_d(mp_int *a, mp_digit d, mp_int *c)
while(d != 0) {
if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
}
d >>= 1;
@@ -875,13 +875,13 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
*/
if(c == b) {
if((res = s_mp_add(c, a)) != MP_OKAY)
- return res;
+ return res;
} else {
if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
- return res;
+ return res;
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 */
@@ -894,10 +894,10 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp;
if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
- return res;
+ return res;
if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
+ mp_clear(&tmp);
+ return res;
}
s_mp_exch(&tmp, c);
@@ -906,9 +906,9 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
} else {
if(c != a && (res = mp_copy(a, c)) != MP_OKAY)
- return res;
+ return res;
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;
if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
- return res;
+ return res;
if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
+ mp_clear(&tmp);
+ return res;
}
s_mp_exch(&tmp, c);
@@ -936,9 +936,9 @@ mp_err mp_add(mp_int *a, mp_int *b, mp_int *c)
} else {
if(c != b && (res = mp_copy(b, c)) != MP_OKAY)
- return res;
+ return res;
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(c == a) {
if((res = s_mp_add(c, b)) != MP_OKAY)
- return res;
+ return res;
} else {
if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
- return res;
+ return res;
if((res = s_mp_add(c, a)) != MP_OKAY)
- return res;
+ return res;
SIGN(c) = SIGN(a);
}
@@ -984,20 +984,20 @@ mp_err mp_sub(mp_int *a, mp_int *b, mp_int *c)
mp_int tmp;
if((res = mp_init_copy(&tmp, a)) != MP_OKAY)
- return res;
+ return res;
if((res = s_mp_sub(&tmp, b)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
+ mp_clear(&tmp);
+ return res;
}
s_mp_exch(&tmp, c);
mp_clear(&tmp);
} else {
if(c != a && ((res = mp_copy(a, c)) != MP_OKAY))
- return res;
+ return res;
if((res = s_mp_sub(c, b)) != MP_OKAY)
- return res;
+ return res;
}
} 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;
if((res = mp_init_copy(&tmp, b)) != MP_OKAY)
- return res;
+ return res;
if((res = s_mp_sub(&tmp, a)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
+ mp_clear(&tmp);
+ return res;
}
s_mp_exch(&tmp, c);
mp_clear(&tmp);
} else {
if(c != b && ((res = mp_copy(b, c)) != MP_OKAY))
- return res;
+ return res;
if((res = s_mp_sub(c, a)) != MP_OKAY)
- return res;
+ return res;
}
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(r) {
if((res = mp_copy(a, r)) != MP_OKAY)
- return res;
+ return res;
}
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);
if(qneg)
- SIGN(q) = MP_NEG;
+ SIGN(q) = MP_NEG;
}
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 */
for(bit = 0; bit < DIGIT_BIT; bit++) {
if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
+ if((res = s_mp_mul(&s, &x)) != MP_OKAY)
+ goto CLEANUP;
}
d >>= 1;
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) {
if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
}
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((res = mp_add(c, m, c)) != MP_OKAY)
- return res;
+ return res;
}
} 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((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 */
for(bit = 0; bit < DIGIT_BIT; bit++) {
if(d & 1) {
- if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
- if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
- goto CLEANUP;
+ if((res = s_mp_mul(&s, &x)) != MP_OKAY)
+ goto CLEANUP;
+ if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
+ goto CLEANUP;
}
d >>= 1;
if((res = s_mp_sqr(&x)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
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) {
if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
if((res = s_mp_reduce(&s, m, &mu)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
}
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) {
if(d & 1) {
if((res = s_mp_mul(&s, &x)) != MP_OKAY ||
- (res = mp_mod(&s, m, &s)) != MP_OKAY)
- goto CLEANUP;
+ (res = mp_mod(&s, m, &s)) != MP_OKAY)
+ goto CLEANUP;
}
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((res = mp_copy(&t, &u)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
} else {
if((res = mp_copy(&t, &v)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
/* v = -t */
if(SIGN(&t) == MP_ZPOS)
- SIGN(&v) = MP_NEG;
+ SIGN(&v) = MP_NEG;
else
- SIGN(&v) = MP_ZPOS;
+ SIGN(&v) = MP_ZPOS;
}
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);
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 {
- if((res = mp_add(&A, &yc, &A)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&A);
- if((res = mp_sub(&B, &xc, &B)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&B);
+ if((res = mp_add(&A, &yc, &A)) != MP_OKAY) goto CLEANUP;
+ s_mp_div_2(&A);
+ if((res = mp_sub(&B, &xc, &B)) != MP_OKAY) goto CLEANUP;
+ 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);
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 {
- if((res = mp_add(&C, &yc, &C)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&C);
- if((res = mp_sub(&D, &xc, &D)) != MP_OKAY) goto CLEANUP;
- s_mp_div_2(&D);
+ if((res = mp_add(&C, &yc, &C)) != MP_OKAY) goto CLEANUP;
+ s_mp_div_2(&C);
+ if((res = mp_sub(&D, &xc, &D)) != MP_OKAY) goto CLEANUP;
+ 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(mp_cmp_z(&u) == 0) {
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((res = mp_copy(&D, y)) != MP_OKAY) goto CLEANUP;
+ if((res = mp_copy(&D, y)) != MP_OKAY) goto CLEANUP;
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;
}
@@ -2463,15 +2463,15 @@ mp_err mp_read_radix(mp_int *mp, unsigned char *str, int radix)
mp_sign sig = MP_ZPOS;
ARGCHK(mp != NULL && str != NULL && radix >= 2 && radix <= MAX_RADIX,
- MP_BADARG);
+ MP_BADARG);
mp_zero(mp);
/* Skip leading non-digit characters until a digit or '-' or '+' */
while(str[ix] &&
- (s_mp_tovalue(str[ix], radix) < 0) &&
- str[ix] != '-' &&
- str[ix] != '+') {
+ (s_mp_tovalue(str[ix], radix) < 0) &&
+ str[ix] != '-' &&
+ str[ix] != '+') {
++ix;
}
@@ -2567,8 +2567,8 @@ mp_err mp_toradix(mp_int *mp, char *str, int radix)
/* Generate output digits in reverse order */
while(mp_cmp_z(&tmp) != 0) {
if((res = s_mp_div_d(&tmp, rdx, &rem)) != MP_OKAY) {
- mp_clear(&tmp);
- return res;
+ mp_clear(&tmp);
+ return res;
}
/* Generate digits, use capital letters */
@@ -2914,7 +2914,7 @@ mp_err s_mp_mul_2(mp_int *mp)
if(kin) {
if(ix >= ALLOC(mp)) {
if((res = s_mp_grow(mp, ALLOC(mp) + 1)) != MP_OKAY)
- return res;
+ return res;
dp = DIGITS(mp);
}
@@ -3555,12 +3555,12 @@ mp_err s_mp_sqr(mp_int *a)
w = *pa1 * *pa2;
/* If w is more than half MP_WORD_MAX, the doubling will
- overflow, and we need to record a carry out into the next
- word */
+ overflow, and we need to record a carry out into the next
+ word */
u = (w >> (MP_WORD_BIT - 1)) & 1;
/* 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;
@@ -3568,7 +3568,7 @@ mp_err s_mp_sqr(mp_int *a)
v = *pt + k;
/* 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);
@@ -3579,7 +3579,7 @@ mp_err s_mp_sqr(mp_int *a)
*pt = ACCUM(w);
/* 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);
} /* 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 */
while(s_mp_cmp(&rem, b) < 0 && ix >= 0) {
if((res = s_mp_lshd(&rem, 1)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
if((res = s_mp_lshd(", 1)) != MP_OKAY)
- goto CLEANUP;
+ goto CLEANUP;
DIGIT(&rem, 0) = DIGIT(a, ix);
s_mp_clamp(&rem);
@@ -3790,9 +3790,9 @@ int s_mp_cmp(mp_int *a, mp_int *b)
while(ix >= 0) {
if(*ap > *bp)
- return MP_GT;
+ return MP_GT;
else if(*ap < *bp)
- return MP_LT;
+ return MP_LT;
--ap; --bp; --ix;
}
@@ -3851,7 +3851,7 @@ int s_mp_ispow2(mp_int *v)
while(ix >= 0) {
if(*dp)
- return -1; /* not a power of two */
+ return -1; /* not a power of two */
--dp; --ix;
}