apply a series of simplifications * this is the final commit of a series of simplifications, containing only the regenerated files and the explanation in the commit message * This is in preparation of the size_t change/a potential representation change to use full width as in tfm, if a (partial?) merge with tfm is desired. These changes have their own merits however. * Remove obfuscating tmpx digit pointers (fewer variables, it is more obvious what is being manipulated) * Reduce scope of variables where possible * Stricter error handling/checking (for example handling in karatsuba was broken) * In some cases the result was written even in the case of an error (e.g. s_mp_is_divisible). This will hide bugs, since the user should check the return value (enforced by MP_WUR). Furthermore if the user accesses the non-initialized result, valgrind will complain for example. Global static analysis like coverity will also detect the issue. Therefore this improves the status quo. * Introduce generic, private MP_EXCH macro which can be used to swap values. * Introduce s_mp_copy_digs/s_mp_zero_digs/s_mp_zero_buf * Some control flow simplifications, e.g, loops instead of goto * Renamings of variables/labels for consistency * Renamings of mul/sqr functions for more consistency, e.g., comba instead of fast suffix * I didn't read through some very complex functions. They are so complex, I am too afraid and lazy to touch them. Maybe someone resposible wants to simplify them if possible. Hint... Hint... - mp_prime_strong_lucas_selfridge.c - s_mp_exptmod.c - s_mp_exptmod_fast.c
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
diff --git a/helper.pl b/helper.pl
index 223c7ef..2378cce 100755
--- a/helper.pl
+++ b/helper.pl
@@ -57,9 +57,8 @@ sub check_source {
push @{$troubles->{unwanted_calloc}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bcalloc\s*\(/;
push @{$troubles->{unwanted_free}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bfree\s*\(/;
# and we probably want to also avoid the following
- push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/;
- push @{$troubles->{unwanted_memset}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemset\s*\(/;
- push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/;
+ #push @{$troubles->{unwanted_memcpy}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcpy\s*\(/;
+ #push @{$troubles->{unwanted_memset}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemset\s*\(/;
push @{$troubles->{unwanted_memmove}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemmove\s*\(/;
push @{$troubles->{unwanted_memcmp}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bmemcmp\s*\(/;
push @{$troubles->{unwanted_strcmp}}, $lineno if $file =~ /^[^\/]+\.c$/ && $l =~ /\bstrcmp\s*\(/;
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 116275e..07c784b 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -577,10 +577,6 @@
>
</File>
<File
- RelativePath="mp_mod_d.c"
- >
- </File>
- <File
RelativePath="mp_montgomery_calc_normalization.c"
>
</File>
@@ -833,7 +829,7 @@
>
</File>
<File
- RelativePath="s_mp_balance_mul.c"
+ RelativePath="s_mp_copy_digs.c"
>
</File>
<File
@@ -861,51 +857,55 @@
>
</File>
<File
- RelativePath="s_mp_invmod_fast.c"
+ RelativePath="s_mp_invmod.c"
>
</File>
<File
- RelativePath="s_mp_invmod_slow.c"
+ RelativePath="s_mp_invmod_odd.c"
>
</File>
<File
- RelativePath="s_mp_karatsuba_mul.c"
+ RelativePath="s_mp_log.c"
>
</File>
<File
- RelativePath="s_mp_karatsuba_sqr.c"
+ RelativePath="s_mp_log_d.c"
>
</File>
<File
- RelativePath="s_mp_log.c"
+ RelativePath="s_mp_log_pow2.c"
>
</File>
<File
- RelativePath="s_mp_log_d.c"
+ RelativePath="s_mp_montgomery_reduce_comba.c"
>
</File>
<File
- RelativePath="s_mp_log_pow2.c"
+ RelativePath="s_mp_mul.c"
>
</File>
<File
- RelativePath="s_mp_montgomery_reduce_fast.c"
+ RelativePath="s_mp_mul_balance.c"
>
</File>
<File
- RelativePath="s_mp_mul_digs.c"
+ RelativePath="s_mp_mul_comba.c"
>
</File>
<File
- RelativePath="s_mp_mul_digs_fast.c"
+ RelativePath="s_mp_mul_high.c"
>
</File>
<File
- RelativePath="s_mp_mul_high_digs.c"
+ RelativePath="s_mp_mul_high_comba.c"
>
</File>
<File
- RelativePath="s_mp_mul_high_digs_fast.c"
+ RelativePath="s_mp_mul_karatsuba.c"
+ >
+ </File>
+ <File
+ RelativePath="s_mp_mul_toom.c"
>
</File>
<File
@@ -925,7 +925,15 @@
>
</File>
<File
- RelativePath="s_mp_sqr_fast.c"
+ RelativePath="s_mp_sqr_comba.c"
+ >
+ </File>
+ <File
+ RelativePath="s_mp_sqr_karatsuba.c"
+ >
+ </File>
+ <File
+ RelativePath="s_mp_sqr_toom.c"
>
</File>
<File
@@ -933,11 +941,11 @@
>
</File>
<File
- RelativePath="s_mp_toom_mul.c"
+ RelativePath="s_mp_zero_buf.c"
>
</File>
<File
- RelativePath="s_mp_toom_sqr.c"
+ RelativePath="s_mp_zero_digs.c"
>
</File>
<File
diff --git a/makefile b/makefile
index cb7ba21..4045390 100644
--- a/makefile
+++ b/makefile
@@ -34,22 +34,22 @@ mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp
mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_mod_d.o mp_montgomery_calc_normalization.o \
-mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o \
-mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o \
-mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o \
-mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o \
-mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
-mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
-mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o \
-mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o \
-mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \
-mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_balance_mul.o s_mp_div_recursive.o s_mp_div_school.o \
-s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod_fast.o s_mp_invmod_slow.o \
-s_mp_karatsuba_mul.o s_mp_karatsuba_sqr.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
-s_mp_montgomery_reduce_fast.o s_mp_mul_digs.o s_mp_mul_digs_fast.o s_mp_mul_high_digs.o \
-s_mp_mul_high_digs_fast.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o \
-s_mp_sqr_fast.o s_mp_sub.o s_mp_toom_mul.o s_mp_toom_sqr.o
+mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
+mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
+mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
+mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
+mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o mp_rand.o \
+mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o \
+mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o \
+mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o \
+mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o \
+mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o \
+s_mp_add.o s_mp_copy_digs.o s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o \
+s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
+s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \
+s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o \
+s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
+s_mp_zero_buf.o s_mp_zero_digs.o
#END_INS
diff --git a/makefile.mingw b/makefile.mingw
index 08b8e96..c597143 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -37,22 +37,22 @@ mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp
mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_mod_d.o mp_montgomery_calc_normalization.o \
-mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o \
-mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o \
-mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o \
-mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o \
-mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
-mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
-mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o \
-mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o \
-mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \
-mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_balance_mul.o s_mp_div_recursive.o s_mp_div_school.o \
-s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod_fast.o s_mp_invmod_slow.o \
-s_mp_karatsuba_mul.o s_mp_karatsuba_sqr.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
-s_mp_montgomery_reduce_fast.o s_mp_mul_digs.o s_mp_mul_digs_fast.o s_mp_mul_high_digs.o \
-s_mp_mul_high_digs_fast.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o \
-s_mp_sqr_fast.o s_mp_sub.o s_mp_toom_mul.o s_mp_toom_sqr.o
+mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
+mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
+mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
+mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
+mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o mp_rand.o \
+mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o \
+mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o \
+mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o \
+mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o \
+mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o \
+s_mp_add.o s_mp_copy_digs.o s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o \
+s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
+s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \
+s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o \
+s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
+s_mp_zero_buf.o s_mp_zero_digs.o
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
diff --git a/makefile.msvc b/makefile.msvc
index 058d5ce..0670b2b 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -29,22 +29,22 @@ mp_from_ubin.obj mp_fwrite.obj mp_gcd.obj mp_get_double.obj mp_get_i32.obj mp_ge
mp_get_mag_u32.obj mp_get_mag_u64.obj mp_get_mag_ul.obj mp_get_mag_ull.obj mp_grow.obj mp_init.obj mp_init_copy.obj \
mp_init_i32.obj mp_init_i64.obj mp_init_l.obj mp_init_ll.obj mp_init_multi.obj mp_init_set.obj mp_init_size.obj \
mp_init_u32.obj mp_init_u64.obj mp_init_ul.obj mp_init_ull.obj mp_invmod.obj mp_is_square.obj mp_kronecker.obj mp_lcm.obj \
-mp_log_u32.obj mp_lshd.obj mp_mod.obj mp_mod_2d.obj mp_mod_d.obj mp_montgomery_calc_normalization.obj \
-mp_montgomery_reduce.obj mp_montgomery_setup.obj mp_mul.obj mp_mul_2.obj mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj \
-mp_neg.obj mp_or.obj mp_pack.obj mp_pack_count.obj mp_prime_fermat.obj mp_prime_frobenius_underwood.obj \
-mp_prime_is_prime.obj mp_prime_miller_rabin.obj mp_prime_next_prime.obj mp_prime_rabin_miller_trials.obj \
-mp_prime_rand.obj mp_prime_strong_lucas_selfridge.obj mp_prime_tab.obj mp_radix_size.obj mp_radix_smap.obj \
-mp_rand.obj mp_read_radix.obj mp_reduce.obj mp_reduce_2k.obj mp_reduce_2k_l.obj mp_reduce_2k_setup.obj \
-mp_reduce_2k_setup_l.obj mp_reduce_is_2k.obj mp_reduce_is_2k_l.obj mp_reduce_setup.obj mp_root_u32.obj mp_rshd.obj \
-mp_sbin_size.obj mp_set.obj mp_set_double.obj mp_set_i32.obj mp_set_i64.obj mp_set_l.obj mp_set_ll.obj mp_set_u32.obj \
-mp_set_u64.obj mp_set_ul.obj mp_set_ull.obj mp_shrink.obj mp_signed_rsh.obj mp_sqr.obj mp_sqrmod.obj mp_sqrt.obj \
-mp_sqrtmod_prime.obj mp_sub.obj mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj mp_to_ubin.obj mp_ubin_size.obj \
-mp_unpack.obj mp_xor.obj mp_zero.obj s_mp_add.obj s_mp_balance_mul.obj s_mp_div_recursive.obj s_mp_div_school.obj \
-s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_mp_get_bit.obj s_mp_invmod_fast.obj s_mp_invmod_slow.obj \
-s_mp_karatsuba_mul.obj s_mp_karatsuba_sqr.obj s_mp_log.obj s_mp_log_d.obj s_mp_log_pow2.obj \
-s_mp_montgomery_reduce_fast.obj s_mp_mul_digs.obj s_mp_mul_digs_fast.obj s_mp_mul_high_digs.obj \
-s_mp_mul_high_digs_fast.obj s_mp_prime_is_divisible.obj s_mp_rand_jenkins.obj s_mp_rand_platform.obj s_mp_sqr.obj \
-s_mp_sqr_fast.obj s_mp_sub.obj s_mp_toom_mul.obj s_mp_toom_sqr.obj
+mp_log_u32.obj mp_lshd.obj mp_mod.obj mp_mod_2d.obj mp_montgomery_calc_normalization.obj mp_montgomery_reduce.obj \
+mp_montgomery_setup.obj mp_mul.obj mp_mul_2.obj mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj mp_neg.obj mp_or.obj mp_pack.obj \
+mp_pack_count.obj mp_prime_fermat.obj mp_prime_frobenius_underwood.obj mp_prime_is_prime.obj \
+mp_prime_miller_rabin.obj mp_prime_next_prime.obj mp_prime_rabin_miller_trials.obj mp_prime_rand.obj \
+mp_prime_strong_lucas_selfridge.obj mp_prime_tab.obj mp_radix_size.obj mp_radix_smap.obj mp_rand.obj \
+mp_read_radix.obj mp_reduce.obj mp_reduce_2k.obj mp_reduce_2k_l.obj mp_reduce_2k_setup.obj mp_reduce_2k_setup_l.obj \
+mp_reduce_is_2k.obj mp_reduce_is_2k_l.obj mp_reduce_setup.obj mp_root_u32.obj mp_rshd.obj mp_sbin_size.obj mp_set.obj \
+mp_set_double.obj mp_set_i32.obj mp_set_i64.obj mp_set_l.obj mp_set_ll.obj mp_set_u32.obj mp_set_u64.obj mp_set_ul.obj \
+mp_set_ull.obj mp_shrink.obj mp_signed_rsh.obj mp_sqr.obj mp_sqrmod.obj mp_sqrt.obj mp_sqrtmod_prime.obj mp_sub.obj \
+mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj mp_to_ubin.obj mp_ubin_size.obj mp_unpack.obj mp_xor.obj mp_zero.obj \
+s_mp_add.obj s_mp_copy_digs.obj s_mp_div_recursive.obj s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj \
+s_mp_exptmod_fast.obj s_mp_get_bit.obj s_mp_invmod.obj s_mp_invmod_odd.obj s_mp_log.obj s_mp_log_d.obj s_mp_log_pow2.obj \
+s_mp_montgomery_reduce_comba.obj s_mp_mul.obj s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj \
+s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj s_mp_mul_toom.obj s_mp_prime_is_divisible.obj s_mp_rand_jenkins.obj \
+s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj s_mp_sqr_karatsuba.obj s_mp_sqr_toom.obj s_mp_sub.obj \
+s_mp_zero_buf.obj s_mp_zero_digs.obj
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
diff --git a/makefile.shared b/makefile.shared
index 51b0ee4..9dd34bb 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -31,22 +31,22 @@ mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp
mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_mod_d.o mp_montgomery_calc_normalization.o \
-mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o \
-mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o \
-mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o \
-mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o \
-mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
-mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
-mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o \
-mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o \
-mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \
-mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_balance_mul.o s_mp_div_recursive.o s_mp_div_school.o \
-s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod_fast.o s_mp_invmod_slow.o \
-s_mp_karatsuba_mul.o s_mp_karatsuba_sqr.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
-s_mp_montgomery_reduce_fast.o s_mp_mul_digs.o s_mp_mul_digs_fast.o s_mp_mul_high_digs.o \
-s_mp_mul_high_digs_fast.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o \
-s_mp_sqr_fast.o s_mp_sub.o s_mp_toom_mul.o s_mp_toom_sqr.o
+mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
+mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
+mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
+mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
+mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o mp_rand.o \
+mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o \
+mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o \
+mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o \
+mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o \
+mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o \
+s_mp_add.o s_mp_copy_digs.o s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o \
+s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
+s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \
+s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o \
+s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
+s_mp_zero_buf.o s_mp_zero_digs.o
#END_INS
diff --git a/makefile.unix b/makefile.unix
index 5fff6b9..33a3829 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -38,22 +38,22 @@ mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp
mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_mod_d.o mp_montgomery_calc_normalization.o \
-mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o \
-mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o \
-mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o \
-mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o \
-mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
-mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
-mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o \
-mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o \
-mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \
-mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_balance_mul.o s_mp_div_recursive.o s_mp_div_school.o \
-s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod_fast.o s_mp_invmod_slow.o \
-s_mp_karatsuba_mul.o s_mp_karatsuba_sqr.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
-s_mp_montgomery_reduce_fast.o s_mp_mul_digs.o s_mp_mul_digs_fast.o s_mp_mul_high_digs.o \
-s_mp_mul_high_digs_fast.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o \
-s_mp_sqr_fast.o s_mp_sub.o s_mp_toom_mul.o s_mp_toom_sqr.o
+mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
+mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
+mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
+mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
+mp_prime_strong_lucas_selfridge.o mp_prime_tab.o mp_radix_size.o mp_radix_smap.o mp_rand.o \
+mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o \
+mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o \
+mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o \
+mp_set_ull.o mp_shrink.o mp_signed_rsh.o mp_sqr.o mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o \
+mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o \
+s_mp_add.o s_mp_copy_digs.o s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o \
+s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o \
+s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \
+s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_rand_jenkins.o \
+s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
+s_mp_zero_buf.o s_mp_zero_digs.o
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
diff --git a/tommath.def b/tommath.def
index db0aba4..4d81e34 100644
--- a/tommath.def
+++ b/tommath.def
@@ -72,7 +72,6 @@ EXPORTS
mp_lshd
mp_mod
mp_mod_2d
- mp_mod_d
mp_montgomery_calc_normalization
mp_montgomery_reduce
mp_montgomery_setup
diff --git a/tommath_class.h b/tommath_class.h
index 3a3d549..2a5380a 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -77,7 +77,6 @@
# define MP_LSHD_C
# define MP_MOD_C
# define MP_MOD_2D_C
-# define MP_MOD_D_C
# define MP_MONTGOMERY_CALC_NORMALIZATION_C
# define MP_MONTGOMERY_REDUCE_C
# define MP_MONTGOMERY_SETUP_C
@@ -141,33 +140,36 @@
# define MP_XOR_C
# define MP_ZERO_C
# define S_MP_ADD_C
-# define S_MP_BALANCE_MUL_C
+# define S_MP_COPY_DIGS_C
# define S_MP_DIV_RECURSIVE_C
# define S_MP_DIV_SCHOOL_C
# define S_MP_DIV_SMALL_C
# define S_MP_EXPTMOD_C
# define S_MP_EXPTMOD_FAST_C
# define S_MP_GET_BIT_C
-# define S_MP_INVMOD_FAST_C
-# define S_MP_INVMOD_SLOW_C
-# define S_MP_KARATSUBA_MUL_C
-# define S_MP_KARATSUBA_SQR_C
+# define S_MP_INVMOD_C
+# define S_MP_INVMOD_ODD_C
# define S_MP_LOG_C
# define S_MP_LOG_D_C
# define S_MP_LOG_POW2_C
-# define S_MP_MONTGOMERY_REDUCE_FAST_C
-# define S_MP_MUL_DIGS_C
-# define S_MP_MUL_DIGS_FAST_C
-# define S_MP_MUL_HIGH_DIGS_C
-# define S_MP_MUL_HIGH_DIGS_FAST_C
+# define S_MP_MONTGOMERY_REDUCE_COMBA_C
+# define S_MP_MUL_C
+# define S_MP_MUL_BALANCE_C
+# define S_MP_MUL_COMBA_C
+# define S_MP_MUL_HIGH_C
+# define S_MP_MUL_HIGH_COMBA_C
+# define S_MP_MUL_KARATSUBA_C
+# define S_MP_MUL_TOOM_C
# define S_MP_PRIME_IS_DIVISIBLE_C
# define S_MP_RAND_JENKINS_C
# define S_MP_RAND_PLATFORM_C
# define S_MP_SQR_C
-# define S_MP_SQR_FAST_C
+# define S_MP_SQR_COMBA_C
+# define S_MP_SQR_KARATSUBA_C
+# define S_MP_SQR_TOOM_C
# define S_MP_SUB_C
-# define S_MP_TOOM_MUL_C
-# define S_MP_TOOM_SQR_C
+# define S_MP_ZERO_BUF_C
+# define S_MP_ZERO_DIGS_C
#endif
#endif
#if defined(MP_2EXPT_C)
@@ -189,6 +191,7 @@
# define MP_CLAMP_C
# define MP_GROW_C
# define MP_SUB_D_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_ADDMOD_C)
@@ -207,6 +210,7 @@
#endif
#if defined(MP_CLEAR_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_CLEAR_MULTI_C)
@@ -227,12 +231,13 @@
#endif
#if defined(MP_COMPLEMENT_C)
-# define MP_NEG_C
# define MP_SUB_D_C
#endif
#if defined(MP_COPY_C)
# define MP_GROW_C
+# define S_MP_COPY_DIGS_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_COUNT_BITS_C)
@@ -253,6 +258,7 @@
#if defined(MP_DIV_2_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_DIV_2D_C)
@@ -260,7 +266,6 @@
# define MP_COPY_C
# define MP_MOD_2D_C
# define MP_RSHD_C
-# define MP_ZERO_C
#endif
#if defined(MP_DIV_3_C)
@@ -288,6 +293,7 @@
# define MP_CMP_MAG_C
# define MP_GROW_C
# define S_MP_SUB_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_DR_SETUP_C)
@@ -351,6 +357,7 @@
#if defined(MP_FWRITE_C)
# define MP_RADIX_SIZE_C
# define MP_TO_RADIX_C
+# define S_MP_ZERO_BUF_C
#endif
#if defined(MP_GCD_C)
@@ -397,6 +404,7 @@
#endif
#if defined(MP_GROW_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_INIT_C)
@@ -463,17 +471,17 @@
#if defined(MP_INVMOD_C)
# define MP_CMP_D_C
-# define S_MP_INVMOD_FAST_C
-# define S_MP_INVMOD_SLOW_C
+# define S_MP_INVMOD_C
+# define S_MP_INVMOD_ODD_C
#endif
#if defined(MP_IS_SQUARE_C)
# define MP_CLEAR_C
# define MP_CMP_MAG_C
+# define MP_DIV_D_C
# define MP_GET_I32_C
# define MP_INIT_U32_C
# define MP_MOD_C
-# define MP_MOD_D_C
# define MP_SQRT_C
# define MP_SQR_C
#endif
@@ -506,6 +514,7 @@
#if defined(MP_LSHD_C)
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_MOD_C)
@@ -520,10 +529,7 @@
# define MP_CLAMP_C
# define MP_COPY_C
# define MP_ZERO_C
-#endif
-
-#if defined(MP_MOD_D_C)
-# define MP_DIV_D_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_MONTGOMERY_CALC_NORMALIZATION_C)
@@ -540,7 +546,7 @@
# define MP_CMP_MAG_C
# define MP_GROW_C
# define MP_RSHD_C
-# define S_MP_MONTGOMERY_REDUCE_FAST_C
+# define S_MP_MONTGOMERY_REDUCE_COMBA_C
# define S_MP_SUB_C
#endif
@@ -548,15 +554,16 @@
#endif
#if defined(MP_MUL_C)
-# define S_MP_BALANCE_MUL_C
-# define S_MP_KARATSUBA_MUL_C
-# define S_MP_MUL_DIGS_C
-# define S_MP_MUL_DIGS_FAST_C
-# define S_MP_TOOM_MUL_C
+# define S_MP_MUL_BALANCE_C
+# define S_MP_MUL_C
+# define S_MP_MUL_COMBA_C
+# define S_MP_MUL_KARATSUBA_C
+# define S_MP_MUL_TOOM_C
#endif
#if defined(MP_MUL_2_C)
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_MUL_2D_C)
@@ -569,6 +576,7 @@
#if defined(MP_MUL_D_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_MULMOD_C)
@@ -660,8 +668,8 @@
# define MP_ADD_D_C
# define MP_CLEAR_C
# define MP_CMP_D_C
+# define MP_DIV_D_C
# define MP_INIT_C
-# define MP_MOD_D_C
# define MP_PRIME_IS_PRIME_C
# define MP_SET_C
# define MP_SUB_D_C
@@ -678,6 +686,7 @@
# define MP_PRIME_IS_PRIME_C
# define MP_SUB_D_C
# define S_MP_RAND_SOURCE_C
+# define S_MP_ZERO_BUF_C
#endif
#if defined(MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
@@ -744,9 +753,9 @@
# define MP_RSHD_C
# define MP_SET_C
# define MP_SUB_C
-# define S_MP_MUL_DIGS_C
-# define S_MP_MUL_HIGH_DIGS_C
-# define S_MP_MUL_HIGH_DIGS_FAST_C
+# define S_MP_MUL_C
+# define S_MP_MUL_HIGH_C
+# define S_MP_MUL_HIGH_COMBA_C
# define S_MP_SUB_C
#endif
@@ -820,6 +829,7 @@
#if defined(MP_RSHD_C)
# define MP_ZERO_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SBIN_SIZE_C)
@@ -827,6 +837,7 @@
#endif
#if defined(MP_SET_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SET_DOUBLE_C)
@@ -852,15 +863,19 @@
#endif
#if defined(MP_SET_U32_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SET_U64_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SET_UL_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SET_ULL_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SHRINK_C)
@@ -873,10 +888,10 @@
#endif
#if defined(MP_SQR_C)
-# define S_MP_KARATSUBA_SQR_C
# define S_MP_SQR_C
-# define S_MP_SQR_FAST_C
-# define S_MP_TOOM_SQR_C
+# define S_MP_SQR_COMBA_C
+# define S_MP_SQR_KARATSUBA_C
+# define S_MP_SQR_TOOM_C
#endif
#if defined(MP_SQRMOD_C)
@@ -905,10 +920,10 @@
# define MP_CMP_D_C
# define MP_COPY_C
# define MP_DIV_2_C
+# define MP_DIV_D_C
# define MP_EXPTMOD_C
# define MP_INIT_MULTI_C
# define MP_KRONECKER_C
-# define MP_MOD_D_C
# define MP_MULMOD_C
# define MP_SET_C
# define MP_SQRMOD_C
@@ -926,6 +941,7 @@
# define MP_ADD_D_C
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(MP_SUBMOD_C)
@@ -969,23 +985,16 @@
#endif
#if defined(MP_ZERO_C)
+# define S_MP_ZERO_DIGS_C
#endif
#if defined(S_MP_ADD_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
-#if defined(S_MP_BALANCE_MUL_C)
-# define MP_ADD_C
-# define MP_CLAMP_C
-# define MP_CLEAR_C
-# define MP_CLEAR_MULTI_C
-# define MP_EXCH_C
-# define MP_INIT_MULTI_C
-# define MP_INIT_SIZE_C
-# define MP_LSHD_C
-# define MP_MUL_C
+#if defined(S_MP_COPY_DIGS_C)
#endif
#if defined(S_MP_DIV_RECURSIVE_C)
@@ -1075,13 +1084,13 @@
# define MP_REDUCE_2K_SETUP_C
# define MP_SET_C
# define MP_SQR_C
-# define S_MP_MONTGOMERY_REDUCE_FAST_C
+# define S_MP_MONTGOMERY_REDUCE_COMBA_C
#endif
#if defined(S_MP_GET_BIT_C)
#endif
-#if defined(S_MP_INVMOD_FAST_C)
+#if defined(S_MP_INVMOD_C)
# define MP_ADD_C
# define MP_CLEAR_MULTI_C
# define MP_CMP_C
@@ -1096,7 +1105,7 @@
# define MP_SUB_C
#endif
-#if defined(S_MP_INVMOD_SLOW_C)
+#if defined(S_MP_INVMOD_ODD_C)
# define MP_ADD_C
# define MP_CLEAR_MULTI_C
# define MP_CMP_C
@@ -1111,28 +1120,6 @@
# define MP_SUB_C
#endif
-#if defined(S_MP_KARATSUBA_MUL_C)
-# define MP_ADD_C
-# define MP_CLAMP_C
-# define MP_CLEAR_C
-# define MP_INIT_SIZE_C
-# define MP_LSHD_C
-# define MP_MUL_C
-# define S_MP_ADD_C
-# define S_MP_SUB_C
-#endif
-
-#if defined(S_MP_KARATSUBA_SQR_C)
-# define MP_ADD_C
-# define MP_CLAMP_C
-# define MP_CLEAR_C
-# define MP_INIT_SIZE_C
-# define MP_LSHD_C
-# define MP_SQR_C
-# define S_MP_ADD_C
-# define S_MP_SUB_C
-#endif
-
#if defined(S_MP_LOG_C)
# define MP_CLEAR_MULTI_C
# define MP_CMP_C
@@ -1153,41 +1140,86 @@
# define MP_COUNT_BITS_C
#endif
-#if defined(S_MP_MONTGOMERY_REDUCE_FAST_C)
+#if defined(S_MP_MONTGOMERY_REDUCE_COMBA_C)
# define MP_CLAMP_C
# define MP_CMP_MAG_C
# define MP_GROW_C
# define S_MP_SUB_C
+# define S_MP_ZERO_BUF_C
+# define S_MP_ZERO_DIGS_C
#endif
-#if defined(S_MP_MUL_DIGS_C)
+#if defined(S_MP_MUL_C)
# define MP_CLAMP_C
# define MP_CLEAR_C
# define MP_EXCH_C
# define MP_INIT_SIZE_C
-# define S_MP_MUL_DIGS_FAST_C
+# define S_MP_MUL_COMBA_C
#endif
-#if defined(S_MP_MUL_DIGS_FAST_C)
+#if defined(S_MP_MUL_BALANCE_C)
+# define MP_ADD_C
+# define MP_CLAMP_C
+# define MP_CLEAR_C
+# define MP_CLEAR_MULTI_C
+# define MP_EXCH_C
+# define MP_INIT_MULTI_C
+# define MP_INIT_SIZE_C
+# define MP_LSHD_C
+# define MP_MUL_C
+# define S_MP_COPY_DIGS_C
+#endif
+
+#if defined(S_MP_MUL_COMBA_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
-#if defined(S_MP_MUL_HIGH_DIGS_C)
+#if defined(S_MP_MUL_HIGH_C)
# define MP_CLAMP_C
# define MP_CLEAR_C
# define MP_EXCH_C
# define MP_INIT_SIZE_C
-# define S_MP_MUL_HIGH_DIGS_FAST_C
+# define S_MP_MUL_HIGH_COMBA_C
#endif
-#if defined(S_MP_MUL_HIGH_DIGS_FAST_C)
+#if defined(S_MP_MUL_HIGH_COMBA_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
+#endif
+
+#if defined(S_MP_MUL_KARATSUBA_C)
+# define MP_ADD_C
+# define MP_CLAMP_C
+# define MP_CLEAR_C
+# define MP_INIT_SIZE_C
+# define MP_LSHD_C
+# define MP_MUL_C
+# define S_MP_ADD_C
+# define S_MP_COPY_DIGS_C
+# define S_MP_SUB_C
+#endif
+
+#if defined(S_MP_MUL_TOOM_C)
+# define MP_ADD_C
+# define MP_CLAMP_C
+# define MP_CLEAR_C
+# define MP_CLEAR_MULTI_C
+# define MP_DIV_2_C
+# define MP_DIV_3_C
+# define MP_INIT_MULTI_C
+# define MP_INIT_SIZE_C
+# define MP_LSHD_C
+# define MP_MUL_2_C
+# define MP_MUL_C
+# define MP_SUB_C
+# define S_MP_COPY_DIGS_C
#endif
#if defined(S_MP_PRIME_IS_DIVISIBLE_C)
-# define MP_MOD_D_C
+# define MP_DIV_D_C
#endif
#if defined(S_MP_RAND_JENKINS_C)
@@ -1204,32 +1236,25 @@
# define MP_INIT_SIZE_C
#endif
-#if defined(S_MP_SQR_FAST_C)
+#if defined(S_MP_SQR_COMBA_C)
# define MP_CLAMP_C
# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
#endif
-#if defined(S_MP_SUB_C)
-# define MP_CLAMP_C
-# define MP_GROW_C
-#endif
-
-#if defined(S_MP_TOOM_MUL_C)
+#if defined(S_MP_SQR_KARATSUBA_C)
# define MP_ADD_C
# define MP_CLAMP_C
# define MP_CLEAR_C
-# define MP_CLEAR_MULTI_C
-# define MP_DIV_2_C
-# define MP_DIV_3_C
-# define MP_INIT_MULTI_C
# define MP_INIT_SIZE_C
# define MP_LSHD_C
-# define MP_MUL_2_C
-# define MP_MUL_C
-# define MP_SUB_C
+# define MP_SQR_C
+# define S_MP_ADD_C
+# define S_MP_COPY_DIGS_C
+# define S_MP_SUB_C
#endif
-#if defined(S_MP_TOOM_SQR_C)
+#if defined(S_MP_SQR_TOOM_C)
# define MP_ADD_C
# define MP_CLAMP_C
# define MP_CLEAR_C
@@ -1241,6 +1266,19 @@
# define MP_MUL_C
# define MP_SQR_C
# define MP_SUB_C
+# define S_MP_COPY_DIGS_C
+#endif
+
+#if defined(S_MP_SUB_C)
+# define MP_CLAMP_C
+# define MP_GROW_C
+# define S_MP_ZERO_DIGS_C
+#endif
+
+#if defined(S_MP_ZERO_BUF_C)
+#endif
+
+#if defined(S_MP_ZERO_DIGS_C)
#endif
#ifdef LTM_INSIDE