rename mul/sqr functions for consistency, comba instead of fast suffix

This commit is contained in:
Daniel Mendler 2019-10-30 17:26:27 +01:00
parent 3b710fbd7e
commit 5c335f8407
No known key found for this signature in database
GPG Key ID: D88ADB2A2693CA43
31 changed files with 193 additions and 194 deletions

View File

@ -37,8 +37,8 @@ static int mtest_opponent(void)
#ifndef MP_FIXED_CUTOFFS
/* force KARA and TOOM to enable despite cutoffs */
MP_KARATSUBA_SQR_CUTOFF = MP_KARATSUBA_MUL_CUTOFF = 8;
MP_TOOM_SQR_CUTOFF = MP_TOOM_MUL_CUTOFF = 16;
MP_SQR_KARATSUBA_CUTOFF = MP_MUL_KARATSUBA_CUTOFF = 8;
MP_SQR_TOOM_CUTOFF = MP_MUL_TOOM_CUTOFF = 16;
#endif
for (;;) {

View File

@ -1866,7 +1866,7 @@ LBL_ERR:
return EXIT_FAILURE;
}
static int test_s_mp_balance_mul(void)
static int test_s_mp_mul_balance(void)
{
mp_int a, b, c;
@ -1881,7 +1881,7 @@ static int test_s_mp_balance_mul(void)
DO(mp_read_radix(&a, na, 64));
DO(mp_read_radix(&b, nb, 64));
DO(s_mp_balance_mul(&a, &b, &c));
DO(s_mp_mul_balance(&a, &b, &c));
DO(mp_read_radix(&b, nc, 64));
@ -1896,18 +1896,18 @@ LBL_ERR:
return EXIT_FAILURE;
}
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
static int test_s_mp_karatsuba_mul(void)
#define s_mp_mul_full(a, b, c) s_mp_mul(a, b, c, (a)->used + (b)->used + 1)
static int test_s_mp_mul_karatsuba(void)
{
mp_int a, b, c, d;
int size;
DOR(mp_init_multi(&a, &b, &c, &d, NULL));
for (size = MP_KARATSUBA_MUL_CUTOFF; size < MP_KARATSUBA_MUL_CUTOFF + 20; size++) {
for (size = MP_MUL_KARATSUBA_CUTOFF; size < MP_MUL_KARATSUBA_CUTOFF + 20; size++) {
DO(mp_rand(&a, size));
DO(mp_rand(&b, size));
DO(s_mp_karatsuba_mul(&a, &b, &c));
DO(s_mp_mul(&a,&b,&d));
DO(s_mp_mul_karatsuba(&a, &b, &c));
DO(s_mp_mul_full(&a,&b,&d));
if (mp_cmp(&c, &d) != MP_EQ) {
fprintf(stderr, "Karatsuba multiplication failed at size %d\n", size);
goto LBL_ERR;
@ -1921,15 +1921,15 @@ LBL_ERR:
return EXIT_FAILURE;
}
static int test_s_mp_karatsuba_sqr(void)
static int test_s_mp_sqr_karatsuba(void)
{
mp_int a, b, c;
int size;
DOR(mp_init_multi(&a, &b, &c, NULL));
for (size = MP_KARATSUBA_SQR_CUTOFF; size < MP_KARATSUBA_SQR_CUTOFF + 20; size++) {
for (size = MP_SQR_KARATSUBA_CUTOFF; size < MP_SQR_KARATSUBA_CUTOFF + 20; size++) {
DO(mp_rand(&a, size));
DO(s_mp_karatsuba_sqr(&a, &b));
DO(s_mp_sqr_karatsuba(&a, &b));
DO(s_mp_sqr(&a, &c));
if (mp_cmp(&b, &c) != MP_EQ) {
fprintf(stderr, "Karatsuba squaring failed at size %d\n", size);
@ -1944,7 +1944,7 @@ LBL_ERR:
return EXIT_FAILURE;
}
static int test_s_mp_toom_mul(void)
static int test_s_mp_mul_toom(void)
{
mp_int a, b, c, d;
int size;
@ -1965,10 +1965,10 @@ static int test_s_mp_toom_mul(void)
DO(mp_2expt(&c, 99000 - 1000));
DO(mp_add(&b, &c, &b));
tc_cutoff = MP_TOOM_MUL_CUTOFF;
MP_TOOM_MUL_CUTOFF = INT_MAX;
tc_cutoff = MP_MUL_TOOM_CUTOFF;
MP_MUL_TOOM_CUTOFF = INT_MAX;
DO(mp_mul(&a, &b, &c));
MP_TOOM_MUL_CUTOFF = tc_cutoff;
MP_MUL_TOOM_CUTOFF = tc_cutoff;
DO(mp_mul(&a, &b, &d));
if (mp_cmp(&c, &d) != MP_EQ) {
fprintf(stderr, "Toom-Cook 3-way multiplication failed for edgecase f1 * f2\n");
@ -1976,11 +1976,11 @@ static int test_s_mp_toom_mul(void)
}
#endif
for (size = MP_TOOM_MUL_CUTOFF; size < MP_TOOM_MUL_CUTOFF + 20; size++) {
for (size = MP_MUL_TOOM_CUTOFF; size < MP_MUL_TOOM_CUTOFF + 20; size++) {
DO(mp_rand(&a, size));
DO(mp_rand(&b, size));
DO(s_mp_toom_mul(&a, &b, &c));
DO(s_mp_mul(&a,&b,&d));
DO(s_mp_mul_toom(&a, &b, &c));
DO(s_mp_mul_full(&a,&b,&d));
if (mp_cmp(&c, &d) != MP_EQ) {
fprintf(stderr, "Toom-Cook 3-way multiplication failed at size %d\n", size);
goto LBL_ERR;
@ -1994,15 +1994,15 @@ LBL_ERR:
return EXIT_FAILURE;
}
static int test_s_mp_toom_sqr(void)
static int test_s_mp_sqr_toom(void)
{
mp_int a, b, c;
int size;
DOR(mp_init_multi(&a, &b, &c, NULL));
for (size = MP_TOOM_SQR_CUTOFF; size < MP_TOOM_SQR_CUTOFF + 20; size++) {
for (size = MP_SQR_TOOM_CUTOFF; size < MP_SQR_TOOM_CUTOFF + 20; size++) {
DO(mp_rand(&a, size));
DO(s_mp_toom_sqr(&a, &b));
DO(s_mp_sqr_toom(&a, &b));
DO(s_mp_sqr(&a, &c));
if (mp_cmp(&b, &c) != MP_EQ) {
fprintf(stderr, "Toom-Cook 3-way squaring failed at size %d\n", size);
@ -2075,7 +2075,7 @@ static int test_s_mp_div_recursive(void)
DOR(mp_init_multi(&a, &b, &c_q, &c_r, &d_q, &d_r, NULL));
for (size = MP_KARATSUBA_MUL_CUTOFF; size < 3 * MP_KARATSUBA_MUL_CUTOFF; size += 10) {
for (size = MP_MUL_KARATSUBA_CUTOFF; size < 3 * MP_MUL_KARATSUBA_CUTOFF; size += 10) {
printf("\rsizes = %d / %d", 10 * size, size);
/* Relation 10:1 */
DO(mp_rand(&a, 10 * size));
@ -2139,7 +2139,7 @@ static int test_s_mp_div_small(void)
int size;
DOR(mp_init_multi(&a, &b, &c_q, &c_r, &d_q, &d_r, NULL));
for (size = 1; size < MP_KARATSUBA_MUL_CUTOFF; size += 10) {
for (size = 1; size < MP_MUL_KARATSUBA_CUTOFF; size += 10) {
printf("\rsizes = %d / %d", 2 * size, size);
/* Relation 10:1 */
DO(mp_rand(&a, 2 * size));
@ -2332,11 +2332,11 @@ static int unit_tests(int argc, char **argv)
T1(mp_xor, MP_XOR),
T2(s_mp_div_recursive, S_MP_DIV_RECURSIVE, S_MP_DIV_SCHOOL),
T2(s_mp_div_small, S_MP_DIV_SMALL, S_MP_DIV_SCHOOL),
T1(s_mp_balance_mul, S_MP_BALANCE_MUL),
T1(s_mp_karatsuba_mul, S_MP_KARATSUBA_MUL),
T1(s_mp_karatsuba_sqr, S_MP_KARATSUBA_SQR),
T1(s_mp_toom_mul, S_MP_TOOM_MUL),
T1(s_mp_toom_sqr, S_MP_TOOM_SQR)
T1(s_mp_mul_balance, S_MP_MUL_BALANCE),
T1(s_mp_mul_karatsuba, S_MP_MUL_KARATSUBA),
T1(s_mp_sqr_karatsuba, S_MP_SQR_KARATSUBA),
T1(s_mp_mul_toom, S_MP_MUL_TOOM),
T1(s_mp_sqr_toom, S_MP_SQR_TOOM)
#undef T2
#undef T1
};

View File

@ -247,18 +247,18 @@ int main(int argc, char **argv)
if (should_test("mulsqr", argc, argv) != 0) {
/* do mult/square twice, first without karatsuba and second with */
old_kara_m = MP_KARATSUBA_MUL_CUTOFF;
old_kara_s = MP_KARATSUBA_SQR_CUTOFF;
old_kara_m = MP_MUL_KARATSUBA_CUTOFF;
old_kara_s = MP_SQR_KARATSUBA_CUTOFF;
/* currently toom-cook cut-off is too high to kick in, so we just use the karatsuba values */
old_toom_m = old_kara_m;
old_toom_s = old_kara_s;
for (ix = 0; ix < 3; ix++) {
printf("With%s Karatsuba, With%s Toom\n", (ix == 1) ? "" : "out", (ix == 2) ? "" : "out");
MP_KARATSUBA_MUL_CUTOFF = (ix == 1) ? old_kara_m : 9999;
MP_KARATSUBA_SQR_CUTOFF = (ix == 1) ? old_kara_s : 9999;
MP_TOOM_MUL_CUTOFF = (ix == 2) ? old_toom_m : 9999;
MP_TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
MP_MUL_KARATSUBA_CUTOFF = (ix == 1) ? old_kara_m : 9999;
MP_SQR_KARATSUBA_CUTOFF = (ix == 1) ? old_kara_s : 9999;
MP_MUL_TOOM_CUTOFF = (ix == 2) ? old_toom_m : 9999;
MP_SQR_TOOM_CUTOFF = (ix == 2) ? old_toom_s : 9999;
log = FOPEN((ix == 0) ? "logs/mult" MP_TIMING_VERSION ".log" : (ix == 1) ? "logs/mult_kara" MP_TIMING_VERSION ".log" :
"logs/mult_toom" MP_TIMING_VERSION ".log", "w");

View File

@ -58,7 +58,7 @@ static int s_number_of_test_loops;
static int s_stabilization_extra;
static int s_offset = 1;
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
#define s_mp_mul_full(a, b, c) s_mp_mul(a, b, c, (a)->used + (b)->used + 1)
static uint64_t s_time_mul(int size)
{
int x;
@ -87,7 +87,7 @@ static uint64_t s_time_mul(int size)
goto LBL_ERR;
}
if (s_check_result == 1) {
if ((e = s_mp_mul(&a,&b,&d)) != MP_OKAY) {
if ((e = s_mp_mul_full(&a,&b,&d)) != MP_OKAY) {
t1 = UINT64_MAX;
goto LBL_ERR;
}
@ -247,8 +247,8 @@ static void s_usage(char *s)
}
struct cutoffs {
int KARATSUBA_MUL, KARATSUBA_SQR;
int TOOM_MUL, TOOM_SQR;
int MUL_KARATSUBA, SQR_KARATSUBA;
int MUL_TOOM, SQR_TOOM;
};
const struct cutoffs max_cutoffs =
@ -256,18 +256,18 @@ const struct cutoffs max_cutoffs =
static void set_cutoffs(const struct cutoffs *c)
{
MP_KARATSUBA_MUL_CUTOFF = c->KARATSUBA_MUL;
MP_KARATSUBA_SQR_CUTOFF = c->KARATSUBA_SQR;
MP_TOOM_MUL_CUTOFF = c->TOOM_MUL;
MP_TOOM_SQR_CUTOFF = c->TOOM_SQR;
MP_MUL_KARATSUBA_CUTOFF = c->MUL_KARATSUBA;
MP_SQR_KARATSUBA_CUTOFF = c->SQR_KARATSUBA;
MP_MUL_TOOM_CUTOFF = c->MUL_TOOM;
MP_SQR_TOOM_CUTOFF = c->SQR_TOOM;
}
static void get_cutoffs(struct cutoffs *c)
{
c->KARATSUBA_MUL = MP_KARATSUBA_MUL_CUTOFF;
c->KARATSUBA_SQR = MP_KARATSUBA_SQR_CUTOFF;
c->TOOM_MUL = MP_TOOM_MUL_CUTOFF;
c->TOOM_SQR = MP_TOOM_SQR_CUTOFF;
c->MUL_KARATSUBA = MP_MUL_KARATSUBA_CUTOFF;
c->SQR_KARATSUBA = MP_SQR_KARATSUBA_CUTOFF;
c->MUL_TOOM = MP_MUL_TOOM_CUTOFF;
c->SQR_TOOM = MP_SQR_TOOM_CUTOFF;
}
@ -414,13 +414,13 @@ int main(int argc, char **argv)
s_usage(argv[0]);
}
str = argv[opt];
MP_KARATSUBA_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for MP_KARATSUBA_MUL_CUTOFF given");
MP_MUL_KARATSUBA_CUTOFF = (int)s_strtol(str, &endptr, "[1/4] No value for MP_MUL_KARATSUBA_CUTOFF given");
str = endptr + 1;
MP_KARATSUBA_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for MP_KARATSUBA_SQR_CUTOFF given");
MP_SQR_KARATSUBA_CUTOFF = (int)s_strtol(str, &endptr, "[2/4] No value for MP_SQR_KARATSUBA_CUTOFF given");
str = endptr + 1;
MP_TOOM_MUL_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for MP_TOOM_MUL_CUTOFF given");
MP_MUL_TOOM_CUTOFF = (int)s_strtol(str, &endptr, "[3/4] No value for MP_MUL_TOOM_CUTOFF given");
str = endptr + 1;
MP_TOOM_SQR_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for MP_TOOM_SQR_CUTOFF given");
MP_SQR_TOOM_CUTOFF = (int)s_strtol(str, &endptr, "[4/4] No value for MP_SQR_TOOM_CUTOFF given");
break;
case 'h':
s_exit_code = EXIT_SUCCESS;
@ -455,10 +455,10 @@ int main(int argc, char **argv)
of the macro MP_WPARRAY in tommath.h which needs to
be changed manually (to 0 (zero)).
*/
T_MUL_SQR("Karatsuba multiplication", KARATSUBA_MUL, s_time_mul),
T_MUL_SQR("Karatsuba squaring", KARATSUBA_SQR, s_time_sqr),
T_MUL_SQR("Toom-Cook 3-way multiplying", TOOM_MUL, s_time_mul),
T_MUL_SQR("Toom-Cook 3-way squaring", TOOM_SQR, s_time_sqr),
T_MUL_SQR("Karatsuba multiplication", MUL_KARATSUBA, s_time_mul),
T_MUL_SQR("Karatsuba squaring", SQR_KARATSUBA, s_time_sqr),
T_MUL_SQR("Toom-Cook 3-way multiplying", MUL_TOOM, s_time_mul),
T_MUL_SQR("Toom-Cook 3-way squaring", SQR_TOOM, s_time_sqr),
#undef T_MUL_SQR
};
/* Turn all limits from bncore.c to the max */
@ -473,15 +473,15 @@ int main(int argc, char **argv)
}
if (args.terse == 1) {
printf("%d %d %d %d\n",
updated.KARATSUBA_MUL,
updated.KARATSUBA_SQR,
updated.TOOM_MUL,
updated.TOOM_SQR);
updated.MUL_KARATSUBA,
updated.SQR_KARATSUBA,
updated.MUL_TOOM,
updated.SQR_TOOM);
} else {
printf("KARATSUBA_MUL_CUTOFF = %d\n", updated.KARATSUBA_MUL);
printf("KARATSUBA_SQR_CUTOFF = %d\n", updated.KARATSUBA_SQR);
printf("TOOM_MUL_CUTOFF = %d\n", updated.TOOM_MUL);
printf("TOOM_SQR_CUTOFF = %d\n", updated.TOOM_SQR);
printf("MUL_KARATSUBA_CUTOFF = %d\n", updated.MUL_KARATSUBA);
printf("SQR_KARATSUBA_CUTOFF = %d\n", updated.SQR_KARATSUBA);
printf("MUL_TOOM_CUTOFF = %d\n", updated.MUL_TOOM);
printf("SQR_TOOM_CUTOFF = %d\n", updated.SQR_TOOM);
}
if (args.print == 1) {
@ -526,15 +526,15 @@ int main(int argc, char **argv)
set_cutoffs(&orig);
if (args.terse == 1) {
printf("%d %d %d %d\n",
MP_KARATSUBA_MUL_CUTOFF,
MP_KARATSUBA_SQR_CUTOFF,
MP_TOOM_MUL_CUTOFF,
MP_TOOM_SQR_CUTOFF);
MP_MUL_KARATSUBA_CUTOFF,
MP_SQR_KARATSUBA_CUTOFF,
MP_MUL_TOOM_CUTOFF,
MP_SQR_TOOM_CUTOFF);
} else {
printf("KARATSUBA_MUL_CUTOFF = %d\n", MP_KARATSUBA_MUL_CUTOFF);
printf("KARATSUBA_SQR_CUTOFF = %d\n", MP_KARATSUBA_SQR_CUTOFF);
printf("TOOM_MUL_CUTOFF = %d\n", MP_TOOM_MUL_CUTOFF);
printf("TOOM_SQR_CUTOFF = %d\n", MP_TOOM_SQR_CUTOFF);
printf("MUL_KARATSUBA_CUTOFF = %d\n", MP_MUL_KARATSUBA_CUTOFF);
printf("SQR_KARATSUBA_CUTOFF = %d\n", MP_SQR_KARATSUBA_CUTOFF);
printf("MUL_TOOM_CUTOFF = %d\n", MP_MUL_TOOM_CUTOFF);
printf("SQR_TOOM_CUTOFF = %d\n", MP_SQR_TOOM_CUTOFF);
}
}
}

View File

@ -93,15 +93,14 @@ i=$(tail -n +2 $FILE_NAME | wc -l)
# our median point will be at $i entries
i=$(( (i / 2) + 1 ))
TMP=$(median $FILE_NAME 1 $i)
echo "#define MP_DEFAULT_KARATSUBA_MUL_CUTOFF $TMP"
echo "#define MP_DEFAULT_KARATSUBA_MUL_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(km) Appending to $TOMMATH_CUTOFFS_H" $?
echo "#define MP_DEFAULT_MUL_KARATSUBA_CUTOFF $TMP"
echo "#define MP_DEFAULT_MUL_KARATSUBA_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(km) Appending to $TOMMATH_CUTOFFS_H" $?
TMP=$(median $FILE_NAME 2 $i)
echo "#define MP_DEFAULT_KARATSUBA_SQR_CUTOFF $TMP"
echo "#define MP_DEFAULT_KARATSUBA_SQR_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(ks) Appending to $TOMMATH_CUTOFFS_H" $?
echo "#define MP_DEFAULT_SQR_KARATSUBA_CUTOFF $TMP"
echo "#define MP_DEFAULT_SQR_KARATSUBA_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(ks) Appending to $TOMMATH_CUTOFFS_H" $?
TMP=$(median $FILE_NAME 3 $i)
echo "#define MP_DEFAULT_TOOM_MUL_CUTOFF $TMP"
echo "#define MP_DEFAULT_TOOM_MUL_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3m) Appending to $TOMMATH_CUTOFFS_H" $?
echo "#define MP_DEFAULT_MUL_TOOM_CUTOFF $TMP"
echo "#define MP_DEFAULT_MUL_TOOM_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3m) Appending to $TOMMATH_CUTOFFS_H" $?
TMP=$(median $FILE_NAME 4 $i)
echo "#define MP_DEFAULT_TOOM_SQR_CUTOFF $TMP"
echo "#define MP_DEFAULT_TOOM_SQR_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3s) Appending to $TOMMATH_CUTOFFS_H" $?
echo "#define MP_DEFAULT_SQR_TOOM_CUTOFF $TMP"
echo "#define MP_DEFAULT_SQR_TOOM_CUTOFF $TMP" >> $TOMMATH_CUTOFFS_H || die "(tc3s) Appending to $TOMMATH_CUTOFFS_H" $?

View File

@ -5,10 +5,10 @@
#ifndef MP_FIXED_CUTOFFS
#include "tommath_cutoffs.h"
int MP_KARATSUBA_MUL_CUTOFF = MP_DEFAULT_KARATSUBA_MUL_CUTOFF,
MP_KARATSUBA_SQR_CUTOFF = MP_DEFAULT_KARATSUBA_SQR_CUTOFF,
MP_TOOM_MUL_CUTOFF = MP_DEFAULT_TOOM_MUL_CUTOFF,
MP_TOOM_SQR_CUTOFF = MP_DEFAULT_TOOM_SQR_CUTOFF;
int MP_MUL_KARATSUBA_CUTOFF = MP_DEFAULT_MUL_KARATSUBA_CUTOFF,
MP_SQR_KARATSUBA_CUTOFF = MP_DEFAULT_SQR_KARATSUBA_CUTOFF,
MP_MUL_TOOM_CUTOFF = MP_DEFAULT_MUL_TOOM_CUTOFF,
MP_SQR_TOOM_CUTOFF = MP_DEFAULT_SQR_TOOM_CUTOFF;
#endif
#endif

View File

@ -26,7 +26,7 @@ mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
}
if (MP_HAS(S_MP_DIV_RECURSIVE)
&& (b->used > MP_KARATSUBA_MUL_CUTOFF)
&& (b->used > MP_MUL_KARATSUBA_CUTOFF)
&& (b->used <= ((a->used/3)*2))) {
err = s_mp_div_recursive(a, b, c, d);
} else if (MP_HAS(S_MP_DIV_SCHOOL)) {

View File

@ -12,12 +12,12 @@ mp_err mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
}
/* if the modulus is odd we can use a faster routine instead */
if (MP_HAS(S_MP_INVMOD_FAST) && mp_isodd(b)) {
return s_mp_invmod_fast(a, b, c);
if (MP_HAS(S_MP_INVMOD_ODD) && mp_isodd(b)) {
return s_mp_invmod_odd(a, b, c);
}
return MP_HAS(S_MP_INVMOD_SLOW)
? s_mp_invmod_slow(a, b, c)
return MP_HAS(S_MP_INVMOD)
? s_mp_invmod(a, b, c)
: MP_VAL;
}
#endif

View File

@ -19,7 +19,7 @@ mp_err mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
if ((digs < MP_WARRAY) &&
(x->used <= MP_WARRAY) &&
(n->used < MP_MAXFAST)) {
return s_mp_montgomery_reduce_fast(x, n, rho);
return s_mp_montgomery_reduce_comba(x, n, rho);
}
/* grow the input as required */

View File

@ -12,26 +12,26 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
digs = a->used + b->used + 1;
mp_sign neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
if (MP_HAS(S_MP_BALANCE_MUL) &&
if (MP_HAS(S_MP_MUL_BALANCE) &&
/* Check sizes. The smaller one needs to be larger than the Karatsuba cut-off.
* The bigger one needs to be at least about one MP_KARATSUBA_MUL_CUTOFF bigger
* The bigger one needs to be at least about one MP_MUL_KARATSUBA_CUTOFF bigger
* to make some sense, but it depends on architecture, OS, position of the
* stars... so YMMV.
* Using it to cut the input into slices small enough for s_mp_mul_digs_fast
* Using it to cut the input into slices small enough for s_mp_mul_comba
* was actually slower on the author's machine, but YMMV.
*/
(min >= MP_KARATSUBA_MUL_CUTOFF) &&
((max / 2) >= MP_KARATSUBA_MUL_CUTOFF) &&
(min >= MP_MUL_KARATSUBA_CUTOFF) &&
((max / 2) >= MP_MUL_KARATSUBA_CUTOFF) &&
/* Not much effect was observed below a ratio of 1:2, but again: YMMV. */
(max >= (2 * min))) {
err = s_mp_balance_mul(a,b,c);
} else if (MP_HAS(S_MP_TOOM_MUL) &&
(min >= MP_TOOM_MUL_CUTOFF)) {
err = s_mp_toom_mul(a, b, c);
} else if (MP_HAS(S_MP_KARATSUBA_MUL) &&
(min >= MP_KARATSUBA_MUL_CUTOFF)) {
err = s_mp_karatsuba_mul(a, b, c);
} else if (MP_HAS(S_MP_MUL_DIGS_FAST) &&
err = s_mp_mul_balance(a,b,c);
} else if (MP_HAS(S_MP_MUL_TOOM) &&
(min >= MP_MUL_TOOM_CUTOFF)) {
err = s_mp_mul_toom(a, b, c);
} else if (MP_HAS(S_MP_MUL_KARATSUBA) &&
(min >= MP_MUL_KARATSUBA_CUTOFF)) {
err = s_mp_mul_karatsuba(a, b, c);
} else if (MP_HAS(S_MP_MUL_COMBA) &&
/* can we use the fast multiplier?
*
* The fast multiplier can be used if the output will
@ -40,9 +40,9 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
*/
(digs < MP_WARRAY) &&
(min <= MP_MAXFAST)) {
err = s_mp_mul_digs_fast(a, b, c, digs);
} else if (MP_HAS(S_MP_MUL_DIGS)) {
err = s_mp_mul_digs(a, b, c, digs);
err = s_mp_mul_comba(a, b, c, digs);
} else if (MP_HAS(S_MP_MUL)) {
err = s_mp_mul(a, b, c, digs);
} else {
err = MP_VAL;
}

View File

@ -26,12 +26,12 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
if ((err = mp_mul(&q, mu, &q)) != MP_OKAY) {
goto LBL_ERR;
}
} else if (MP_HAS(S_MP_MUL_HIGH_DIGS)) {
if ((err = s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
} else if (MP_HAS(S_MP_MUL_HIGH)) {
if ((err = s_mp_mul_high(&q, mu, &q, um)) != MP_OKAY) {
goto LBL_ERR;
}
} else if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)) {
if ((err = s_mp_mul_high_digs_fast(&q, mu, &q, um)) != MP_OKAY) {
} else if (MP_HAS(S_MP_MUL_HIGH_COMBA)) {
if ((err = s_mp_mul_high_comba(&q, mu, &q, um)) != MP_OKAY) {
goto LBL_ERR;
}
} else {
@ -48,7 +48,7 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
}
/* q = q * m mod b**(k+1), quick (no division) */
if ((err = s_mp_mul_digs(&q, m, &q, um + 1)) != MP_OKAY) {
if ((err = s_mp_mul(&q, m, &q, um + 1)) != MP_OKAY) {
goto LBL_ERR;
}

View File

@ -7,16 +7,16 @@
mp_err mp_sqr(const mp_int *a, mp_int *b)
{
mp_err err;
if (MP_HAS(S_MP_TOOM_SQR) && /* use Toom-Cook? */
(a->used >= MP_TOOM_SQR_CUTOFF)) {
err = s_mp_toom_sqr(a, b);
} else if (MP_HAS(S_MP_KARATSUBA_SQR) && /* Karatsuba? */
(a->used >= MP_KARATSUBA_SQR_CUTOFF)) {
err = s_mp_karatsuba_sqr(a, b);
} else if (MP_HAS(S_MP_SQR_FAST) && /* can we use the fast comba multiplier? */
if (MP_HAS(S_MP_SQR_TOOM) && /* use Toom-Cook? */
(a->used >= MP_SQR_TOOM_CUTOFF)) {
err = s_mp_sqr_toom(a, b);
} else if (MP_HAS(S_MP_SQR_KARATSUBA) && /* Karatsuba? */
(a->used >= MP_SQR_KARATSUBA_CUTOFF)) {
err = s_mp_sqr_karatsuba(a, b);
} else if (MP_HAS(S_MP_SQR_COMBA) && /* can we use the fast comba multiplier? */
(((a->used * 2) + 1) < MP_WARRAY) &&
(a->used < (MP_MAXFAST / 2))) {
err = s_mp_sqr_fast(a, b);
err = s_mp_sqr_comba(a, b);
} else if (MP_HAS(S_MP_SQR)) {
err = s_mp_sqr(a, b);
} else {

View File

@ -20,7 +20,7 @@ static mp_err s_mp_recursion(const mp_int *a, const mp_int *b, mp_int *q, mp_int
mp_int A1, A2, B1, B0, Q1, Q0, R1, R0, t;
int m = a->used - b->used, k = m/2;
if (m < MP_KARATSUBA_MUL_CUTOFF) {
if (m < MP_MUL_KARATSUBA_CUTOFF) {
return s_mp_div_school(a, b, q, r);
}
@ -104,7 +104,7 @@ mp_err s_mp_div_recursive(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r
Vid. section 2.3.
*/
m = MP_KARATSUBA_MUL_CUTOFF;
m = MP_MUL_KARATSUBA_CUTOFF;
while (m <= b->used) {
m <<= 1;
}

View File

@ -80,10 +80,10 @@ mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_i
}
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
if (MP_HAS(S_MP_MONTGOMERY_REDUCE_FAST) &&
if (MP_HAS(S_MP_MONTGOMERY_REDUCE_COMBA) &&
(((P->used * 2) + 1) < MP_WARRAY) &&
(P->used < MP_MAXFAST)) {
redux = s_mp_montgomery_reduce_fast;
redux = s_mp_montgomery_reduce_comba;
} else if (MP_HAS(MP_MONTGOMERY_REDUCE)) {
/* use slower baseline Montgomery method */
redux = mp_montgomery_reduce;

View File

@ -1,10 +1,10 @@
#include "tommath_private.h"
#ifdef S_MP_INVMOD_SLOW_C
#ifdef S_MP_INVMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* hac 14.61, pp608 */
mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
mp_err s_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int x, y, u, v, A, B, C, D;
mp_err err;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_INVMOD_FAST_C
#ifdef S_MP_INVMOD_ODD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -9,7 +9,7 @@
* Based on slow invmod except this is optimized for the case where b is
* odd as per HAC Note 14.64 on pp. 610
*/
mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c)
mp_err s_mp_invmod_odd(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int x, y, u, v, B, D;
mp_sign neg;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_MONTGOMERY_REDUCE_FAST_C
#ifdef S_MP_MONTGOMERY_REDUCE_COMBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -11,7 +11,7 @@
*
* Based on Algorithm 14.32 on pp.601 of HAC.
*/
mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho)
mp_err s_mp_montgomery_reduce_comba(mp_int *x, const mp_int *n, mp_digit rho)
{
int ix, oldused;
mp_err err;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_MUL_DIGS_C
#ifdef S_MP_MUL_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -7,7 +7,7 @@
* HAC pp. 595, Algorithm 14.12 Modified so you can control how
* many digits of output are created.
*/
mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_err s_mp_mul(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
mp_int t;
mp_err err;
@ -16,7 +16,7 @@ mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
/* can we use the fast multiplier? */
if ((digs < MP_WARRAY) &&
(MP_MIN(a->used, b->used) < MP_MAXFAST)) {
return s_mp_mul_digs_fast(a, b, c, digs);
return s_mp_mul_comba(a, b, c, digs);
}
if ((err = mp_init_size(&t, digs)) != MP_OKAY) {

View File

@ -1,10 +1,10 @@
#include "tommath_private.h"
#ifdef S_MP_BALANCE_MUL_C
#ifdef S_MP_MUL_BALANCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* single-digit multiplication with the smaller number as the single-digit */
mp_err s_mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
mp_err s_mp_mul_balance(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int a0, tmp, r;
mp_err err;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_MUL_DIGS_FAST_C
#ifdef S_MP_MUL_COMBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -19,7 +19,7 @@
* Based on Algorithm 14.12 on pp.595 of HAC.
*
*/
mp_err s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_err s_mp_mul_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
int oldused, pa, ix;
mp_err err;

View File

@ -1,22 +1,22 @@
#include "tommath_private.h"
#ifdef S_MP_MUL_HIGH_DIGS_C
#ifdef S_MP_MUL_HIGH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* multiplies |a| * |b| and does not compute the lower digs digits
* [meant to get the higher part of the product]
*/
mp_err s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_err s_mp_mul_high(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
mp_int t;
int pa, pb, ix;
mp_err err;
/* can we use the fast multiplier? */
if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)
if (MP_HAS(S_MP_MUL_HIGH_COMBA)
&& ((a->used + b->used + 1) < MP_WARRAY)
&& (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
return s_mp_mul_high_digs_fast(a, b, c, digs);
return s_mp_mul_high_comba(a, b, c, digs);
}
if ((err = mp_init_size(&t, a->used + b->used + 1)) != MP_OKAY) {

View File

@ -1,10 +1,10 @@
#include "tommath_private.h"
#ifdef S_MP_MUL_HIGH_DIGS_FAST_C
#ifdef S_MP_MUL_HIGH_COMBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* this is a modified version of s_mp_mul_digs_fast that only produces
* output digits *above* digs. See the comments for s_mp_mul_digs_fast
/* this is a modified version of s_mp_mul_comba that only produces
* output digits *above* digs. See the comments for s_mp_mul_comba
* to see how it works.
*
* This is used in the Barrett reduction since for one of the multiplications
@ -12,7 +12,7 @@
*
* Based on Algorithm 14.12 on pp.595 of HAC.
*/
mp_err s_mp_mul_high_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs)
mp_err s_mp_mul_high_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
int oldused, pa, ix;
mp_err err;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_KARATSUBA_MUL_C
#ifdef S_MP_MUL_KARATSUBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -32,7 +32,7 @@
* Generally though the overhead of this method doesn't pay off
* until a certain size (N ~ 80) is reached.
*/
mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
mp_err s_mp_mul_karatsuba(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int x0, x1, y0, y1, t1, x0y0, x1y1;
int B;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_TOOM_MUL_C
#ifdef S_MP_MUL_TOOM_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -29,7 +29,7 @@
Centro Vito Volterra Universita di Roma Tor Vergata (2006)
*/
mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
mp_err s_mp_mul_toom(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int S1, S2, T1, a0, a1, a2, b0, b1, b2;
int B;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_SQR_FAST_C
#ifdef S_MP_SQR_COMBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -13,7 +13,7 @@
After that loop you do the squares and add them in.
*/
mp_err s_mp_sqr_fast(const mp_int *a, mp_int *b)
mp_err s_mp_sqr_comba(const mp_int *a, mp_int *b)
{
int oldused, pa, ix;
mp_digit W[MP_WARRAY];

View File

@ -1,16 +1,16 @@
#include "tommath_private.h"
#ifdef S_MP_KARATSUBA_SQR_C
#ifdef S_MP_SQR_KARATSUBA_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
/* Karatsuba squaring, computes b = a*a using three
* half size squarings
*
* See comments of karatsuba_mul for details. It
* See comments of mul_karatsuba for details. It
* is essentially the same algorithm but merely
* tuned to perform recursive squarings.
*/
mp_err s_mp_karatsuba_sqr(const mp_int *a, mp_int *b)
mp_err s_mp_sqr_karatsuba(const mp_int *a, mp_int *b)
{
mp_int x0, x1, t1, t2, x0x0, x1x1;
int B;

View File

@ -1,5 +1,5 @@
#include "tommath_private.h"
#ifdef S_MP_TOOM_SQR_C
#ifdef S_MP_SQR_TOOM_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
@ -18,7 +18,7 @@
18th IEEE Symposium on Computer Arithmetic (ARITH'07). IEEE, 2007.
*/
mp_err s_mp_toom_sqr(const mp_int *a, mp_int *b)
mp_err s_mp_sqr_toom(const mp_int *a, mp_int *b)
{
mp_int S0, a0, a1, a2;
int B;

View File

@ -63,7 +63,7 @@ typedef uint32_t mp_digit;
# ifdef MP_31BIT
/*
* This is an extension that uses 31-bit digits.
* Please be aware that not all functions support this size, especially s_mp_mul_digs_fast
* Please be aware that not all functions support this size, especially s_mp_mul_comba
* will be reduced to work on small numbers only:
* Up to 8 limbs, 248 bits instead of up to 512 limbs, 15872 bits with MP_28BIT.
*/
@ -117,10 +117,10 @@ typedef enum {
/* tunable cutoffs */
#ifndef MP_FIXED_CUTOFFS
extern int
MP_KARATSUBA_MUL_CUTOFF,
MP_KARATSUBA_SQR_CUTOFF,
MP_TOOM_MUL_CUTOFF,
MP_TOOM_SQR_CUTOFF;
MP_MUL_KARATSUBA_CUTOFF,
MP_SQR_KARATSUBA_CUTOFF,
MP_MUL_TOOM_CUTOFF,
MP_SQR_TOOM_CUTOFF;
#endif
/* define this to use lower memory usage routines (exptmods mostly) */

View File

@ -7,7 +7,7 @@
on the aforementioned machine for example.
*/
#define MP_DEFAULT_KARATSUBA_MUL_CUTOFF 80
#define MP_DEFAULT_KARATSUBA_SQR_CUTOFF 120
#define MP_DEFAULT_TOOM_MUL_CUTOFF 350
#define MP_DEFAULT_TOOM_SQR_CUTOFF 400
#define MP_DEFAULT_MUL_KARATSUBA_CUTOFF 80
#define MP_DEFAULT_SQR_KARATSUBA_CUTOFF 120
#define MP_DEFAULT_MUL_TOOM_CUTOFF 350
#define MP_DEFAULT_SQR_TOOM_CUTOFF 400

View File

@ -82,10 +82,10 @@ do { \
#ifdef MP_FIXED_CUTOFFS
# include "tommath_cutoffs.h"
# define MP_KARATSUBA_MUL_CUTOFF MP_DEFAULT_KARATSUBA_MUL_CUTOFF
# define MP_KARATSUBA_SQR_CUTOFF MP_DEFAULT_KARATSUBA_SQR_CUTOFF
# define MP_TOOM_MUL_CUTOFF MP_DEFAULT_TOOM_MUL_CUTOFF
# define MP_TOOM_SQR_CUTOFF MP_DEFAULT_TOOM_SQR_CUTOFF
# define MP_MUL_KARATSUBA_CUTOFF MP_DEFAULT_MUL_KARATSUBA_CUTOFF
# define MP_SQR_KARATSUBA_CUTOFF MP_DEFAULT_SQR_KARATSUBA_CUTOFF
# define MP_MUL_TOOM_CUTOFF MP_DEFAULT_MUL_TOOM_CUTOFF
# define MP_SQR_TOOM_CUTOFF MP_DEFAULT_SQR_TOOM_CUTOFF
#endif
/* define heap macros */
@ -161,20 +161,20 @@ extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size);
MP_PRIVATE bool s_mp_get_bit(const mp_int *a, int b);
MP_PRIVATE mp_err s_mp_add(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_high_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_sqr_fast(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_high_comba(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_high(const mp_int *a, const mp_int *b, mp_int *c, int digs) MP_WUR;
MP_PRIVATE mp_err s_mp_sqr_comba(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_sqr(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_karatsuba_sqr(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_toom_sqr(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_balance(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_karatsuba(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_mul_toom(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_sqr_karatsuba(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_sqr_toom(const mp_int *a, mp_int *b) MP_WUR;
MP_PRIVATE mp_err s_mp_invmod_odd(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
MP_PRIVATE mp_err s_mp_montgomery_reduce_comba(mp_int *x, const mp_int *n, mp_digit rho) MP_WUR;
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;

View File

@ -76,23 +76,23 @@
* like removing support for even moduli, etc...
*/
# ifdef LTM_LAST
# undef MP_DR_IS_MODULUS_C
# undef MP_DR_SETUP_C
# undef MP_DR_REDUCE_C
# undef MP_DIV_3_C
# undef MP_REDUCE_2K_SETUP_C
# undef MP_DR_IS_MODULUS_C
# undef MP_DR_REDUCE_C
# undef MP_DR_SETUP_C
# undef MP_REDUCE_2K_C
# undef MP_REDUCE_2K_SETUP_C
# undef MP_REDUCE_IS_2K_C
# undef MP_REDUCE_SETUP_C
# undef S_MP_BALANCE_MUL_C
# undef S_MP_EXPTMOD_C
# undef S_MP_INVMOD_FAST_C
# undef S_MP_KARATSUBA_MUL_C
# undef S_MP_KARATSUBA_SQR_C
# undef S_MP_MUL_HIGH_DIGS_C
# undef S_MP_MUL_HIGH_DIGS_FAST_C
# undef S_MP_TOOM_MUL_C
# undef S_MP_TOOM_SQR_C
# undef S_MP_INVMOD_ODD_C
# undef S_MP_MUL_BALANCE_C
# undef S_MP_MUL_HIGH_C
# undef S_MP_MUL_HIGH_COMBA_C
# undef S_MP_MUL_KARATSUBA_C
# undef S_MP_MUL_TOOM_C
# undef S_MP_SQR_KARATSUBA_C
# undef S_MP_SQR_TOOM_C
# ifndef SC_RSA_1_WITH_TESTS
# undef MP_REDUCE_C
@ -104,7 +104,7 @@
* trouble.
*/
# undef MP_MONTGOMERY_REDUCE_C
# undef S_MP_MUL_DIGS_C
# undef S_MP_MUL_C
# undef S_MP_SQR_C
# endif