Skip to content

Commit 1661066

Browse files
author
jan.nijtmans
committed
Merge 8.7 (removing some dead libtommath-related code)
2 parents bfa6e2e + 062a445 commit 1661066

File tree

4 files changed

+44
-48
lines changed

4 files changed

+44
-48
lines changed

generic/tclStubInit.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ int TclParseArgsObjv(Tcl_Interp *interp,
207207
#define TclBN_mp_div_2 mp_div_2
208208
#define TclBN_mp_div_2d mp_div_2d
209209
#define TclBN_mp_exch mp_exch
210-
#define TclBN_mp_expt_u32 mp_expt_u32
211210
#define TclBN_mp_get_mag_u64 mp_get_mag_u64
212211
#define TclBN_mp_grow mp_grow
213212
#define TclBN_mp_init mp_init
@@ -246,18 +245,18 @@ int TclParseArgsObjv(Tcl_Interp *interp,
246245
#define TclBN_mp_xor mp_xor
247246
#define TclBN_mp_zero mp_zero
248247
#define TclBN_s_mp_add s_mp_add
249-
#define TclBN_s_mp_balance_mul s_mp_balance_mul
250-
#define TclBN_s_mp_div_3 s_mp_div_3
251-
#define TclBN_s_mp_karatsuba_mul s_mp_karatsuba_mul
252-
#define TclBN_s_mp_karatsuba_sqr s_mp_karatsuba_sqr
253-
#define TclBN_s_mp_mul_digs s_mp_mul_digs
254-
#define TclBN_s_mp_mul_digs_fast s_mp_mul_digs_fast
255-
#define TclBN_s_mp_reverse s_mp_reverse
248+
#define TclBN_mp_balance_mul s_mp_balance_mul
249+
#define TclBN_mp_div_3 s_mp_div_3
250+
#define TclBN_mp_karatsuba_mul s_mp_karatsuba_mul
251+
#define TclBN_mp_karatsuba_sqr s_mp_karatsuba_sqr
252+
#define TclBN_mp_mul_digs s_mp_mul_digs
253+
#define TclBN_mp_mul_digs_fast s_mp_mul_digs_fast
254+
#define TclBN_mp_reverse s_mp_reverse
256255
#define TclBN_s_mp_sqr s_mp_sqr
257-
#define TclBN_s_mp_sqr_fast s_mp_sqr_fast
256+
#define TclBN_mp_sqr_fast s_mp_sqr_fast
258257
#define TclBN_s_mp_sub s_mp_sub
259-
#define TclBN_s_mp_toom_mul s_mp_toom_mul
260-
#define TclBN_s_mp_toom_sqr s_mp_toom_sqr
258+
#define TclBN_mp_toom_mul s_mp_toom_mul
259+
#define TclBN_mp_toom_sqr s_mp_toom_sqr
261260

262261
#ifndef MAC_OSX_TCL /* On UNIX, fill with other stub entries */
263262
# define Tcl_MacOSXOpenVersionedBundleResources 0
@@ -387,6 +386,9 @@ MODULE_SCOPE const TclTomMathStubs tclTomMathStubs;
387386
/* If Tcl is linked with an external libtommath 1.2.x, then mp_expt_n doesn't
388387
* exist (since that was introduced in libtommath 1.3.0. Provide it here.) */
389388
mp_err MP_WUR TclBN_mp_expt_n(const mp_int *a, int b, mp_int *c) {
389+
if ((unsigned)b > MP_MIN(MP_DIGIT_MAX, INT_MAX)) {
390+
return MP_VAL;
391+
}
390392
return mp_expt_u32(a, (uint32_t)b, c);;
391393
}
392394
#endif /* TCL_WITH_EXTERNAL_TOMMATH */

generic/tclTomMathDecls.h

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,18 @@
6464
extern "C" {
6565
#endif
6666
MODULE_SCOPE mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b);
67-
MODULE_SCOPE mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, mp_digit *r);
68-
MODULE_SCOPE mp_err TclBN_mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c);
69-
MODULE_SCOPE mp_err TclBN_s_mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c);
70-
MODULE_SCOPE mp_err TclBN_s_mp_div_3(const mp_int *a, mp_int *c, mp_digit *d);
71-
MODULE_SCOPE mp_err TclBN_s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c);
72-
MODULE_SCOPE mp_err TclBN_s_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
73-
MODULE_SCOPE mp_err TclBN_s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c);
74-
MODULE_SCOPE mp_err TclBN_s_mp_toom_sqr(const mp_int *a, mp_int *b);
67+
MODULE_SCOPE mp_err TclBN_mp_balance_mul(const mp_int *a, const mp_int *b, mp_int *c);
68+
MODULE_SCOPE mp_err TclBN_mp_div_3(const mp_int *a, mp_int *c, mp_digit *d);
69+
MODULE_SCOPE mp_err TclBN_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c);
70+
MODULE_SCOPE mp_err TclBN_mp_karatsuba_sqr(const mp_int *a, mp_int *b);
71+
MODULE_SCOPE mp_err TclBN_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c);
72+
MODULE_SCOPE mp_err TclBN_mp_toom_sqr(const mp_int *a, mp_int *b);
7573
MODULE_SCOPE mp_err TclBN_s_mp_add(const mp_int *a, const mp_int *b, mp_int *c);
76-
MODULE_SCOPE mp_err TclBN_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs);
77-
MODULE_SCOPE mp_err TclBN_s_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs);
78-
MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len);
74+
MODULE_SCOPE mp_err TclBN_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs);
75+
MODULE_SCOPE mp_err TclBN_mp_mul_digs_fast(const mp_int *a, const mp_int *b, mp_int *c, int digs);
76+
MODULE_SCOPE void TclBN_mp_reverse(unsigned char *s, size_t len);
7977
MODULE_SCOPE mp_err TclBN_s_mp_sqr(const mp_int *a, mp_int *b);
80-
MODULE_SCOPE mp_err TclBN_s_mp_sqr_fast(const mp_int *a, mp_int *b);
78+
MODULE_SCOPE mp_err TclBN_mp_sqr_fast(const mp_int *a, mp_int *b);
8179
MODULE_SCOPE mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
8280
MODULE_SCOPE const char *const TclBN_mp_s_rmap;
8381
MODULE_SCOPE const uint8_t TclBN_mp_s_rmap_reverse[];
@@ -106,12 +104,9 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b);
106104
#define mp_div TclBN_mp_div
107105
#define mp_div_d TclBN_mp_div_d
108106
#define mp_div_2 TclBN_mp_div_2
109-
#define mp_div_3 TclBN_mp_div_3
110107
#define mp_div_2d TclBN_mp_div_2d
111108
#define mp_exch TclBN_mp_exch
112-
#define mp_expt_d TclBN_mp_expt_d
113-
#define mp_expt_d_ex TclBN_mp_expt_d_ex
114-
#define mp_expt_u32 TclBN_mp_expt_u32
109+
#define mp_expt_d TclBN_mp_expt_n
115110
#define mp_expt_n TclBN_mp_expt_n
116111
#define mp_get_mag_u64 TclBN_mp_get_mag_u64
117112
#define mp_grow TclBN_mp_grow
@@ -139,7 +134,7 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b);
139134
#define mp_s_rmap TclBN_mp_s_rmap
140135
#define mp_s_rmap_reverse TclBN_mp_s_rmap_reverse
141136
#define mp_s_rmap_reverse_sz TclBN_mp_s_rmap_reverse_sz
142-
#define mp_set TclBN_s_mp_set
137+
#define mp_set TclBN_mp_set
143138
#define mp_set_i64 TclBN_mp_set_i64
144139
#define mp_set_u64 TclBN_mp_set_u64
145140
#define mp_shrink TclBN_mp_shrink
@@ -162,18 +157,18 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b);
162157
#define mp_xor TclBN_mp_xor
163158
#define mp_zero TclBN_mp_zero
164159
#define s_mp_add TclBN_s_mp_add
165-
#define s_mp_balance_mul TclBN_s_mp_balance_mul
166-
#define s_mp_div_3 TclBN_s_mp_div_3
167-
#define s_mp_karatsuba_mul TclBN_s_mp_karatsuba_mul
168-
#define s_mp_karatsuba_sqr TclBN_s_mp_karatsuba_sqr
169-
#define s_mp_mul_digs TclBN_s_mp_mul_digs
170-
#define s_mp_mul_digs_fast TclBN_s_mp_mul_digs_fast
171-
#define s_mp_reverse TclBN_s_mp_reverse
160+
#define s_mp_balance_mul TclBN_mp_balance_mul
161+
#define s_mp_div_3 TclBN_mp_div_3
162+
#define s_mp_karatsuba_mul TclBN_mp_karatsuba_mul
163+
#define s_mp_karatsuba_sqr TclBN_mp_karatsuba_sqr
164+
#define s_mp_mul_digs TclBN_mp_mul_digs
165+
#define s_mp_mul_digs_fast TclBN_mp_mul_digs_fast
166+
#define s_mp_reverse TclBN_mp_reverse
172167
#define s_mp_sqr TclBN_s_mp_sqr
173-
#define s_mp_sqr_fast TclBN_s_mp_sqr_fast
168+
#define s_mp_sqr_fast TclBN_mp_sqr_fast
174169
#define s_mp_sub TclBN_s_mp_sub
175-
#define s_mp_toom_mul TclBN_s_mp_toom_mul
176-
#define s_mp_toom_sqr TclBN_s_mp_toom_sqr
170+
#define s_mp_toom_mul TclBN_mp_toom_mul
171+
#define s_mp_toom_sqr TclBN_mp_toom_sqr
177172
#endif /* !TCL_WITH_EXTERNAL_TOMMATH */
178173

