Skip to content

Commit fbfcb66

Browse files
committed
apply rename
1 parent 7469e85 commit fbfcb66

38 files changed

+5803
-4754
lines changed

bn_deprecated.c

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#include "tommath_private.h"
2+
#ifdef BN_DEPRECATED_C
3+
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4+
/* SPDX-License-Identifier: Unlicense */
5+
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
6+
7+
/* SPDX-License-Identifier: Unlicense */
8+
#include <tommath_private.h>
9+
#ifdef BN_FAST_MP_INVMOD_C
10+
int fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
11+
{
12+
return s_mp_invmod_fast(a, b, c);
13+
}
14+
#endif
15+
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
16+
int fast_mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
17+
{
18+
return s_mp_montgomery_reduce_fast(x, n, rho);
19+
}
20+
#endif
21+
#ifdef BN_FAST_S_MP_MUL_DIGS_C
22+
int fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
23+
{
24+
return s_mp_mul_digs_fast(a, b, c, digs);
25+
}
26+
#endif
27+
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
28+
int fast_s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
29+
{
30+
return s_mp_mul_high_digs_fast(a, b, c, digs);
31+
}
32+
#endif
33+
#ifdef BN_FAST_S_MP_SQR_C
34+
int fast_s_mp_sqr(const mp_int *a, mp_int *b)
35+
{
36+
return s_mp_sqr_fast(a, b);
37+
}
38+
#endif
39+
#ifdef BN_MP_BALANCE_MUL_C
40+
int mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
41+
{
42+
return s_mp_balance_mul(a, b, c);
43+
}
44+
#endif
45+
#ifdef BN_MP_EXPTMOD_FAST_C
46+
int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
47+
{
48+
return s_mp_exptmod_fast(G, X, P, Y, redmode);
49+
}
50+
#endif
51+
#ifdef BN_MP_INVMOD_SLOW_C
52+
int mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
53+
{
54+
return s_mp_invmod_slow(a, b, c);
55+
}
56+
#endif
57+
#ifdef BN_MP_KARATSUBA_MUL_C
58+
int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
59+
{
60+
return s_mp_karatsuba_mul(a, b, c);
61+
}
62+
#endif
63+
#ifdef BN_MP_KARATSUBA_SQR_C
64+
int mp_karatsuba_sqr(const mp_int *a, mp_int *b)
65+
{
66+
return s_mp_karatsuba_sqr(a, b);
67+
}
68+
#endif
69+
#ifdef BN_MP_TOOM_MUL_C
70+
int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
71+
{
72+
return s_mp_toom_mul(a, b, c);
73+
}
74+
#endif
75+
#ifdef BN_MP_TOOM_SQR_C
76+
int mp_toom_sqr(const mp_int *a, mp_int *b)
77+
{
78+
return s_mp_toom_sqr(a, b);
79+
}
80+
#endif
81+
#ifdef BN_REVERSE_C
82+
void bn_reverse(unsigned char *s, int len)
83+
{
84+
s_mp_reverse(s, len);
85+
}
86+
#endif
87+
#endif

bn_mp_exptmod.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ int mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y)
7575
#endif
7676

7777
/* if the modulus is odd or dr != 0 use the montgomery method */
78-
#ifdef BN_MP_EXPTMOD_FAST_C
78+
#ifdef BN_S_MP_EXPTMOD_FAST_C
7979
if (MP_IS_ODD(P) || (dr != 0)) {
80-
return mp_exptmod_fast(G, X, P, Y, dr);
80+
return s_mp_exptmod_fast(G, X, P, Y, dr);
8181
} else {
8282
#endif
8383
#ifdef BN_S_MP_EXPTMOD_C
@@ -87,7 +87,7 @@ int mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y)
8787
/* no exptmod for evens */
8888
return MP_VAL;
8989
#endif
90-
#ifdef BN_MP_EXPTMOD_FAST_C
90+
#ifdef BN_S_MP_EXPTMOD_FAST_C
9191
}
9292
#endif
9393
}

bn_mp_invmod.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
1111
return MP_VAL;
1212
}
1313

14-
#ifdef BN_FAST_MP_INVMOD_C
14+
#ifdef BN_S_MP_INVMOD_FAST_C
1515
/* if the modulus is odd we can use a faster routine instead */
1616
if (MP_IS_ODD(b)) {
17-
return fast_mp_invmod(a, b, c);
17+
return s_mp_invmod_fast(a, b, c);
1818
}
1919
#endif
2020

21-
#ifdef BN_MP_INVMOD_SLOW_C
22-
return mp_invmod_slow(a, b, c);
21+
#ifdef BN_S_MP_INVMOD_SLOW_C
22+
return s_mp_invmod_slow(a, b, c);
2323
#else
2424
return MP_VAL;
2525
#endif

bn_mp_montgomery_reduce.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
2020
(x->used <= (int)MP_WARRAY) &&
2121
(n->used <
2222
(int)(1u << ((CHAR_BIT * sizeof(mp_word)) - (2u * (size_t)DIGIT_BIT))))) {
23-
return fast_mp_montgomery_reduce(x, n, rho);
23+
return s_mp_montgomery_reduce_fast(x, n, rho);
2424
}
2525

