use u32 i64 suffix
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 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
diff --git a/bn_conversion.c b/bn_conversion.c
index 80854c7..39bdf7a 100644
--- a/bn_conversion.c
+++ b/bn_conversion.c
@@ -52,28 +52,28 @@
return a->sign == MP_NEG ? (int##w##_t)-res : (int##w##_t)res; \
}
-#ifdef BN_MP_SET_UINT32_C
-MP_SET_UNSIGNED(mp_set_uint32, 32)
+#ifdef BN_MP_SET_U32_C
+MP_SET_UNSIGNED(mp_set_u32, 32)
#endif
-#ifdef BN_MP_SET_UINT64_C
-MP_SET_UNSIGNED(mp_set_uint64, 64)
+#ifdef BN_MP_SET_U64_C
+MP_SET_UNSIGNED(mp_set_u64, 64)
#endif
-#ifdef BN_MP_SET_INT32_C
-MP_SET_SIGNED(mp_set_int32, mp_set_uint32, 32)
+#ifdef BN_MP_SET_I32_C
+MP_SET_SIGNED(mp_set_i32, mp_set_u32, 32)
#endif
-#ifdef BN_MP_SET_INT64_C
-MP_SET_SIGNED(mp_set_int64, mp_set_uint64, 64)
+#ifdef BN_MP_SET_I64_C
+MP_SET_SIGNED(mp_set_i64, mp_set_u64, 64)
#endif
-#if defined(BN_MP_GET_INT32_C) || defined(BN_MP_GET_UINT32_C)
-MP_GET_SIGNED(mp_get_int32, mp_get_mag32, 32)
+#if defined(BN_MP_GET_I32_C) || defined(BN_MP_GET_U32_C)
+MP_GET_SIGNED(mp_get_i32, mp_get_mag32, 32)
#endif
-#if defined(BN_MP_GET_INT64_C) || defined(BN_MP_GET_UINT64_C)
-MP_GET_SIGNED(mp_get_int64, mp_get_mag64, 64)
+#if defined(BN_MP_GET_I64_C) || defined(BN_MP_GET_U64_C)
+MP_GET_SIGNED(mp_get_i64, mp_get_mag64, 64)
#endif
#ifdef BN_MP_GET_MAG32_C
@@ -84,12 +84,20 @@ MP_GET_MAG(mp_get_mag32, 32)
MP_GET_MAG(mp_get_mag64, 64)
#endif
-#ifdef BN_MP_INIT_UINT32_C
-MP_INIT_INT(mp_init_uint32, mp_set_uint32, uint32_t)
+#ifdef BN_MP_INIT_U32_C
+MP_INIT_INT(mp_init_u32, mp_set_u32, uint32_t)
#endif
-#ifdef BN_MP_INIT_INT32_C
-MP_INIT_INT(mp_init_int32, mp_set_int32, int32_t)
+#ifdef BN_MP_INIT_I32_C
+MP_INIT_INT(mp_init_i32, mp_set_i32, int32_t)
+#endif
+
+#ifdef BN_MP_INIT_U64_C
+MP_INIT_INT(mp_init_u64, mp_set_u64, uint64_t)
+#endif
+
+#ifdef BN_MP_INIT_I64_C
+MP_INIT_INT(mp_init_i64, mp_set_i64, int64_t)
#endif
#endif
diff --git a/bn_deprecated.c b/bn_deprecated.c
index bb3d34d..70925fe 100644
--- a/bn_deprecated.c
+++ b/bn_deprecated.c
@@ -149,27 +149,27 @@ mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
#ifdef BN_MP_INIT_SET_INT_C
mp_err mp_init_set_int(mp_int *a, unsigned long b)
{
- return mp_init_uint32(a, (uint32_t)b);
+ return mp_init_u32(a, (uint32_t)b);
}
#endif
#ifdef BN_MP_SET_INT_C
mp_err mp_set_int(mp_int *a, unsigned long b)
{
- mp_set_uint32(a, (uint32_t)b);
+ mp_set_u32(a, (uint32_t)b);
return MP_OKAY;
}
#endif
#ifdef BN_MP_SET_LONG_C
mp_err mp_set_long(mp_int *a, unsigned long b)
{
- mp_set_uint64(a, b);
+ mp_set_u64(a, b);
return MP_OKAY;
}
#endif
#ifdef BN_MP_SET_LONG_LONG_C
mp_err mp_set_long_long(mp_int *a, unsigned long long b)
{
- mp_set_uint64(a, b);
+ mp_set_u64(a, b);
return MP_OKAY;
}
#endif
diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c
index ac972b3..6669eb8 100644
--- a/bn_mp_ilogb.c
+++ b/bn_mp_ilogb.c
@@ -89,7 +89,7 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
return MP_VAL;
}
if (base == 2u) {
- mp_set_uint32(c, (uint32_t)(mp_count_bits(a) - 1));
+ mp_set_u32(c, (uint32_t)(mp_count_bits(a) - 1));
return err;
}
if (a->used == 1) {
@@ -161,15 +161,15 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
mp_exch(&bracket_mid, &bracket_low);
}
if (cmp == MP_EQ) {
- mp_set_uint32(c, mid);
+ mp_set_u32(c, mid);
goto LBL_END;
}
}
if (mp_cmp(&bracket_high, a) == MP_EQ) {
- mp_set_uint32(c, high);
+ mp_set_u32(c, high);
} else {
- mp_set_uint32(c, low);
+ mp_set_u32(c, low);
}
LBL_END:
diff --git a/bn_mp_is_square.c b/bn_mp_is_square.c
index 254130c..5c191dc 100644
--- a/bn_mp_is_square.c
+++ b/bn_mp_is_square.c
@@ -58,13 +58,13 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
}
- if ((err = mp_init_uint32(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
+ if ((err = mp_init_u32(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
return err;
}
if ((err = mp_mod(arg, &t, &t)) != MP_OKAY) {
goto LBL_ERR;
}
- r = mp_get_uint32(&t);
+ r = mp_get_u32(&t);
/* Check for other prime modules, note it's not an ERROR but we must
* free "t" so the easiest way is to goto LBL_ERR. We know that err
* is already equal to MP_OKAY from the mp_mod call
diff --git a/bn_mp_prime_frobenius_underwood.c b/bn_mp_prime_frobenius_underwood.c
index fc7c81a..e2f9f1f 100644
--- a/bn_mp_prime_frobenius_underwood.c
+++ b/bn_mp_prime_frobenius_underwood.c
@@ -43,7 +43,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
continue;
}
/* (32764^2 - 4) < 2^31, no bigint for >MP_8BIT needed) */
- mp_set_uint32(&T1z, (uint32_t)a);
+ mp_set_u32(&T1z, (uint32_t)a);
if ((err = mp_sqr(&T1z, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
@@ -72,7 +72,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
goto LBL_FU_ERR;
}
/* Composite if N and (a+4)*(2*a+5) are not coprime */
- mp_set_uint32(&T1z, (uint32_t)((a+4)*((2*a)+5)));
+ mp_set_u32(&T1z, (uint32_t)((a+4)*((2*a)+5)));
if ((err = mp_gcd(N, &T1z, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
@@ -157,7 +157,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
}
}
- mp_set_uint32(&T1z, (uint32_t)((2 * a) + 5));
+ mp_set_u32(&T1z, (uint32_t)((2 * a) + 5));
if ((err = mp_mod(&T1z, N, &T1z)) != MP_OKAY) {
goto LBL_FU_ERR;
}
diff --git a/bn_mp_prime_strong_lucas_selfridge.c b/bn_mp_prime_strong_lucas_selfridge.c
index 118b08a..e58b64a 100644
--- a/bn_mp_prime_strong_lucas_selfridge.c
+++ b/bn_mp_prime_strong_lucas_selfridge.c
@@ -32,7 +32,7 @@ static mp_err s_mp_mul_si(const mp_int *a, int32_t d, mp_int *c)
* mp_digit might be smaller than a long, which excludes
* the use of mp_mul_d() here.
*/
- mp_set_int32(&t, d);
+ mp_set_i32(&t, d);
err = mp_mul(a, &t, c);
mp_clear(&t);
return err;
@@ -83,7 +83,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
for (;;) {
Ds = sign * D;
sign = -sign;
- mp_set_uint32(&Dz, (uint32_t)D);
+ mp_set_u32(&Dz, (uint32_t)D);
if ((err = mp_gcd(a, &Dz, &gcd)) != MP_OKAY) {
goto LBL_LS_ERR;
}
@@ -179,23 +179,23 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
if (Q < 0) {
Q = -Q;
- mp_set_uint32(&Qmz, (uint32_t)Q);
+ mp_set_u32(&Qmz, (uint32_t)Q);
if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Initializes calculation of Q^d */
- mp_set_uint32(&Qkdz, (uint32_t)Q);
+ mp_set_u32(&Qkdz, (uint32_t)Q);
Qmz.sign = MP_NEG;
Q2mz.sign = MP_NEG;
Qkdz.sign = MP_NEG;
Q = -Q;
} else {
- mp_set_uint32(&Qmz, (uint32_t)Q);
+ mp_set_u32(&Qmz, (uint32_t)Q);
if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
goto LBL_LS_ERR;
}
/* Initializes calculation of Q^d */
- mp_set_uint32(&Qkdz, (uint32_t)Q);
+ mp_set_u32(&Qkdz, (uint32_t)Q);
}
Nbits = mp_count_bits(&Dz);
diff --git a/bn_mp_set_double.c b/bn_mp_set_double.c
index 9583b06..a42fc70 100644
--- a/bn_mp_set_double.c
+++ b/bn_mp_set_double.c
@@ -23,7 +23,7 @@ mp_err mp_set_double(mp_int *a, double b)
}
exp -= 1023 + 52;
- mp_set_uint64(a, frac);
+ mp_set_u64(a, frac);
err = (exp < 0) ? mp_div_2d(a, -exp, a, NULL) : mp_mul_2d(a, exp, a);
if (err != MP_OKAY) {
diff --git a/bn_mp_sqrtmod_prime.c b/bn_mp_sqrtmod_prime.c
index 765c1a4..0ce83bd 100644
--- a/bn_mp_sqrtmod_prime.c
+++ b/bn_mp_sqrtmod_prime.c
@@ -59,7 +59,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
}
/* find a Z such that the Legendre symbol (Z|prime) == -1 */
- mp_set_uint32(&Z, 2uL);
+ mp_set_u32(&Z, 2uL);
/* Z = 2 */
while (1) {
if ((err = mp_kronecker(&Z, prime, &legendre)) != MP_OKAY) goto cleanup;
@@ -79,7 +79,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
/* T = n ^ Q mod prime */
if ((err = mp_copy(&S, &M)) != MP_OKAY) goto cleanup;
/* M = S */
- mp_set_uint32(&two, 2uL);
+ mp_set_u32(&two, 2uL);
while (1) {
if ((err = mp_copy(&T, &t1)) != MP_OKAY) goto cleanup;
diff --git a/demo/test.c b/demo/test.c
index a16397a..6e08c6e 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -89,10 +89,10 @@ static int test_trivial_stuff(void)
if (mp_isneg(&b) != MP_YES) {
goto LBL_ERR;
}
- if (mp_get_int32(&b) != -4) {
+ if (mp_get_i32(&b) != -4) {
goto LBL_ERR;
}
- if (mp_get_uint32(&b) != (uint32_t)-4) {
+ if (mp_get_u32(&b) != (uint32_t)-4) {
goto LBL_ERR;
}
if (mp_get_mag32(&b) != 4) {
@@ -100,18 +100,18 @@ static int test_trivial_stuff(void)
}
/* a: -5-> b: 1 */
mp_add_d(&a, 6uL, &b);
- if (mp_get_uint32(&b) != 1) {
+ if (mp_get_u32(&b) != 1) {
goto LBL_ERR;
}
/* a: -5-> a: 1 */
mp_add_d(&a, 6uL, &a);
- if (mp_get_uint32(&a) != 1) {
+ if (mp_get_u32(&a) != 1) {
goto LBL_ERR;
}
mp_zero(&a);
/* a: 0-> a: 6 */
mp_add_d(&a, 6uL, &a);
- if (mp_get_uint32(&a) != 6) {
+ if (mp_get_u32(&a) != 6) {
goto LBL_ERR;
}
@@ -135,21 +135,21 @@ LBL_ERR:
return EXIT_FAILURE;
}
-static int check_get_set_int32(mp_int *a, int32_t b)
+static int check_get_set_i32(mp_int *a, int32_t b)
{
- mp_set_int32(a, b);
- if (mp_get_int32(a) != b) return EXIT_FAILURE;
- if (mp_get_uint32(a) != (uint32_t)b) return EXIT_FAILURE;
+ mp_set_i32(a, b);
+ if (mp_get_i32(a) != b) return EXIT_FAILURE;
+ if (mp_get_u32(a) != (uint32_t)b) return EXIT_FAILURE;
if (mp_get_mag32(a) != uabs32(b)) return EXIT_FAILURE;
- mp_set_uint32(a, (uint32_t)b);
- if (mp_get_uint32(a) != (uint32_t)b) return EXIT_FAILURE;
- if (mp_get_int32(a) != (int32_t)(uint32_t)b) return EXIT_FAILURE;
+ mp_set_u32(a, (uint32_t)b);
+ if (mp_get_u32(a) != (uint32_t)b) return EXIT_FAILURE;
+ if (mp_get_i32(a) != (int32_t)(uint32_t)b) return EXIT_FAILURE;
return EXIT_SUCCESS;
}
-static int test_mp_get_set_int32(void)
+static int test_mp_get_set_i32(void)
{
int i;
mp_int a;
@@ -158,15 +158,15 @@ static int test_mp_get_set_int32(void)
return EXIT_FAILURE;
}
- check_get_set_int32(&a, 0);
- check_get_set_int32(&a, -1);
- check_get_set_int32(&a, 1);
- check_get_set_int32(&a, INT32_MIN);
- check_get_set_int32(&a, INT32_MAX);
+ check_get_set_i32(&a, 0);
+ check_get_set_i32(&a, -1);
+ check_get_set_i32(&a, 1);
+ check_get_set_i32(&a, INT32_MIN);
+ check_get_set_i32(&a, INT32_MAX);
for (i = 0; i < 1000; ++i) {
int32_t b = rand_int32();
- if (check_get_set_int32(&a, b) != EXIT_SUCCESS) {
+ if (check_get_set_i32(&a, b) != EXIT_SUCCESS) {
goto LBL_ERR;
}
}
@@ -178,21 +178,21 @@ LBL_ERR:
return EXIT_FAILURE;
}
-static int check_get_set_int64(mp_int *a, int64_t b)
+static int check_get_set_i64(mp_int *a, int64_t b)
{
- mp_set_int64(a, b);
- if (mp_get_int64(a) != b) return EXIT_FAILURE;
- if (mp_get_uint64(a) != (uint64_t)b) return EXIT_FAILURE;
+ mp_set_i64(a, b);
+ if (mp_get_i64(a) != b) return EXIT_FAILURE;
+ if (mp_get_u64(a) != (uint64_t)b) return EXIT_FAILURE;
if (mp_get_mag64(a) != uabs64(b)) return EXIT_FAILURE;
- mp_set_uint64(a, (uint64_t)b);
- if (mp_get_uint64(a) != (uint64_t)b) return EXIT_FAILURE;
- if (mp_get_int64(a) != (int64_t)(uint64_t)b) return EXIT_FAILURE;
+ mp_set_u64(a, (uint64_t)b);
+ if (mp_get_u64(a) != (uint64_t)b) return EXIT_FAILURE;
+ if (mp_get_i64(a) != (int64_t)(uint64_t)b) return EXIT_FAILURE;
return EXIT_SUCCESS;
}
-static int test_mp_get_set_int64(void)
+static int test_mp_get_set_i64(void)
{
int i;
mp_int a;
@@ -201,15 +201,15 @@ static int test_mp_get_set_int64(void)
return EXIT_FAILURE;
}
- check_get_set_int64(&a, 0);
- check_get_set_int64(&a, -1);
- check_get_set_int64(&a, 1);
- check_get_set_int64(&a, INT64_MIN);
- check_get_set_int64(&a, INT64_MAX);
+ check_get_set_i64(&a, 0);
+ check_get_set_i64(&a, -1);
+ check_get_set_i64(&a, 1);
+ check_get_set_i64(&a, INT64_MIN);
+ check_get_set_i64(&a, INT64_MAX);
for (i = 0; i < 1000; ++i) {
int64_t b = rand_int64();
- if (check_get_set_int64(&a, b) != EXIT_SUCCESS) {
+ if (check_get_set_i64(&a, b) != EXIT_SUCCESS) {
goto LBL_ERR;
}
}
@@ -239,7 +239,7 @@ static int test_mp_fread_fwrite(void)
if ((e = mp_fread(&b, 64, tmp)) != MP_OKAY) {
goto LBL_ERR;
}
- if (mp_get_uint32(&b) != 123456uL) {
+ if (mp_get_u32(&b) != 123456uL) {
goto LBL_ERR;
}
fclose(tmp);
@@ -732,7 +732,7 @@ LBL_ERR:
}
-static int test_mp_get_uint32(void)
+static int test_mp_get_u32(void)
{
unsigned long t;
int i;
@@ -745,19 +745,19 @@ static int test_mp_get_uint32(void)
for (i = 0; i < 1000; ++i) {
t = (unsigned long)rand_long() & 0xFFFFFFFFuL;
mp_set_ul(&a, t);
- if (t != mp_get_uint32(&a)) {
- printf("\nmp_get_uint32() bad result!");
+ if (t != mp_get_u32(&a)) {
+ printf("\nmp_get_u32() bad result!");
goto LBL_ERR;
}
}
mp_set_ul(&a, 0uL);
- if (mp_get_uint32(&a) != 0) {
- printf("\nmp_get_uint32() bad result!");
+ if (mp_get_u32(&a) != 0) {
+ printf("\nmp_get_u32() bad result!");
goto LBL_ERR;
}
mp_set_ul(&a, 0xFFFFFFFFuL);
- if (mp_get_uint32(&a) != 0xFFFFFFFFuL) {
- printf("\nmp_get_uint32() bad result!");
+ if (mp_get_u32(&a) != 0xFFFFFFFFuL) {
+ printf("\nmp_get_u32() bad result!");
goto LBL_ERR;
}
@@ -801,7 +801,7 @@ LBL_ERR:
return EXIT_FAILURE;
}
-static int test_mp_get_uint64(void)
+static int test_mp_get_u64(void)
{
unsigned long long q, r;
int i;
@@ -817,10 +817,10 @@ static int test_mp_get_uint64(void)
r = ~0ULL;
printf(" r = 0x%llx i = %d\r", r, i);
do {
- mp_set_uint64(&a, r);
- q = mp_get_uint64(&a);
+ mp_set_u64(&a, r);
+ q = mp_get_u64(&a);
if (q != r) {
- printf("\nmp_get_uint64() bad result! 0x%llx != 0x%llx", q, r);
+ printf("\nmp_get_u64() bad result! 0x%llx != 0x%llx", q, r);
goto LBL_ERR;
}
r <<= 1;
@@ -2143,8 +2143,8 @@ int unit_tests(int argc, char **argv)
} test[] = {
#define T(n) { #n, test_##n }
T(trivial_stuff),
- T(mp_get_set_int32),
- T(mp_get_set_int64),
+ T(mp_get_set_i32),
+ T(mp_get_set_i64),
T(mp_and),
T(mp_cnt_lsb),
T(mp_complement),
@@ -2152,8 +2152,8 @@ int unit_tests(int argc, char **argv)
T(mp_div_3),
T(mp_dr_reduce),
T(mp_fread_fwrite),
- T(mp_get_uint32),
- T(mp_get_uint64),
+ T(mp_get_u32),
+ T(mp_get_u64),
T(mp_get_ul),
T(mp_ilogb),
T(mp_incr),
diff --git a/doc/bn.tex b/doc/bn.tex
index 6f5afcd..906e58e 100644
--- a/doc/bn.tex
+++ b/doc/bn.tex
@@ -826,10 +826,10 @@ These functions can be used to set a constant with 32 or 64 bits.
\index{mp\_set\_int}
\begin{alltt}
-void mp_set_int32 (mp_int * a, int32_t b);
-void mp_set_uint32 (mp_int * a, uint32_t b);
-void mp_set_int64 (mp_int * a, int64_t b);
-void mp_set_uint64 (mp_int * a, uint64_t b);
+void mp_set_i32 (mp_int * a, int32_t b);
+void mp_set_u32 (mp_int * a, uint32_t b);
+void mp_set_i64 (mp_int * a, int64_t b);
+void mp_set_u64 (mp_int * a, uint64_t b);
\end{alltt}
These functions assign the sign and value of the input \texttt{b} to \texttt{mp_int a}.
@@ -837,11 +837,11 @@ The value can be obtained again by calling the following functions.
\index{mp\_get\_int}
\begin{alltt}
-int32_t mp_get_int32 (mp_int * a);
-uint32_t mp_get_uint32 (mp_int * a);
+int32_t mp_get_i32 (mp_int * a);
+uint32_t mp_get_u32 (mp_int * a);
uint32_t mp_get_mag32 (mp_int * a);
-int64_t mp_get_int64 (mp_int * a);
-uint64_t mp_get_uint64 (mp_int * a);
+int64_t mp_get_i64 (mp_int * a);
+uint64_t mp_get_u64 (mp_int * a);
uint64_t mp_get_mag64 (mp_int * a);
\end{alltt}
@@ -861,9 +861,9 @@ int main(void)
\}
/* set the number to 654321 (note this is bigger than 127) */
- mp_set_uint(&number, 654321);
+ mp_set_u32(&number, 654321);
- printf("number == \%lu", mp_get_int(&number));
+ printf("number == \%lu", mp_get_i32(&number));
/* we're done with it. */
mp_clear(&number);
@@ -903,8 +903,8 @@ To both initialize and set small constants the following two functions are avail
\index{mp\_init\_set} \index{mp\_init\_set\_int}
\begin{alltt}
int mp_init_set (mp_int * a, mp_digit b);
-int mp_init_set_int32 (mp_int * a, int32_t b);
-int mp_init_set_uint32 (mp_int * a, uint32_t b);
+int mp_init_i32 (mp_int * a, int32_t b);
+int mp_init_u32 (mp_int * a, uint32_t b);
\end{alltt}
Both functions work like the previous counterparts except they first mp\_init $a$ before setting the values.
@@ -931,7 +931,7 @@ int main(void)
/* display */
printf("Number1, Number2 == \%lu, \%lu",
- mp_get_int(&number1), mp_get_int(&number2));
+ mp_get_i32(&number1), mp_get_i32(&number2));
/* clear */
mp_clear_multi(&number1, &number2, NULL);
@@ -1365,8 +1365,8 @@ int main(void)
\}
/* set the terms */
- mp_set_int(&number, 257);
- mp_set_int(&number2, 1023);
+ mp_set_i32(&number, 257);
+ mp_set_i32(&number2, 1023);
/* multiply them */
if ((result = mp_mul(&number1, &number2,
@@ -1377,7 +1377,7 @@ int main(void)
\}
/* display */
- printf("number1 * number2 == \%lu", mp_get_int(&number1));
+ printf("number1 * number2 == \%lu", mp_get_i32(&number1));
/* free terms and return */
mp_clear_multi(&number1, &number2, NULL);
diff --git a/tommath.h b/tommath.h
index 936a432..329ddaa 100644
--- a/tommath.h
+++ b/tommath.h
@@ -275,34 +275,36 @@ double mp_get_double(const mp_int *a) MP_WUR;
mp_err mp_set_double(mp_int *a, double b) MP_WUR;
/* get integer, set integer and init with integer (int32_t) */
-int32_t mp_get_int32(const mp_int *a) MP_WUR;
-void mp_set_int32(mp_int *a, int32_t b);
-mp_err mp_init_int32(mp_int *a, int32_t b) MP_WUR;
+int32_t mp_get_i32(const mp_int *a) MP_WUR;
+void mp_set_i32(mp_int *a, int32_t b);
+mp_err mp_init_i32(mp_int *a, int32_t b) MP_WUR;
/* get integer, set integer and init with integer, behaves like two complement for negative numbers (uint32_t) */
-#define mp_get_uint32(a) ((uint32_t)mp_get_int32(a))
-void mp_set_uint32(mp_int *a, uint32_t b);
-mp_err mp_init_uint32(mp_int *a, uint32_t b) MP_WUR;
+#define mp_get_u32(a) ((uint32_t)mp_get_i32(a))
+void mp_set_u32(mp_int *a, uint32_t b);
+mp_err mp_init_u32(mp_int *a, uint32_t b) MP_WUR;
/* get integer, set integer and init with integer (int64_t) */
-int64_t mp_get_int64(const mp_int *a) MP_WUR;
-void mp_set_int64(mp_int *a, int64_t b);
+int64_t mp_get_i64(const mp_int *a) MP_WUR;
+void mp_set_i64(mp_int *a, int64_t b);
+mp_err mp_init_i64(mp_int *a, int64_t b) MP_WUR;
/* get integer, set integer and init with integer, behaves like two complement for negative numbers (uint64_t) */
-#define mp_get_uint64(a) ((uint64_t)mp_get_int64(a))
-void mp_set_uint64(mp_int *a, uint64_t b);
+#define mp_get_u64(a) ((uint64_t)mp_get_i64(a))
+void mp_set_u64(mp_int *a, uint64_t b);
+mp_err mp_init_u64(mp_int *a, uint64_t b) MP_WUR;
/* get magnitude */
uint32_t mp_get_mag32(const mp_int *a) MP_WUR;
uint64_t mp_get_mag64(const mp_int *a) MP_WUR;
/* get integer, set integer (long) */
-#define mp_get_l(a) (sizeof (long) == 8 ? (long)mp_get_int64(a) : (long)mp_get_int32(a))
-#define mp_set_l(a, b) (sizeof (long) == 8 ? mp_set_int64((a), (b)) : mp_set_int32((a), (int32_t)(b)))
+#define mp_get_l(a) (sizeof (long) == 8 ? (long)mp_get_i64(a) : (long)mp_get_i32(a))
+#define mp_set_l(a, b) (sizeof (long) == 8 ? mp_set_i64((a), (b)) : mp_set_i32((a), (int32_t)(b)))
/* get integer, set integer (unsigned long) */
-#define mp_get_ul(a) (sizeof (long) == 8 ? (unsigned long)mp_get_uint64(a) : (unsigned long)mp_get_uint32(a))
-#define mp_set_ul(a, b) (sizeof (long) == 8 ? mp_set_uint64((a), (b)) : mp_set_uint32((a), (uint32_t)(b)))
+#define mp_get_ul(a) (sizeof (long) == 8 ? (unsigned long)mp_get_u64(a) : (unsigned long)mp_get_u32(a))
+#define mp_set_ul(a, b) (sizeof (long) == 8 ? mp_set_u64((a), (b)) : mp_set_u32((a), (uint32_t)(b)))
#define mp_get_magl(a) (sizeof (long) == 8 ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a))
/* set to single unsigned digit, up to MP_DIGIT_MAX */
@@ -310,13 +312,13 @@ void mp_set(mp_int *a, mp_digit b);
mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
/* get integer, set integer and init with integer (deprecated) */
-MP_DEPRECATED(mp_get_mag32/mp_get_uint32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_get_mag32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
MP_DEPRECATED(mp_get_magl/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_mag64/mp_get_uint64) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_set_uint32) mp_err mp_set_int(mp_int *a, unsigned long b);
+MP_DEPRECATED(mp_get_mag64/mp_get_u64) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_set_u32) mp_err mp_set_int(mp_int *a, unsigned long b);
MP_DEPRECATED(mp_set_ul) mp_err mp_set_long(mp_int *a, unsigned long b);
-MP_DEPRECATED(mp_set_uint64) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
-MP_DEPRECATED(mp_init_uint32) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
+MP_DEPRECATED(mp_set_u64) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
+MP_DEPRECATED(mp_init_u32) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
/* copy, b = a */
mp_err mp_copy(const mp_int *a, mp_int *b) MP_WUR;
diff --git a/tommath_class.h b/tommath_class.h
index 3c03d21..b0e1de6 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -151,16 +151,18 @@
#endif
#if defined(BN_CONVERSION_C)
# define BN_MP_INIT_C
-# define BN_MP_SET_UINT32_C
-# define BN_MP_SET_UINT64_C
-# define BN_MP_SET_INT32_C
-# define BN_MP_SET_INT64_C
-# define BN_MP_GET_INT32_C
-# define BN_MP_GET_INT64_C
+# define BN_MP_SET_U32_C
+# define BN_MP_SET_U64_C
+# define BN_MP_SET_I32_C
+# define BN_MP_SET_I64_C
+# define BN_MP_GET_I32_C
+# define BN_MP_GET_I64_C
# define BN_MP_GET_MAG32_C
# define BN_MP_GET_MAG64_C
-# define BN_MP_INIT_UINT32_C
-# define BN_MP_INIT_INT32_C
+# define BN_MP_INIT_U32_C
+# define BN_MP_INIT_I32_C
+# define BN_MP_INIT_U64_C
+# define BN_MP_INIT_I64_C
#endif
#if defined(BN_CUTOFFS_C)
@@ -211,11 +213,11 @@
# define BN_MP_TC_DIV_2D_C
# define BN_MP_SIGNED_RSH_C
# define BN_MP_INIT_SET_INT_C
-# define BN_MP_INIT_UINT32_C
+# define BN_MP_INIT_U32_C
# define BN_MP_SET_INT_C
-# define BN_MP_SET_UINT32_C
+# define BN_MP_SET_U32_C
# define BN_MP_SET_LONG_C
-# define BN_MP_SET_UINT64_C
+# define BN_MP_SET_U64_C
# define BN_MP_SET_LONG_LONG_C
# define BN_MP_GET_INT_C
# define BN_MP_GET_MAG32_C
@@ -447,7 +449,7 @@
#endif
#if defined(BN_MP_ILOGB_C)
-# define BN_MP_SET_UINT32_C
+# define BN_MP_SET_U32_C
# define BN_MP_COUNT_BITS_C
# define BN_MP_SET_C
# define BN_MP_CMP_D_C
@@ -504,9 +506,9 @@
#if defined(BN_MP_IS_SQUARE_C)
# define BN_MP_MOD_D_C
-# define BN_MP_INIT_UINT32_C
+# define BN_MP_INIT_U32_C
# define BN_MP_MOD_C
-# define BN_MP_GET_UINT32_C
+# define BN_MP_GET_U32_C
# define BN_MP_SQRT_C
# define BN_MP_SQR_C
# define BN_MP_CMP_MAG_C
@@ -653,7 +655,7 @@
#if defined(BN_MP_PRIME_FROBENIUS_UNDERWOOD_C)
# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_UINT32_C
+# define BN_MP_SET_U32_C
# define BN_MP_SQR_C
# define BN_MP_SUB_D_C
# define BN_MP_KRONECKER_C
@@ -735,11 +737,11 @@
#if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
# define BN_S_MP_MUL_SI_C
# define BN_MP_INIT_C
-# define BN_MP_SET_INT32_C
+# define BN_MP_SET_I32_C
# define BN_MP_MUL_C
# define BN_MP_CLEAR_C
# define BN_MP_INIT_MULTI_C
-# define BN_MP_SET_UINT32_C
+# define BN_MP_SET_U32_C
# define BN_MP_GCD_C
# define BN_MP_CMP_D_C
# define BN_MP_CMP_C
@@ -870,7 +872,7 @@
#endif
#if defined(BN_MP_SET_DOUBLE_C)
-# define BN_MP_SET_UINT64_C
+# define BN_MP_SET_U64_C
# define BN_MP_DIV_2D_C
# define BN_MP_MUL_2D_C
#endif
@@ -925,7 +927,7 @@
# define BN_MP_EXPTMOD_C
# define BN_MP_COPY_C
# define BN_MP_SUB_D_C
-# define BN_MP_SET_UINT32_C
+# define BN_MP_SET_U32_C
# define BN_MP_SQRMOD_C
# define BN_MP_MULMOD_C
# define BN_MP_SET_C