179174
#undef TCL_STORAGE_CLASS

libtommath/bn_deprecated.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ mp_err mp_expt_d(const mp_int *a, mp_digit b, mp_int *c)
249249
return mp_expt_n(a, (int)b, c);
250250
}
251251
#endif
252+
#ifdef BN_MP_EXPT_U32_C
253+
mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c)
254+
{
255+
if (b > MP_MIN(MP_DIGIT_MAX, INT_MAX)) {
256+
return MP_VAL;
257+
}
258+
return mp_expt_n(a, (int)b, c);
259+
}
260+
#endif
252261
#ifdef BN_MP_N_ROOT_EX_C
253262
mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
254263
{

libtommath/bn_mp_expt_n.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
44
/* SPDX-License-Identifier: Unlicense */
55

6-
#ifdef BN_MP_EXPT_U32_C
7-
mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c)
8-
{
9-
if (b > MP_MIN(MP_DIGIT_MAX, INT_MAX)) {
10-
return MP_VAL;
11-
}
12-
return mp_expt_n(a, (int)b, c);
13-
}
14-
#endif
15-
166
/* calculate c = a**b using a square-multiply algorithm */
177
mp_err mp_expt_n(const mp_int *a, int b, mp_int *c)
188
{

0 commit comments

Comments
 (0)