2626
/* grow the input as required */

bn_mp_mul.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
88
{
99
int res, neg;
10-
#ifdef BN_MP_BALANCE_MUL_C
10+
#ifdef BN_S_MP_BALANCE_MUL_C
1111
int len_b, len_a;
1212
#endif
1313
neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
14-
#ifdef BN_MP_BALANCE_MUL_C
14+
#ifdef BN_S_MP_BALANCE_MUL_C
1515
len_a = a->used;
1616
len_b = b->used;
1717

@@ -37,22 +37,22 @@ int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
3737
goto GO_ON;
3838
}
3939

40-
res = mp_balance_mul(a,b,c);
40+
res = s_mp_balance_mul(a,b,c);
4141
goto END;
4242

4343
GO_ON:
4444
#endif
4545

4646
/* use Toom-Cook? */
47-
#ifdef BN_MP_TOOM_MUL_C
47+
#ifdef BN_S_MP_TOOM_MUL_C
4848
if (MP_MIN(a->used, b->used) >= TOOM_MUL_CUTOFF) {
49-
res = mp_toom_mul(a, b, c);
49+
res = s_mp_toom_mul(a, b, c);
5050
} else
5151
#endif
52-
#ifdef BN_MP_KARATSUBA_MUL_C
52+
#ifdef BN_S_MP_KARATSUBA_MUL_C
5353
/* use Karatsuba? */
5454
if (MP_MIN(a->used, b->used) >= KARATSUBA_MUL_CUTOFF) {
55-
res = mp_karatsuba_mul(a, b, c);
55+
res = s_mp_karatsuba_mul(a, b, c);
5656
} else
5757
#endif
5858
{
@@ -64,11 +64,11 @@ int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
6464
*/
6565
int digs = a->used + b->used + 1;
6666

67-
#ifdef BN_FAST_S_MP_MUL_DIGS_C
67+
#ifdef BN_S_MP_MUL_DIGS_FAST_C
6868
if ((digs < (int)MP_WARRAY) &&
6969
(MP_MIN(a->used, b->used) <=
7070
(int)(1u << ((CHAR_BIT * sizeof(mp_word)) - (2u * (size_t)DIGIT_BIT))))) {
71-
res = fast_s_mp_mul_digs(a, b, c, digs);
71+
res = s_mp_mul_digs_fast(a, b, c, digs);
7272
} else
7373
#endif
7474
{

bn_mp_reduce.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ int mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
3030
if ((res = s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
3131
goto CLEANUP;
3232
}
33-
#elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
34-
if ((res = fast_s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
33+
#elif defined(BN_S_MP_MUL_HIGH_DIGS_FAST_C)
34+
if ((res = s_mp_mul_high_digs_fast(&q, mu, &q, um)) != MP_OKAY) {
3535
goto CLEANUP;
3636
}
3737
#else

bn_mp_sqr.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ int mp_sqr(const mp_int *a, mp_int *b)
88
{
99
int res;
1010

11-
#ifdef BN_MP_TOOM_SQR_C
11+
#ifdef BN_S_MP_TOOM_SQR_C
1212
/* use Toom-Cook? */
1313
if (a->used >= TOOM_SQR_CUTOFF) {
14-
res = mp_toom_sqr(a, b);
14+
res = s_mp_toom_sqr(a, b);
1515
/* Karatsuba? */
1616
} else
1717
#endif
18-
#ifdef BN_MP_KARATSUBA_SQR_C
18+
#ifdef BN_S_MP_KARATSUBA_SQR_C
1919
if (a->used >= KARATSUBA_SQR_CUTOFF) {
20-
res = mp_karatsuba_sqr(a, b);
20+
res = s_mp_karatsuba_sqr(a, b);
2121
} else
2222
#endif
2323
{
24-
#ifdef BN_FAST_S_MP_SQR_C
24+
#ifdef BN_S_MP_SQR_FAST_C
2525
/* can we use the fast comba multiplier? */
2626
if ((((a->used * 2) + 1) < (int)MP_WARRAY) &&
2727
(a->used <
2828
(int)(1u << (((CHAR_BIT * sizeof(mp_word)) - (2u * (size_t)DIGIT_BIT)) - 1u)))) {
29-
res = fast_s_mp_sqr(a, b);
29+
res = s_mp_sqr_fast(a, b);
3030
} else
3131
#endif
3232
{

bn_mp_to_unsigned_bin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
2525
return res;
2626
}
2727
}
28-
bn_reverse(b, x);
28+
s_mp_reverse(b, x);
2929
mp_clear(&t);
3030
return MP_OKAY;
3131
}

bn_mp_toradix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int mp_toradix(const mp_int *a, char *str, int radix)
4747
/* reverse the digits of the string. In this case _s points
4848
* to the first digit [exluding the sign] of the number]
4949
*/
50-
bn_reverse((unsigned char *)_s, digs);
50+
s_mp_reverse((unsigned char *)_s, digs);
5151

5252
/* append a NULL so the string is properly terminated */
5353
*str = '\0';

bn_mp_toradix_n.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
6060
/* reverse the digits of the string. In this case _s points
6161
* to the first digit [exluding the sign] of the number
6262
*/
63-
bn_reverse((unsigned char *)_s, digs);
63+
s_mp_reverse((unsigned char *)_s, digs);
6464

6565
/* append a NULL so the string is properly terminated */
6666
*str = '\0';

bn_mp_balance_mul.c bn_s_mp_balance_mul.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "tommath_private.h"
2-
#ifdef BN_MP_BALANCE_MUL_C
2+
#ifdef BN_S_MP_BALANCE_MUL_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

66
/* single-digit multiplication with the smaller number as the single-digit */
7-
int mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
7+
int s_mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c)
88
{
99
int e, count, len_a, len_b, nblocks, i, j, bsize;
1010
mp_int a0, tmp, A, B, r;

bn_mp_exptmod_fast.c bn_s_mp_exptmod_fast.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "tommath_private.h"
2-
#ifdef BN_MP_EXPTMOD_FAST_C
2+
#ifdef BN_S_MP_EXPTMOD_FAST_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

@@ -17,7 +17,7 @@
1717
# define TAB_SIZE 256
1818
#endif
1919

20-
int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
20+
int s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, int redmode)
2121
{
2222
mp_int M[TAB_SIZE], res;
2323
mp_digit buf, mp;
@@ -83,10 +83,10 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
8383
#endif
8484

8585
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
86-
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
86+
#ifdef BN_S_MP_MONTGOMERY_REDUCE_FAST_C
8787
if ((((P->used * 2) + 1) < (int)MP_WARRAY) &&
8888
(P->used < (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
89-
redux = fast_mp_montgomery_reduce;
89+
redux = s_mp_montgomery_reduce_fast;
9090
} else
9191
#endif
9292
{

bn_fast_mp_invmod.c bn_s_mp_invmod_fast.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "tommath_private.h"
2-
#ifdef BN_FAST_MP_INVMOD_C
2+
#ifdef BN_S_MP_INVMOD_FAST_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

@@ -9,7 +9,7 @@
99
* Based on slow invmod except this is optimized for the case where b is
1010
* odd as per HAC Note 14.64 on pp. 610
1111
*/
12-
int fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
12+
int s_mp_invmod_fast(const mp_int *a, const mp_int *b, mp_int *c)
1313
{
1414
mp_int x, y, u, v, B, D;
1515
int res, neg;

bn_mp_invmod_slow.c bn_s_mp_invmod_slow.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "tommath_private.h"
2-
#ifdef BN_MP_INVMOD_SLOW_C
2+
#ifdef BN_S_MP_INVMOD_SLOW_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

66
/* hac 14.61, pp608 */
7-
int mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
7+
int s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
88
{
99
mp_int x, y, u, v, A, B, C, D;
1010
int res;

bn_mp_karatsuba_mul.c bn_s_mp_karatsuba_mul.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "tommath_private.h"
2-
#ifdef BN_MP_KARATSUBA_MUL_C
2+
#ifdef BN_S_MP_KARATSUBA_MUL_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

@@ -32,7 +32,7 @@
3232
* Generally though the overhead of this method doesn't pay off
3333
* until a certain size (N ~ 80) is reached.
3434
*/
35-
int mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
35+
int s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
3636
{
3737
mp_int x0, x1, y0, y1, t1, x0y0, x1y1;
3838
int B, err;

bn_mp_karatsuba_sqr.c bn_s_mp_karatsuba_sqr.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "tommath_private.h"
2-
#ifdef BN_MP_KARATSUBA_SQR_C
2+
#ifdef BN_S_MP_KARATSUBA_SQR_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

@@ -10,7 +10,7 @@
1010
* is essentially the same algorithm but merely
1111
* tuned to perform recursive squarings.
1212
*/
13-
int mp_karatsuba_sqr(const mp_int *a, mp_int *b)
13+
int s_mp_karatsuba_sqr(const mp_int *a, mp_int *b)
1414
{
1515
mp_int x0, x1, t1, t2, x0x0, x1x1;
1616
int B, err;

bn_fast_mp_montgomery_reduce.c bn_s_mp_montgomery_reduce_fast.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "tommath_private.h"
2-
#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C
2+
#ifdef BN_S_MP_MONTGOMERY_REDUCE_FAST_C
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

@@ -11,7 +11,7 @@
1111
*
1212
* Based on Algorithm 14.32 on pp.601 of HAC.
1313
*/
14-
int fast_mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
14+
int s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho)
1515
{
1616
int ix, res, olduse;
1717
mp_word W[MP_WARRAY];

bn_s_mp_mul_digs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
1919
if ((digs < (int)MP_WARRAY) &&
2020
(MP_MIN(a->used, b->used) <
2121
(int)(1u << ((CHAR_BIT * sizeof(mp_word)) - (2u * (size_t)DIGIT_BIT))))) {
22-
return fast_s_mp_mul_digs(a, b, c, digs);
22+
return s_mp_mul_digs_fast(a, b, c, digs);
2323
}
2424

2525
if ((res = mp_init_size(&t, digs)) != MP_OKAY) {

0 commit comments

Comments
 (0)