Merge pull request #378 from libtom/remove-deprecated Remove deprecated functions
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 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
diff --git a/bn_deprecated.c b/bn_deprecated.c
deleted file mode 100644
index 2056b20..0000000
--- a/bn_deprecated.c
+++ /dev/null
@@ -1,321 +0,0 @@
-#include "tommath_private.h"
-#ifdef BN_DEPRECATED_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis */
-/* SPDX-License-Identifier: Unlicense */
-
-#ifdef BN_MP_GET_BIT_C
-int mp_get_bit(const mp_int *a, int b)
-{
- if (b < 0) {
- return MP_VAL;
- }
- return (s_mp_get_bit(a, (unsigned int)b) == MP_YES) ? MP_YES : MP_NO;
-}
-#endif
-#ifdef BN_MP_JACOBI_C
-mp_err mp_jacobi(const mp_int *a, const mp_int *n, int *c)
-{
- if (a->sign == MP_NEG) {
- return MP_VAL;
- }
- if (mp_cmp_d(n, 0uL) != MP_GT) {
- return MP_VAL;
- }
- return mp_kronecker(a, n, c);
-}
-#endif
-#ifdef BN_MP_PRIME_RANDOM_EX_C
-mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
-{
- return s_mp_prime_random_ex(a, t, size, flags, cb, dat);
-}
-#endif
-#ifdef BN_MP_RAND_DIGIT_C
-mp_err mp_rand_digit(mp_digit *r)
-{
- mp_err err = s_mp_rand_source(r, sizeof(mp_digit));
- *r &= MP_MASK;
- return err;
-}
-#endif
-#ifdef BN_FAST_MP_INVMOD_C
-mp_err fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return s_mp_invmod_fast(a, b, c);
-}
-#endif
-#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
-mp_err fast_mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
-{
- return s_mp_montgomery_reduce_fast(x, n, rho);
-}
-#endif
-#ifdef BN_FAST_S_MP_MUL_DIGS_C
-mp_err fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
-{
- return s_mp_mul_digs_fast(a, b, c, digs);
-}
-#endif
-#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
-mp_err fast_s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
-{
- return s_mp_mul_high_digs_fast(a, b, c, digs);
-}
-#endif
-#ifdef BN_FAST_S_MP_SQR_C
-mp_err fast_s_mp_sqr(const mp_int *a, mp_int *b)
-{
- return s_mp_sqr_fast(a, b);
-}
-#endif
-#ifdef BN_MP_BALANCE_MUL_C
-mp_err mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return s_mp_balance_mul(a, b, c);
-}
-#endif
-#ifdef BN_MP_EXPTMOD_FAST_C
-mp_err mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
-{
- return s_mp_exptmod_fast(G, X, P, Y, redmode);
-}
-#endif
-#ifdef BN_MP_INVMOD_SLOW_C
-mp_err mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return s_mp_invmod_slow(a, b, c);
-}
-#endif
-#ifdef BN_MP_KARATSUBA_MUL_C
-mp_err mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return s_mp_karatsuba_mul(a, b, c);
-}
-#endif
-#ifdef BN_MP_KARATSUBA_SQR_C
-mp_err mp_karatsuba_sqr(const mp_int *a, mp_int *b)
-{
- return s_mp_karatsuba_sqr(a, b);
-}
-#endif
-#ifdef BN_MP_TOOM_MUL_C
-mp_err mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return s_mp_toom_mul(a, b, c);
-}
-#endif
-#ifdef BN_MP_TOOM_SQR_C
-mp_err mp_toom_sqr(const mp_int *a, mp_int *b)
-{
- return s_mp_toom_sqr(a, b);
-}
-#endif
-#ifdef S_MP_REVERSE_C
-void bn_reverse(unsigned char *s, int len)
-{
- if (len > 0) {
- s_mp_reverse(s, (size_t)len);
- }
-}
-#endif
-#ifdef BN_MP_TC_AND_C
-mp_err mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return mp_and(a, b, c);
-}
-#endif
-#ifdef BN_MP_TC_OR_C
-mp_err mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return mp_or(a, b, c);
-}
-#endif
-#ifdef BN_MP_TC_XOR_C
-mp_err mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
-{
- return mp_xor(a, b, c);
-}
-#endif
-#ifdef BN_MP_TC_DIV_2D_C
-mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
-{
- return mp_signed_rsh(a, b, c);
-}
-#endif
-#ifdef BN_MP_INIT_SET_INT_C
-mp_err mp_init_set_int(mp_int *a, unsigned long 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_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_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_u64(a, b);
- return MP_OKAY;
-}
-#endif
-#ifdef BN_MP_GET_INT_C
-unsigned long mp_get_int(const mp_int *a)
-{
- return (unsigned long)mp_get_mag_u32(a);
-}
-#endif
-#ifdef BN_MP_GET_LONG_C
-unsigned long mp_get_long(const mp_int *a)
-{
- return (unsigned long)mp_get_mag_ul(a);
-}
-#endif
-#ifdef BN_MP_GET_LONG_LONG_C
-unsigned long long mp_get_long_long(const mp_int *a)
-{
- return mp_get_mag_ull(a);
-}
-#endif
-#ifdef BN_MP_PRIME_IS_DIVISIBLE_C
-mp_err mp_prime_is_divisible(const mp_int *a, mp_bool *result)
-{
- return s_mp_prime_is_divisible(a, result);
-}
-#endif
-#ifdef BN_MP_EXPT_D_EX_C
-mp_err mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
-{
- (void)fast;
- if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
- return MP_VAL;
- }
- return mp_expt_u32(a, (uint32_t)b, c);
-}
-#endif
-#ifdef BN_MP_EXPT_D_C
-mp_err mp_expt_d(const mp_int *a, mp_digit b, mp_int *c)
-{
- if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
- return MP_VAL;
- }
- return mp_expt_u32(a, (uint32_t)b, c);
-}
-#endif
-#ifdef BN_MP_N_ROOT_EX_C
-mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
-{
- (void)fast;
- if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
- return MP_VAL;
- }
- return mp_root_u32(a, (uint32_t)b, c);
-}
-#endif
-#ifdef BN_MP_N_ROOT_C
-mp_err mp_n_root(const mp_int *a, mp_digit b, mp_int *c)
-{
- if (b > MP_MIN(MP_DIGIT_MAX, UINT32_MAX)) {
- return MP_VAL;
- }
- return mp_root_u32(a, (uint32_t)b, c);
-}
-#endif
-#ifdef BN_MP_UNSIGNED_BIN_SIZE_C
-int mp_unsigned_bin_size(const mp_int *a)
-{
- return (int)mp_ubin_size(a);
-}
-#endif
-#ifdef BN_MP_READ_UNSIGNED_BIN_C
-mp_err mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c)
-{
- return mp_from_ubin(a, b, (size_t) c);
-}
-#endif
-#ifdef BN_MP_TO_UNSIGNED_BIN_C
-mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
-{
- return mp_to_ubin(a, b, SIZE_MAX, NULL);
-}
-#endif
-#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
-mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
-{
- size_t n = mp_ubin_size(a);
- if (*outlen < (unsigned long)n) {
- return MP_VAL;
- }
- *outlen = (unsigned long)n;
- return mp_to_ubin(a, b, n, NULL);
-}
-#endif
-#ifdef BN_MP_SIGNED_BIN_SIZE_C
-int mp_signed_bin_size(const mp_int *a)
-{
- return (int)mp_sbin_size(a);
-}
-#endif
-#ifdef BN_MP_READ_SIGNED_BIN_C
-mp_err mp_read_signed_bin(mp_int *a, const unsigned char *b, int c)
-{
- return mp_from_sbin(a, b, (size_t) c);
-}
-#endif
-#ifdef BN_MP_TO_SIGNED_BIN_C
-mp_err mp_to_signed_bin(const mp_int *a, unsigned char *b)
-{
- return mp_to_sbin(a, b, SIZE_MAX, NULL);
-}
-#endif
-#ifdef BN_MP_TO_SIGNED_BIN_N_C
-mp_err mp_to_signed_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
-{
- size_t n = mp_sbin_size(a);
- if (*outlen < (unsigned long)n) {
- return MP_VAL;
- }
- *outlen = (unsigned long)n;
- return mp_to_sbin(a, b, n, NULL);
-}
-#endif
-#ifdef BN_MP_TORADIX_N_C
-mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
-{
- if (maxlen < 0) {
- return MP_VAL;
- }
- return mp_to_radix(a, str, (size_t)maxlen, NULL, radix);
-}
-#endif
-#ifdef BN_MP_TORADIX_C
-mp_err mp_toradix(const mp_int *a, char *str, int radix)
-{
- return mp_to_radix(a, str, SIZE_MAX, NULL, radix);
-}
-#endif
-#ifdef BN_MP_IMPORT_C
-mp_err mp_import(mp_int *rop, size_t count, int order, size_t size, int endian, size_t nails,
- const void *op)
-{
- return mp_unpack(rop, count, order, size, endian, nails, op);
-}
-#endif
-#ifdef BN_MP_EXPORT_C
-mp_err mp_export(void *rop, size_t *countp, int order, size_t size,
- int endian, size_t nails, const mp_int *op)
-{
- return mp_pack(rop, SIZE_MAX, countp, order, size, endian, nails, op);
-}
-#endif
-#endif
diff --git a/bn_mp_fread.c b/bn_mp_fread.c
index 52ea773..1e5ecf7 100644
--- a/bn_mp_fread.c
+++ b/bn_mp_fread.c
@@ -30,11 +30,11 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
do {
int y;
unsigned pos = (unsigned)(ch - (int)'(');
- if (mp_s_rmap_reverse_sz < pos) {
+ if (MP_RMAP_REVERSE_SIZE < pos) {
break;
}
- y = (int)mp_s_rmap_reverse[pos];
+ y = (int)s_mp_rmap_reverse[pos];
if ((y == 0xff) || (y >= radix)) {
break;
diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index 7f9fc0b..49fde93 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -51,7 +51,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
}
/* is the input equal to one of the primes in the table? */
- for (ix = 0; ix < PRIVATE_MP_PRIME_TAB_SIZE; ix++) {
+ for (ix = 0; ix < MP_PRIME_TAB_SIZE; ix++) {
if (mp_cmp_d(a, s_mp_prime_tab[ix]) == MP_EQ) {
*result = MP_YES;
return MP_OKAY;
@@ -59,7 +59,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
}
#ifdef MP_8BIT
/* The search in the loop above was exhaustive in this case */
- if ((a->used == 1) && (PRIVATE_MP_PRIME_TAB_SIZE >= 31)) {
+ if ((a->used == 1) && (MP_PRIME_TAB_SIZE >= 31)) {
return MP_OKAY;
}
#endif
diff --git a/bn_mp_prime_next_prime.c b/bn_mp_prime_next_prime.c
index 1e971fa..de27eab 100644
--- a/bn_mp_prime_next_prime.c
+++ b/bn_mp_prime_next_prime.c
@@ -13,16 +13,16 @@ mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style)
int x, y, cmp;
mp_err err;
mp_bool res = MP_NO;
- mp_digit res_tab[PRIVATE_MP_PRIME_TAB_SIZE], step, kstep;
+ mp_digit res_tab[MP_PRIME_TAB_SIZE], step, kstep;
mp_int b;
/* force positive */
a->sign = MP_ZPOS;
/* simple algo if a is less than the largest prime in the table */
- if (mp_cmp_d(a, s_mp_prime_tab[PRIVATE_MP_PRIME_TAB_SIZE-1]) == MP_LT) {
+ if (mp_cmp_d(a, s_mp_prime_tab[MP_PRIME_TAB_SIZE-1]) == MP_LT) {
/* find which prime it is bigger than "a" */
- for (x = 0; x < PRIVATE_MP_PRIME_TAB_SIZE; x++) {
+ for (x = 0; x < MP_PRIME_TAB_SIZE; x++) {
cmp = mp_cmp_d(a, s_mp_prime_tab[x]);
if (cmp == MP_EQ) {
continue;
@@ -66,7 +66,7 @@ mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style)
}
/* generate the restable */
- for (x = 1; x < PRIVATE_MP_PRIME_TAB_SIZE; x++) {
+ for (x = 1; x < MP_PRIME_TAB_SIZE; x++) {
if ((err = mp_mod_d(a, s_mp_prime_tab[x], res_tab + x)) != MP_OKAY) {
return err;
}
@@ -88,7 +88,7 @@ mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style)
step += kstep;
/* compute the new residue without using division */
- for (x = 1; x < PRIVATE_MP_PRIME_TAB_SIZE; x++) {
+ for (x = 1; x < MP_PRIME_TAB_SIZE; x++) {
/* add the step to each residue */
res_tab[x] += kstep;
diff --git a/bn_mp_prime_rand.c b/bn_mp_prime_rand.c
index 4530e9a..af19d76 100644
--- a/bn_mp_prime_rand.c
+++ b/bn_mp_prime_rand.c
@@ -18,7 +18,7 @@
*/
/* This is possibly the mother of all prime generation functions, muahahahahaha! */
-mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat)
+mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback cb, void *dat)
{
unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb;
int bsize, maskOR_msb_offset;
diff --git a/bn_mp_radix_smap.c b/bn_mp_radix_smap.c
index a16128d..e7d7c06 100644
--- a/bn_mp_radix_smap.c
+++ b/bn_mp_radix_smap.c
@@ -4,8 +4,8 @@
/* SPDX-License-Identifier: Unlicense */
/* chars used in radix conversions */
-const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
-const uint8_t mp_s_rmap_reverse[] = {
+const char s_mp_rmap[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
+const uint8_t s_mp_rmap_reverse[] = {
0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
@@ -18,5 +18,5 @@ const uint8_t mp_s_rmap_reverse[] = {
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
};
-const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
+MP_STATIC_ASSERT(correct_rmap_reverse_size, sizeof(s_mp_rmap_reverse) == MP_RMAP_REVERSE_SIZE)
#endif
diff --git a/bn_mp_read_radix.c b/bn_mp_read_radix.c
index de18e06..456a387 100644
--- a/bn_mp_read_radix.c
+++ b/bn_mp_read_radix.c
@@ -43,10 +43,10 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix)
*/
ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
pos = (unsigned)(ch - '(');
- if (mp_s_rmap_reverse_sz < pos) {
+ if (MP_RMAP_REVERSE_SIZE < pos) {
break;
}
- y = (int)mp_s_rmap_reverse[pos];
+ y = (int)s_mp_rmap_reverse[pos];
/* if the char was found in the map
* and is less than the given radix add it
diff --git a/bn_mp_to_radix.c b/bn_mp_to_radix.c
index 7fa86ca..18cb504 100644
--- a/bn_mp_to_radix.c
+++ b/bn_mp_to_radix.c
@@ -60,7 +60,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
if ((err = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
goto LBL_ERR;
}
- *str++ = mp_s_rmap[d];
+ *str++ = s_mp_rmap[d];
++digs;
}
/* reverse the digits of the string. In this case _s points
diff --git a/bn_prime_tab.c b/bn_prime_tab.c
index a6c07f8..6bd53fe 100644
--- a/bn_prime_tab.c
+++ b/bn_prime_tab.c
@@ -3,7 +3,7 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
-const mp_digit ltm_prime_tab[] = {
+const mp_digit s_mp_prime_tab[] = {
0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013,
0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035,
0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059,
@@ -44,18 +44,4 @@ const mp_digit ltm_prime_tab[] = {
#endif
};
-#if defined(__GNUC__) && __GNUC__ >= 4
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-const mp_digit *s_mp_prime_tab = ltm_prime_tab;
-#pragma GCC diagnostic pop
-#elif defined(_MSC_VER) && _MSC_VER >= 1500
-#pragma warning(push)
-#pragma warning(disable: 4996)
-const mp_digit *s_mp_prime_tab = ltm_prime_tab;
-#pragma warning(pop)
-#else
-const mp_digit *s_mp_prime_tab = ltm_prime_tab;
-#endif
-
#endif
diff --git a/bn_s_mp_prime_is_divisible.c b/bn_s_mp_prime_is_divisible.c
index ffd5093..ca303a5 100644
--- a/bn_s_mp_prime_is_divisible.c
+++ b/bn_s_mp_prime_is_divisible.c
@@ -17,7 +17,7 @@ mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result)
/* default to not */
*result = MP_NO;
- for (ix = 0; ix < PRIVATE_MP_PRIME_TAB_SIZE; ix++) {
+ for (ix = 0; ix < MP_PRIME_TAB_SIZE; ix++) {
/* what is a mod LBL_prime_tab[ix] */
if ((err = mp_mod_d(a, s_mp_prime_tab[ix], &res)) != MP_OKAY) {
return err;
diff --git a/demo/test.c b/demo/test.c
index 7b29a4c..c1fc878 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -1283,21 +1283,6 @@ static int test_mp_read_radix(void)
if ((err = mp_to_radix(&a, buf, SIZE_MAX, &written, 10)) != MP_OKAY) goto LTM_ERR;
printf(" '0' a == %s, length = %zu\n", buf, written);
-
-
- /* Although deprecated it needs to function as long as it isn't dropped */
- /*
- printf("Testing deprecated mp_toradix_n\n");
- if( (err = mp_read_radix(&a, "-123456", 10) ) != MP_OKAY) goto LTM_ERR;
- if( (err = mp_toradix_n(&a, buf, 10, 3) ) != MP_OKAY) goto LTM_ERR;
- printf("a == %s\n", buf);
- if( (err = mp_toradix_n(&a, buf, 10, 4) ) != MP_OKAY) goto LTM_ERR;
- printf("a == %s\n", buf);
- if( (err = mp_toradix_n(&a, buf, 10, 30) ) != MP_OKAY) goto LTM_ERR;
- printf("a == %s\n", buf);
- */
-
-
while (0) {
char *s = fgets(buf, sizeof(buf), stdin);
if (s != buf) break;
diff --git a/doc/bn.tex b/doc/bn.tex
index 3174187..5512bcd 100644
--- a/doc/bn.tex
+++ b/doc/bn.tex
@@ -2089,19 +2089,17 @@ The variable $flags$ specifies one of several options available
The function mp\_prime\_rand() is suitable for generating primes which must be secret (as in the case of RSA) since there
is no skew on the least significant bits.
-\textit{Note:} This function replaces the deprecated mp\_prime\_random and mp\_prime\_random\_ex functions.
-
\begin{figure}[h]
\begin{center}
\begin{small}
\begin{tabular}{|r|l|}
\hline \textbf{Flag} & \textbf{Meaning} \\
-\hline LTM\_PRIME\_BBS & Make the prime congruent to $3$ modulo $4$ \\
-\hline LTM\_PRIME\_SAFE & Make a prime $p$ such that $(p - 1)/2$ is also prime. \\
- & This option implies LTM\_PRIME\_BBS as well. \\
-\hline LTM\_PRIME\_2MSB\_OFF & Makes sure that the bit adjacent to the most significant bit \\
+\hline MP\_PRIME\_BBS & Make the prime congruent to $3$ modulo $4$ \\
+\hline MP\_PRIME\_SAFE & Make a prime $p$ such that $(p - 1)/2$ is also prime. \\
+ & This option implies MP\_PRIME\_BBS as well. \\
+\hline MP\_PRIME\_2MSB\_OFF & Makes sure that the bit adjacent to the most significant bit \\
& Is forced to zero. \\
-\hline LTM\_PRIME\_2MSB\_ON & Makes sure that the bit adjacent to the most significant bit \\
+\hline MP\_PRIME\_2MSB\_ON & Makes sure that the bit adjacent to the most significant bit \\
& Is forced to one. \\
\hline
\end{tabular}
@@ -2154,7 +2152,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
This stores in ``size'' the number of characters (including space for the NUL terminator) required. Upon error this
function returns an error code and ``size'' will be zero.
-If \texttt{LTM\_NO\_FILE} is not defined a function to write to a file is also available.
+If \texttt{MP\_NO\_FILE} is not defined a function to write to a file is also available.
\index{mp\_fwrite}
\begin{alltt}
int mp_fwrite(const mp_int *a, int radix, FILE *stream);
@@ -2170,7 +2168,7 @@ This will read the base-``radix'' NUL terminated string from ``str'' into $a$.
character it does not recognize (which happens to include th NUL char... imagine that...). A single leading $-$ sign
can be used to denote a negative number.
-If \texttt{LTM\_NO\_FILE} is not defined a function to read from a file is also available.
+If \texttt{MP\_NO\_FILE} is not defined a function to read from a file is also available.
\index{mp\_fread}
\begin{alltt}
int mp_fread(mp_int *a, int radix, FILE *stream);
diff --git a/helper.pl b/helper.pl
index e60c1a7..03b081c 100755
--- a/helper.pl
+++ b/helper.pl
@@ -358,15 +358,9 @@ EOS
my %depmap;
foreach my $filename (glob 'bn*.c') {
my $content;
- if ($filename =~ "bn_deprecated.c") {
- open(my $src, '<', $filename) or die "Can't open source file!\n";
- read $src, $content, -s $src;
- close $src;
- } else {
- my $cc = $ENV{'CC'} || 'gcc';
- $content = `$cc -E -x c -DLTM_ALL $filename`;
- $content =~ s/^# 1 "$filename".*?^# 2 "$filename"//ms;
- }
+ my $cc = $ENV{'CC'} || 'gcc';
+ $content = `$cc -E -x c -DLTM_ALL $filename`;
+ $content =~ s/^# 1 "$filename".*?^# 2 "$filename"//ms;
# convert filename to upper case so we can use it as a define
$filename =~ tr/[a-z]/[A-Z]/;
@@ -434,8 +428,6 @@ sub generate_def {
@files = map { my $x = $_; $x =~ s/^bn_|\.c$//g; $x; } @files;
@files = grep(!/mp_radix_smap/, @files);
- push(@files, qw(mp_set_int mp_set_long mp_set_long_long mp_get_int mp_get_long mp_get_long_long mp_init_set_int));
-
my $files = join("\n ", sort(grep(/^mp_/, @files)));
write_file "tommath.def", "; libtommath
;
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 67cc89b..7e51929 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -317,10 +317,6 @@
>
</File>
<File
- RelativePath="bn_deprecated.c"
- >
- </File>
- <File
RelativePath="bn_mp_2expt.c"
>
</File>
diff --git a/makefile b/makefile
index de65c9c..0f2e611 100644
--- a/makefile
+++ b/makefile
@@ -26,10 +26,10 @@ endif
LCOV_ARGS=--directory .
#START_INS
-OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
-bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
-bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
-bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+OBJECTS=bn_cutoffs.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o bn_mp_and.o \
+bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \
+bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \
+bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_expt_u32.o bn_mp_exptmod.o bn_mp_exteuclid.o bn_mp_fread.o \
bn_mp_from_sbin.o bn_mp_from_ubin.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o \
bn_mp_get_i64.o bn_mp_get_l.o bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o \
@@ -95,9 +95,6 @@ uninstall:
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
-test_standalone: test
- @echo "test_standalone is deprecated, please use make-target 'test'"
-
DEMOS=test mtest_opponent
define DEMO_template
diff --git a/makefile.mingw b/makefile.mingw
index 7eee57d..20b2ffe 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -29,10 +29,10 @@ LIBMAIN_I =libtommath.dll.a
LIBMAIN_D =libtommath.dll
#List of objects to compile (all goes to libtommath.a)
-OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
-bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
-bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
-bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+OBJECTS=bn_cutoffs.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o bn_mp_and.o \
+bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \
+bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \
+bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_expt_u32.o bn_mp_exptmod.o bn_mp_exteuclid.o bn_mp_fread.o \
bn_mp_from_sbin.o bn_mp_from_ubin.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o \
bn_mp_get_i64.o bn_mp_get_l.o bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o \
@@ -86,9 +86,6 @@ test.exe: demo/shared.o demo/test.o $(LIBMAIN_S)
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
@echo NOTICE: start the tests by launching test.exe
-test_standalone: test.exe
- @echo test_standalone is deprecated, please use make-target 'test.exe'
-
all: $(LIBMAIN_S) test.exe
tune: $(LIBNAME_S)
diff --git a/makefile.msvc b/makefile.msvc
index d282e93..8ad12be 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -21,10 +21,10 @@ LTM_LDFLAGS = advapi32.lib
LIBMAIN_S =tommath.lib
#List of objects to compile (all goes to tommath.lib)
-OBJECTS=bn_cutoffs.obj bn_deprecated.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj bn_mp_addmod.obj \
-bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj bn_mp_cmp_mag.obj \
-bn_mp_cnt_lsb.obj bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj \
-bn_mp_div_2d.obj bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \
+OBJECTS=bn_cutoffs.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj bn_mp_addmod.obj bn_mp_and.obj \
+bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj bn_mp_cmp_mag.obj bn_mp_cnt_lsb.obj \
+bn_mp_complement.obj bn_mp_copy.obj bn_mp_count_bits.obj bn_mp_decr.obj bn_mp_div.obj bn_mp_div_2.obj bn_mp_div_2d.obj \
+bn_mp_div_3.obj bn_mp_div_d.obj bn_mp_dr_is_modulus.obj bn_mp_dr_reduce.obj bn_mp_dr_setup.obj \
bn_mp_error_to_string.obj bn_mp_exch.obj bn_mp_expt_u32.obj bn_mp_exptmod.obj bn_mp_exteuclid.obj bn_mp_fread.obj \
bn_mp_from_sbin.obj bn_mp_from_ubin.obj bn_mp_fwrite.obj bn_mp_gcd.obj bn_mp_get_double.obj bn_mp_get_i32.obj \
bn_mp_get_i64.obj bn_mp_get_l.obj bn_mp_get_ll.obj bn_mp_get_mag_u32.obj bn_mp_get_mag_u64.obj bn_mp_get_mag_ul.obj \
@@ -72,9 +72,6 @@ test.exe: $(LIBMAIN_S) demo/shared.obj demo/test.obj
cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/shared.c demo/test.c /Fe$@
@echo NOTICE: start the tests by launching test.exe
-test_standalone: test.exe
- @echo test_standalone is deprecated, please use make-target 'test.exe'
-
all: $(LIBMAIN_S) test.exe
tune: $(LIBMAIN_S)
diff --git a/makefile.shared b/makefile.shared
index 6802107..9f6b1c5 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -23,10 +23,10 @@ LTLINK = $(LIBTOOL) --mode=link --tag=CC $(CC)
LCOV_ARGS=--directory .libs --directory .
#START_INS
-OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
-bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
-bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
-bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+OBJECTS=bn_cutoffs.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o bn_mp_and.o \
+bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \
+bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \
+bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_expt_u32.o bn_mp_exptmod.o bn_mp_exteuclid.o bn_mp_fread.o \
bn_mp_from_sbin.o bn_mp_from_ubin.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o \
bn_mp_get_i64.o bn_mp_get_l.o bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o \
@@ -79,9 +79,6 @@ uninstall:
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
-test_standalone: test
- @echo "test_standalone is deprecated, please use make-target 'test'"
-
test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
$(LTLINK) $(LTM_LDFLAGS) demo/$@.o $^ -o $@
diff --git a/makefile.unix b/makefile.unix
index 750be56..4aa0d27 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -30,10 +30,10 @@ LTM_LDFLAGS = $(LDFLAGS)
#Library to be created (this makefile builds only static library)
LIBMAIN_S = libtommath.a
-OBJECTS=bn_cutoffs.o bn_deprecated.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o \
-bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o \
-bn_mp_cnt_lsb.o bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o \
-bn_mp_div_2d.o bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
+OBJECTS=bn_cutoffs.o bn_mp_2expt.o bn_mp_abs.o bn_mp_add.o bn_mp_add_d.o bn_mp_addmod.o bn_mp_and.o \
+bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o \
+bn_mp_complement.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_decr.o bn_mp_div.o bn_mp_div_2.o bn_mp_div_2d.o \
+bn_mp_div_3.o bn_mp_div_d.o bn_mp_dr_is_modulus.o bn_mp_dr_reduce.o bn_mp_dr_setup.o \
bn_mp_error_to_string.o bn_mp_exch.o bn_mp_expt_u32.o bn_mp_exptmod.o bn_mp_exteuclid.o bn_mp_fread.o \
bn_mp_from_sbin.o bn_mp_from_ubin.o bn_mp_fwrite.o bn_mp_gcd.o bn_mp_get_double.o bn_mp_get_i32.o \
bn_mp_get_i64.o bn_mp_get_l.o bn_mp_get_ll.o bn_mp_get_mag_u32.o bn_mp_get_mag_u64.o bn_mp_get_mag_ul.o \
@@ -84,9 +84,6 @@ test: demo/shared.o demo/test.o $(LIBMAIN_S)
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
@echo "NOTICE: start the tests by: ./test"
-test_standalone: test
- @echo "test_standalone is deprecated, please use make-target 'test'"
-
all: $(LIBMAIN_S) test
tune: $(LIBMAIN_S)
diff --git a/tommath.def b/tommath.def
index 229fae4..9c7f226 100644
--- a/tommath.def
+++ b/tommath.def
@@ -44,11 +44,8 @@ EXPORTS
mp_get_double
mp_get_i32
mp_get_i64
- mp_get_int
mp_get_l
mp_get_ll
- mp_get_long
- mp_get_long_long
mp_get_mag_u32
mp_get_mag_u64
mp_get_mag_ul
@@ -63,7 +60,6 @@ EXPORTS
mp_init_ll
mp_init_multi
mp_init_set
- mp_init_set_int
mp_init_size
mp_init_u32
mp_init_u64
@@ -118,11 +114,8 @@ EXPORTS
mp_set_double
mp_set_i32
mp_set_i64
- mp_set_int
mp_set_l
mp_set_ll
- mp_set_long
- mp_set_long_long
mp_set_u32
mp_set_u64
mp_set_ul
diff --git a/tommath.h b/tommath.h
index 5af5014..6c4e957 100644
--- a/tommath.h
+++ b/tommath.h
@@ -6,12 +6,6 @@
#include <stdint.h>
#include <stddef.h>
-#include <limits.h>
-
-#ifdef LTM_NO_FILE
-# warning LTM_NO_FILE has been deprecated, use MP_NO_FILE.
-# define MP_NO_FILE
-#endif
#ifndef MP_NO_FILE
# include <stdio.h>
@@ -98,11 +92,6 @@ typedef uint64_t private_mp_word;
# endif
#endif
-/* mp_word is a private type */
-#define mp_word MP_DEPRECATED_PRAGMA("mp_word has been made private") private_mp_word
-
-#define MP_SIZEOF_MP_DIGIT (MP_DEPRECATED_PRAGMA("MP_SIZEOF_MP_DIGIT has been deprecated, use sizeof (mp_digit)") sizeof (mp_digit))
-
#define MP_MASK ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
#define MP_DIGIT_MAX MP_MASK
@@ -111,10 +100,6 @@ typedef uint64_t private_mp_word;
#define MP_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
#define MP_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
-#define LTM_PRIME_BBS (MP_DEPRECATED_PRAGMA("LTM_PRIME_BBS has been deprecated, use MP_PRIME_BBS") MP_PRIME_BBS)
-#define LTM_PRIME_SAFE (MP_DEPRECATED_PRAGMA("LTM_PRIME_SAFE has been deprecated, use MP_PRIME_SAFE") MP_PRIME_SAFE)
-#define LTM_PRIME_2MSB_ON (MP_DEPRECATED_PRAGMA("LTM_PRIME_2MSB_ON has been deprecated, use MP_PRIME_2MSB_ON") MP_PRIME_2MSB_ON)
-
typedef enum {
MP_ZPOS = 0, /* positive */
MP_NEG = 1 /* negative */
@@ -164,22 +149,6 @@ TOOM_SQR_CUTOFF;
/* define this to use lower memory usage routines (exptmods mostly) */
/* #define MP_LOW_MEM */
-/* default precision */
-#ifndef MP_PREC
-# ifndef MP_LOW_MEM
-# define PRIVATE_MP_PREC 32 /* default digits of precision */
-# elif defined(MP_8BIT)
-# define PRIVATE_MP_PREC 16 /* default digits of precision */
-# else
-# define PRIVATE_MP_PREC 8 /* default digits of precision */
-# endif
-# define MP_PREC (MP_DEPRECATED_PRAGMA("MP_PREC is an internal macro") PRIVATE_MP_PREC)
-#endif
-
-/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
-#define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)
-
#if defined(__GNUC__) && __GNUC__ >= 4
# define MP_NULL_TERMINATED __attribute__((sentinel))
#else
@@ -221,11 +190,6 @@ TOOM_SQR_CUTOFF;
# define MP_DEPRECATED_PRAGMA(s)
#endif
-#define DIGIT_BIT (MP_DEPRECATED_PRAGMA("DIGIT_BIT macro is deprecated, MP_DIGIT_BIT instead") MP_DIGIT_BIT)
-#define USED(m) (MP_DEPRECATED_PRAGMA("USED macro is deprecated, use z->used instead") (m)->used)
-#define DIGIT(m, k) (MP_DEPRECATED_PRAGMA("DIGIT macro is deprecated, use z->dp instead") (m)->dp[(k)])
-#define SIGN(m) (MP_DEPRECATED_PRAGMA("SIGN macro is deprecated, use z->sign instead") (m)->sign)
-
/* the infamous mp_int structure */
typedef struct {
int used, alloc;
@@ -233,10 +197,6 @@ typedef struct {
mp_digit *dp;
} mp_int;
-/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */
-typedef int private_mp_prime_callback(unsigned char *dst, int len, void *dat);
-typedef private_mp_prime_callback MP_DEPRECATED(mp_rand_source) ltm_prime_callback;
-
/* error code to char* string */
const char *mp_error_to_string(mp_err code) MP_WUR;
@@ -328,15 +288,6 @@ mp_err mp_init_ull(mp_int *a, unsigned long long b) MP_WUR;
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_mag_u32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_mag_ul/mp_get_ul) unsigned long mp_get_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_mag_ull/mp_get_ull) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_set_ul) 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_ull) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
-MP_DEPRECATED(mp_init_ul) 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;
@@ -346,16 +297,6 @@ mp_err mp_init_copy(mp_int *a, const mp_int *b) MP_WUR;
/* trim unused digits */
void mp_clamp(mp_int *a);
-
-/* export binary data */
-MP_DEPRECATED(mp_pack) mp_err mp_export(void *rop, size_t *countp, int order, size_t size,
- int endian, size_t nails, const mp_int *op) MP_WUR;
-
-/* import binary data */
-MP_DEPRECATED(mp_unpack) mp_err mp_import(mp_int *rop, size_t count, int order,
- size_t size, int endian, size_t nails,
- const void *op) MP_WUR;
-
/* unpack binary data */
mp_err mp_unpack(mp_int *rop, size_t count, mp_order order, size_t size, mp_endian endian,
size_t nails, const void *op) MP_WUR;
@@ -401,46 +342,24 @@ int mp_cnt_lsb(const mp_int *a) MP_WUR;
/* makes a pseudo-random mp_int of a given size */
mp_err mp_rand(mp_int *a, int digits) MP_WUR;
-/* makes a pseudo-random small int of a given size */
-MP_DEPRECATED(mp_rand) mp_err mp_rand_digit(mp_digit *r) MP_WUR;
/* use custom random data source instead of source provided the platform */
void mp_rand_source(mp_err(*source)(void *out, size_t size));
-#ifdef MP_PRNG_ENABLE_LTM_RNG
-# warning MP_PRNG_ENABLE_LTM_RNG has been deprecated, use mp_rand_source instead.
-/* A last resort to provide random data on systems without any of the other
- * implemented ways to gather entropy.
- * It is compatible with `rng_get_bytes()` from libtomcrypt so you could
- * provide that one and then set `ltm_rng = rng_get_bytes;` */
-extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
-extern void (*ltm_rng_callback)(void);
-#endif
-
/* ---> binary operations <--- */
-/* Checks the bit at position b and returns MP_YES
- * if the bit is 1, MP_NO if it is 0 and MP_VAL
- * in case of error
- */
-MP_DEPRECATED(s_mp_get_bit) int mp_get_bit(const mp_int *a, int b) MP_WUR;
-
/* c = a XOR b (two complement) */
-MP_DEPRECATED(mp_xor) mp_err mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
mp_err mp_xor(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
/* c = a OR b (two complement) */
-MP_DEPRECATED(mp_or) mp_err mp_tc_or(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
/* c = a AND b (two complement) */
-MP_DEPRECATED(mp_and) mp_err mp_tc_and(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
/* b = ~a (bitwise not, two complement) */
mp_err mp_complement(const mp_int *a, mp_int *b) MP_WUR;
/* right shift with sign extension */
-MP_DEPRECATED(mp_signed_rsh) mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c) MP_WUR;
mp_err mp_signed_rsh(const mp_int *a, int b, mp_int *c) MP_WUR;
/* ---> Basic arithmetic <--- */
@@ -532,8 +451,6 @@ mp_err mp_lcm(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
* returns error if a < 0 and b is even
*/
mp_err mp_root_u32(const mp_int *a, uint32_t b, mp_int *c) MP_WUR;
-MP_DEPRECATED(mp_root_u32) mp_err mp_n_root(const mp_int *a, mp_digit b, mp_int *c) MP_WUR;
-MP_DEPRECATED(mp_root_u32) mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) MP_WUR;
/* special sqrt algo */
mp_err mp_sqrt(const mp_int *arg, mp_int *ret) MP_WUR;
@@ -544,9 +461,6 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) MP_WU
/* is number a square? */
mp_err mp_is_square(const mp_int *arg, mp_bool *ret) MP_WUR;
-/* computes the jacobi c = (a | n) (or Legendre if b is prime) */
-MP_DEPRECATED(mp_kronecker) mp_err mp_jacobi(const mp_int *a, const mp_int *n, int *c) MP_WUR;
-
/* computes the Kronecker symbol c = (a | p) (like jacobi() but with {a,p} in Z */
mp_err mp_kronecker(const mp_int *a, const mp_int *p, int *c) MP_WUR;
@@ -603,20 +517,6 @@ mp_err mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y)
/* ---> Primes <--- */
-/* number of primes */
-#ifdef MP_8BIT
-# define PRIVATE_MP_PRIME_TAB_SIZE 31
-#else
-# define PRIVATE_MP_PRIME_TAB_SIZE 256
-#endif
-#define PRIME_SIZE (MP_DEPRECATED_PRAGMA("PRIME_SIZE has been made internal") PRIVATE_MP_PRIME_TAB_SIZE)
-
-/* table of first PRIME_SIZE primes */
-MP_DEPRECATED(internal) extern const mp_digit ltm_prime_tab[PRIVATE_MP_PRIME_TAB_SIZE];
-
-/* result=1 if a is divisible by one of the first PRIME_SIZE primes */
-MP_DEPRECATED(mp_prime_is_prime) mp_err mp_prime_is_divisible(const mp_int *a, mp_bool *result) MP_WUR;
-
/* performs one Fermat test of "a" using base "b".
* Sets result to 0 if composite or 1 if probable prime
*/
@@ -665,17 +565,6 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result) MP_WUR;
*/
mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style) MP_WUR;
-/* makes a truly random prime of a given size (bytes),
- * call with bbs = 1 if you want it to be congruent to 3 mod 4
- *
- * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
- * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
- * so it can be NULL
- *
- * The prime generated will be larger than 2^(8*size).
- */
-#define mp_prime_random(a, t, size, bbs, cb, dat) (MP_DEPRECATED_PRAGMA("mp_prime_random has been deprecated, use mp_prime_rand instead") mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?MP_PRIME_BBS:0, cb, dat))
-
/* makes a truly random prime of a given size (bits),
*
* Flags are as follows:
@@ -689,8 +578,6 @@ mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style) MP_WUR;
* so it can be NULL
*
*/
-MP_DEPRECATED(mp_prime_rand) mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags,
- private_mp_prime_callback cb, void *dat) MP_WUR;
mp_err mp_prime_rand(mp_int *a, int t, int size, int flags) MP_WUR;
/* Integer logarithm to integer base */
@@ -698,23 +585,10 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c) MP_WUR;
/* c = a**b */
mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c) MP_WUR;
-MP_DEPRECATED(mp_expt_u32) mp_err mp_expt_d(const mp_int *a, mp_digit b, mp_int *c) MP_WUR;
-MP_DEPRECATED(mp_expt_u32) mp_err mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) MP_WUR;
/* ---> radix conversion <--- */
int mp_count_bits(const mp_int *a) MP_WUR;
-
-MP_DEPRECATED(mp_ubin_size) int mp_unsigned_bin_size(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_from_ubin) mp_err mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c) MP_WUR;
-MP_DEPRECATED(mp_to_ubin) mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b) MP_WUR;
-MP_DEPRECATED(mp_to_ubin) mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen) MP_WUR;
-
-MP_DEPRECATED(mp_sbin_size) int mp_signed_bin_size(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_from_sbin) mp_err mp_read_signed_bin(mp_int *a, const unsigned char *b, int c) MP_WUR;
-MP_DEPRECATED(mp_to_sbin) mp_err mp_to_signed_bin(const mp_int *a, unsigned char *b) MP_WUR;
-MP_DEPRECATED(mp_to_sbin) mp_err mp_to_signed_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen) MP_WUR;
-
size_t mp_ubin_size(const mp_int *a) MP_WUR;
mp_err mp_from_ubin(mp_int *a, const unsigned char *buf, size_t size) MP_WUR;
mp_err mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) MP_WUR;
@@ -724,8 +598,6 @@ mp_err mp_from_sbin(mp_int *a, const unsigned char *buf, size_t size) MP_WUR;
mp_err mp_to_sbin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written) MP_WUR;
mp_err mp_read_radix(mp_int *a, const char *str, int radix) MP_WUR;
-MP_DEPRECATED(mp_to_radix) mp_err mp_toradix(const mp_int *a, char *str, int radix) MP_WUR;
-MP_DEPRECATED(mp_to_radix) mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) MP_WUR;
mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix) MP_WUR;
mp_err mp_radix_size(const mp_int *a, int radix, int *size) MP_WUR;
@@ -734,18 +606,6 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream) MP_WUR;
mp_err mp_fwrite(const mp_int *a, int radix, FILE *stream) MP_WUR;
#endif
-#define mp_read_raw(mp, str, len) (MP_DEPRECATED_PRAGMA("replaced by mp_read_signed_bin") mp_read_signed_bin((mp), (str), (len)))
-#define mp_raw_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_signed_bin_size") mp_signed_bin_size(mp))
-#define mp_toraw(mp, str) (MP_DEPRECATED_PRAGMA("replaced by mp_to_signed_bin") mp_to_signed_bin((mp), (str)))
-#define mp_read_mag(mp, str, len) (MP_DEPRECATED_PRAGMA("replaced by mp_read_unsigned_bin") mp_read_unsigned_bin((mp), (str), (len))
-#define mp_mag_size(mp) (MP_DEPRECATED_PRAGMA("replaced by mp_unsigned_bin_size") mp_unsigned_bin_size(mp))
-#define mp_tomag(mp, str) (MP_DEPRECATED_PRAGMA("replaced by mp_to_unsigned_bin") mp_to_unsigned_bin((mp), (str)))
-
-#define mp_tobinary(M, S) (MP_DEPRECATED_PRAGMA("replaced by mp_to_binary") mp_toradix((M), (S), 2))
-#define mp_tooctal(M, S) (MP_DEPRECATED_PRAGMA("replaced by mp_to_octal") mp_toradix((M), (S), 8))
-#define mp_todecimal(M, S) (MP_DEPRECATED_PRAGMA("replaced by mp_to_decimal") mp_toradix((M), (S), 10))
-#define mp_tohex(M, S) (MP_DEPRECATED_PRAGMA("replaced by mp_to_hex") mp_toradix((M), (S), 16))
-
#define mp_to_binary(M, S, N) mp_to_radix((M), (S), (N), NULL, 2)
#define mp_to_octal(M, S, N) mp_to_radix((M), (S), (N), NULL, 8)
#define mp_to_decimal(M, S, N) mp_to_radix((M), (S), (N), NULL, 10)
diff --git a/tommath_class.h b/tommath_class.h
index 52ba585..b3c5dbd 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -12,7 +12,6 @@
#define LTM1
#if defined(LTM_ALL)
# define BN_CUTOFFS_C
-# define BN_DEPRECATED_C
# define BN_MP_2EXPT_C
# define BN_MP_ABS_C
# define BN_MP_ADD_C
@@ -173,93 +172,6 @@
#if defined(BN_CUTOFFS_C)
#endif
-#if defined(BN_DEPRECATED_C)
-# define BN_FAST_MP_INVMOD_C
-# define BN_FAST_MP_MONTGOMERY_REDUCE_C
-# define BN_FAST_S_MP_MUL_DIGS_C
-# define BN_FAST_S_MP_MUL_HIGH_DIGS_C
-# define BN_FAST_S_MP_SQR_C
-# define BN_MP_AND_C
-# define BN_MP_BALANCE_MUL_C
-# define BN_MP_CMP_D_C
-# define BN_MP_EXPORT_C
-# define BN_MP_EXPTMOD_FAST_C
-# define BN_MP_EXPT_D_C
-# define BN_MP_EXPT_D_EX_C
-# define BN_MP_EXPT_U32_C
-# define BN_MP_FROM_SBIN_C
-# define BN_MP_FROM_UBIN_C
-# define BN_MP_GET_BIT_C
-# define BN_MP_GET_INT_C
-# define BN_MP_GET_LONG_C
-# define BN_MP_GET_LONG_LONG_C
-# define BN_MP_GET_MAG_U32_C
-# define BN_MP_GET_MAG_ULL_C
-# define BN_MP_GET_MAG_UL_C
-# define BN_MP_IMPORT_C
-# define BN_MP_INIT_SET_INT_C
-# define BN_MP_INIT_U32_C
-# define BN_MP_INVMOD_SLOW_C
-# define BN_MP_JACOBI_C
-# define BN_MP_KARATSUBA_MUL_C
-# define BN_MP_KARATSUBA_SQR_C
-# define BN_MP_KRONECKER_C
-# define BN_MP_N_ROOT_C
-# define BN_MP_N_ROOT_EX_C
-# define BN_MP_OR_C
-# define BN_MP_PACK_C
-# define BN_MP_PRIME_IS_DIVISIBLE_C
-# define BN_MP_PRIME_RANDOM_EX_C
-# define BN_MP_RAND_DIGIT_C
-# define BN_MP_READ_SIGNED_BIN_C
-# define BN_MP_READ_UNSIGNED_BIN_C
-# define BN_MP_ROOT_U32_C
-# define BN_MP_SBIN_SIZE_C
-# define BN_MP_SET_INT_C
-# define BN_MP_SET_LONG_C
-# define BN_MP_SET_LONG_LONG_C
-# define BN_MP_SET_U32_C
-# define BN_MP_SET_U64_C
-# define BN_MP_SIGNED_BIN_SIZE_C
-# define BN_MP_SIGNED_RSH_C
-# define BN_MP_TC_AND_C
-# define BN_MP_TC_DIV_2D_C
-# define BN_MP_TC_OR_C
-# define BN_MP_TC_XOR_C
-# define BN_MP_TOOM_MUL_C
-# define BN_MP_TOOM_SQR_C
-# define BN_MP_TORADIX_C
-# define BN_MP_TORADIX_N_C
-# define BN_MP_TO_RADIX_C
-# define BN_MP_TO_SBIN_C
-# define BN_MP_TO_SIGNED_BIN_C
-# define BN_MP_TO_SIGNED_BIN_N_C
-# define BN_MP_TO_UBIN_C
-# define BN_MP_TO_UNSIGNED_BIN_C
-# define BN_MP_TO_UNSIGNED_BIN_N_C
-# define BN_MP_UBIN_SIZE_C
-# define BN_MP_UNPACK_C
-# define BN_MP_UNSIGNED_BIN_SIZE_C
-# define BN_MP_XOR_C
-# define BN_S_MP_BALANCE_MUL_C
-# define BN_S_MP_EXPTMOD_FAST_C
-# define BN_S_MP_GET_BIT_C
-# define BN_S_MP_INVMOD_FAST_C
-# define BN_S_MP_INVMOD_SLOW_C
-# define BN_S_MP_KARATSUBA_MUL_C
-# define BN_S_MP_KARATSUBA_SQR_C
-# define BN_S_MP_MONTGOMERY_REDUCE_FAST_C
-# define BN_S_MP_MUL_DIGS_FAST_C
-# define BN_S_MP_MUL_HIGH_DIGS_FAST_C
-# define BN_S_MP_PRIME_IS_DIVISIBLE_C
-# define BN_S_MP_PRIME_RANDOM_EX_C
-# define BN_S_MP_RAND_SOURCE_C
-# define BN_S_MP_REVERSE_C
-# define BN_S_MP_SQR_FAST_C
-# define BN_S_MP_TOOM_MUL_C
-# define BN_S_MP_TOOM_SQR_C
-#endif
-
#if defined(BN_MP_2EXPT_C)
# define BN_MP_GROW_C
# define BN_MP_ZERO_C
diff --git a/tommath_private.h b/tommath_private.h
index 7c167a5..3f4b23a 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -6,6 +6,7 @@
#include "tommath.h"
#include "tommath_class.h"
+#include <limits.h>
/*
* Private symbols
@@ -146,7 +147,6 @@ extern void MP_FREE(void *mem, size_t size);
#define MP_HAS(x) (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
/* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
-#undef mp_word
typedef private_mp_word mp_word;
#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
@@ -163,14 +163,18 @@ typedef private_mp_word mp_word;
#define MP_SIZEOF_BITS(type) ((size_t)CHAR_BIT * sizeof(type))
#define MP_MAXFAST (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
-/* TODO: Remove PRIVATE_MP_WARRAY as soon as deprecated MP_WARRAY is removed from tommath.h */
-#undef MP_WARRAY
-#define MP_WARRAY PRIVATE_MP_WARRAY
+#define MP_WARRAY (1 << ((MP_SIZEOF_BITS(mp_word) - (2 * MP_DIGIT_BIT)) + 1))
-/* TODO: Remove PRIVATE_MP_PREC as soon as deprecated MP_PREC is removed from tommath.h */
-#ifdef PRIVATE_MP_PREC
-# undef MP_PREC
-# define MP_PREC PRIVATE_MP_PREC
+
+/* default precision */
+#ifndef MP_PREC
+# ifndef MP_LOW_MEM
+# define MP_PREC 32 /* default digits of precision */
+# elif defined(MP_8BIT)
+# define MP_PREC 16 /* default digits of precision */
+# else
+# define MP_PREC 8 /* default digits of precision */
+# endif
#endif
/* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC */
@@ -202,7 +206,8 @@ MP_PRIVATE mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_dig
MP_PRIVATE mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
MP_PRIVATE mp_err s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode) MP_WUR;
MP_PRIVATE mp_err s_mp_rand_platform(void *p, size_t n) MP_WUR;
-MP_PRIVATE mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prime_callback cb, void *dat);
+typedef int mp_prime_callback(unsigned char *dst, int len, void *dat);
+MP_PRIVATE mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback cb, void *dat);
MP_PRIVATE void s_mp_reverse(unsigned char *s, size_t len);
MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
@@ -210,31 +215,17 @@ MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
-extern MP_PRIVATE const char *const mp_s_rmap;
-extern MP_PRIVATE const uint8_t mp_s_rmap_reverse[];
-extern MP_PRIVATE const size_t mp_s_rmap_reverse_sz;
-extern MP_PRIVATE const mp_digit *s_mp_prime_tab;
+#define MP_RMAP_REVERSE_SIZE 88
+extern MP_PRIVATE const char s_mp_rmap[];
+extern MP_PRIVATE const uint8_t s_mp_rmap_reverse[];
+extern MP_PRIVATE const mp_digit s_mp_prime_tab[];
-/* deprecated functions */
-MP_DEPRECATED(s_mp_invmod_fast) mp_err fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c);
-MP_DEPRECATED(s_mp_montgomery_reduce_fast) mp_err fast_mp_montgomery_reduce(mp_int *x, const mp_int *n,
- mp_digit rho);
-MP_DEPRECATED(s_mp_mul_digs_fast) mp_err fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c,
- int digs);
-MP_DEPRECATED(s_mp_mul_high_digs_fast) mp_err fast_s_mp_mul_high_digs(const mp_int *a, const mp_int *b,
- mp_int *c,
- int digs);
-MP_DEPRECATED(s_mp_sqr_fast) mp_err fast_s_mp_sqr(const mp_int *a, mp_int *b);
-MP_DEPRECATED(s_mp_balance_mul) mp_err mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c);
-MP_DEPRECATED(s_mp_exptmod_fast) mp_err mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P,
- mp_int *Y,
- int redmode);
-MP_DEPRECATED(s_mp_invmod_slow) mp_err mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c);
-MP_DEPRECATED(s_mp_karatsuba_mul) mp_err mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c);
-MP_DEPRECATED(s_mp_karatsuba_sqr) mp_err mp_karatsuba_sqr(const mp_int *a, mp_int *b);
-MP_DEPRECATED(s_mp_toom_mul) mp_err mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c);
-MP_DEPRECATED(s_mp_toom_sqr) mp_err mp_toom_sqr(const mp_int *a, mp_int *b);
-MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
+/* number of primes */
+#ifdef MP_8BIT
+# define MP_PRIME_TAB_SIZE 31
+#else
+# define MP_PRIME_TAB_SIZE 256
+#endif
#define MP_GET_ENDIANNESS(x) \
do{\