Skip to content

Commit b9d6e5a

Browse files
committed
Adapted test.c (SC_RSA_1_WITH_TESTS)
1 parent ffe3333 commit b9d6e5a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

bn_s_mp_div_recursive.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "tommath_private.h"
22
#ifdef BN_S_MP_DIV_RECURSIVE_C
3+
34
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
45
/* SPDX-License-Identifier: Unlicense */
56

@@ -22,7 +23,7 @@ static mp_err s_mp_recursion(const mp_int *a, const mp_int *b, mp_int *q, mp_int
2223
mp_int A1, A2, B1, B0, Q1, Q0, R1, R0, t;
2324

2425
m = a->used - b->used;
25-
if (m < KARATSUBA_MUL_CUTOFF) {
26+
if (m < MP_KARATSUBA_MUL_CUTOFF) {
2627
return s_mp_div_school(a, b, q, r);
2728
}
2829

@@ -109,7 +110,7 @@ mp_err s_mp_div_recursive(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r
109110
110111
Vid. section 2.3.
111112
*/
112-
m = KARATSUBA_MUL_CUTOFF;
113+
m = MP_KARATSUBA_MUL_CUTOFF;
113114
while (m <= b->used) {
114115
m <<= 1;
115116
}

bn_s_mp_div_school.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifdef BN_S_MP_DIV_SCHOOL_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
5+
56
#ifndef BN_MP_DIV_SMALL
67
/* integer signed division.
78
* c*b + d == a [e.g. a/b, c=quotient, d=remainder]

demo/test.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ static int test_s_mp_toom_sqr(void)
22962296
mp_clear_multi(&a, &b, &c, NULL);
22972297
return EXIT_FAILURE;
22982298
}
2299-
2299+
#ifndef BN_MP_DIV_SMALL
23002300
/* Some larger values to test the fast divsion algorithm */
23012301
static int test_s_mp_div(void)
23022302
{
@@ -2370,7 +2370,7 @@ static int test_s_mp_div(void)
23702370
mp_clear_multi(&a, &b, &c, &d, NULL);
23712371
return EXIT_FAILURE;
23722372
}
2373-
2373+
#endif
23742374
static int test_mp_read_write_ubin(void)
23752375
{
23762376
mp_int a, b, c;
@@ -2542,12 +2542,14 @@ static int unit_tests(int argc, char **argv)
25422542
T1(mp_sqrt, MP_SQRT),
25432543
T1(mp_sqrtmod_prime, MP_SQRTMOD_PRIME),
25442544
T1(mp_xor, MP_XOR),
2545+
#ifndef BN_MP_DIV_SMALL
2546+
T2(s_mp_div, S_MP_DIV_RECURSIVE, S_MP_DIV_SCHOOL),
2547+
#endif
25452548
T1(s_mp_balance_mul, S_MP_BALANCE_MUL),
25462549
T1(s_mp_karatsuba_mul, S_MP_KARATSUBA_MUL),
25472550
T1(s_mp_karatsuba_sqr, S_MP_KARATSUBA_SQR),
25482551
T1(s_mp_toom_mul, S_MP_TOOM_MUL),
2549-
T1(s_mp_toom_sqr, S_MP_TOOM_SQR),
2550-
T1(s_mp_div, S_MP_DIV_RECURSIVE)
2552+
T1(s_mp_toom_sqr, S_MP_TOOM_SQR)
25512553
#undef T2
25522554
#undef T1
25532555
};

0 commit comments

Comments
 (0)