diff options
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclStubInit.c | 30 | ||||
-rw-r--r-- | generic/tclTomMath.decls | 10 | ||||
-rw-r--r-- | generic/tclTomMathDecls.h | 48 | ||||
-rw-r--r-- | libtommath/bn_deprecated.c | 9 | ||||
-rw-r--r-- | libtommath/bn_mp_expt_n.c | 10 |
6 files changed, 54 insertions, 55 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 962acba..91caca1 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8774,7 +8774,7 @@ ExecuteExtendedBinaryMathOp( err = mp_init(&bigResult); if (err == MP_OKAY) { /* Don't use "mp_expt_n" directly here, it doesn't exist in libtommath 1.2 */ - err = TclBN_mp_expt_n(&big1, (int)w2, &bigResult); + err = TclBN_mp_expt_d(&big1, (int)w2, &bigResult); } if (err != MP_OKAY) { return OUT_OF_MEMORY; diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 057ffc0..2b0b44b 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -147,7 +147,7 @@ static const char *TclUtfPrev(const char *src, const char *start) { #define TclBN_mp_div_2 mp_div_2 #define TclBN_mp_div_2d mp_div_2d #define TclBN_mp_exch mp_exch -#define TclBN_mp_get_mag_u64 mp_get_mag_u64 +#define TclBN_mp_get_mag_ull mp_get_mag_u64 #define TclBN_mp_grow mp_grow #define TclBN_mp_init mp_init #define TclBN_mp_init_copy mp_init_copy @@ -169,8 +169,8 @@ static const char *TclUtfPrev(const char *src, const char *start) { #define TclBN_mp_reverse mp_reverse #define TclBN_mp_read_radix mp_read_radix #define TclBN_mp_rshd mp_rshd -#define TclBN_mp_set_i64 mp_set_i64 -#define TclBN_mp_set_u64 mp_set_u64 +#define TclBN_mp_set_ll mp_set_i64 +#define TclBN_mp_set_ull mp_set_u64 #define TclBN_mp_shrink mp_shrink #define TclBN_mp_sqr mp_sqr #define TclBN_mp_sqrt mp_sqrt @@ -214,20 +214,20 @@ static int TclSockMinimumBuffersOld(int sock, int size) mp_err TclBN_mp_set_int(mp_int *a, unsigned long i) { - TclBN_mp_set_u64(a, i); + TclBN_mp_set_ull(a, i); return MP_OKAY; } static mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) { - TclBN_mp_set_u64(a, i); + TclBN_mp_set_ull(a, i); return MP_OKAY; } #define TclBN_mp_set_ul (void (*)(mp_int *a, unsigned long i))(void *)TclBN_mp_set_long mp_err MP_WUR TclBN_mp_expt_u32(const mp_int *a, unsigned int b, mp_int *c) { - return TclBN_mp_expt_n(a, b, c); + return TclBN_mp_expt_d(a, b, c); } mp_err TclBN_mp_add_d(const mp_int *a, unsigned int b, mp_int *c) { return mp_add_d(a, b, c); @@ -275,7 +275,7 @@ mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *c) { # define TclBN_mp_sqr 0 # define TclBN_mp_div_3 0 # define TclBN_mp_init_l 0 -# define TclBN_mp_init_ul 0 +# define TclBN_mp_init_set_int 0 # define TclBN_mp_set 0 # define TclSetStartupScriptPath 0 # define TclGetStartupScriptPath 0 @@ -370,7 +370,7 @@ void TclBN_reverse(unsigned char *s, int len) } } -mp_err TclBN_mp_init_ul(mp_int *a, unsigned long b) +mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long b) { return TclBN_mp_init_u64(a,b); } @@ -381,7 +381,7 @@ mp_err TclBN_mp_init_l(mp_int *a, long b) } void TclBN_mp_set(mp_int *a, unsigned int b) { - TclBN_mp_set_u64(a, b); + TclBN_mp_set_ull(a, b); } mp_err TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) @@ -782,7 +782,7 @@ MODULE_SCOPE const TclTomMathStubs tclTomMathStubs; #ifdef TCL_WITH_EXTERNAL_TOMMATH /* If Tcl is linked with an external libtommath 1.2.x, then mp_expt_n doesn't * exist (since that was introduced in libtommath 1.3.0. Provide it here.) */ -mp_err MP_WUR TclBN_mp_expt_n(const mp_int *a, int b, mp_int *c) { +mp_err MP_WUR TclBN_mp_expt_d(const mp_int *a, int b, mp_int *c) { return mp_expt_u32(a, (uint32_t)b, c);; } #endif /* TCL_WITH_EXTERNAL_TOMMATH */ @@ -1198,7 +1198,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_div_2d, /* 16 */ TclBN_mp_div_3, /* 17 */ TclBN_mp_exch, /* 18 */ - TclBN_mp_expt_n, /* 19 */ + TclBN_mp_expt_d, /* 19 */ TclBN_mp_grow, /* 20 */ TclBN_mp_init, /* 21 */ TclBN_mp_init_copy, /* 22 */ @@ -1240,16 +1240,16 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_s_mp_mul_digs, /* 58 */ TclBN_s_mp_sqr, /* 59 */ TclBN_s_mp_sub, /* 60 */ - TclBN_mp_init_ul, /* 61 */ + TclBN_mp_init_set_int, /* 61 */ TclBN_mp_set_ul, /* 62 */ TclBN_mp_cnt_lsb, /* 63 */ TclBN_mp_init_l, /* 64 */ TclBN_mp_init_i64, /* 65 */ TclBN_mp_init_u64, /* 66 */ TclBN_mp_expt_d_ex, /* 67 */ - TclBN_mp_set_u64, /* 68 */ - TclBN_mp_get_mag_u64, /* 69 */ - TclBN_mp_set_i64, /* 70 */ + TclBN_mp_set_ull, /* 68 */ + TclBN_mp_get_mag_ull, /* 69 */ + TclBN_mp_set_ll, /* 70 */ TclBN_mp_unpack, /* 71 */ TclBN_mp_pack, /* 72 */ TclBN_mp_tc_and, /* 73 */ diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index a641b0f..f4aa332 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -80,7 +80,7 @@ declare 18 { void TclBN_mp_exch(mp_int *a, mp_int *b) } declare 19 { - mp_err MP_WUR TclBN_mp_expt_n(const mp_int *a, int b, mp_int *c) + mp_err MP_WUR TclBN_mp_expt_d(const mp_int *a, int b, mp_int *c) } declare 20 { mp_err MP_WUR TclBN_mp_grow(mp_int *a, int size) @@ -211,7 +211,7 @@ declare 60 {deprecated {is private function in libtommath}} { mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c) } declare 61 {deprecated {macro calling mp_init_u64}} { - mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i) + mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long i) } declare 62 {deprecated {macro calling mp_set_u64}} { void TclBN_mp_set_ul(mp_int *a, unsigned long i) @@ -235,13 +235,13 @@ declare 67 {deprecated {Use mp_expt_n}} { } # Added in libtommath 1.0.1 declare 68 { - void TclBN_mp_set_u64(mp_int *a, uint64_t i) + void TclBN_mp_set_ull(mp_int *a, uint64_t i) } declare 69 { - uint64_t MP_WUR TclBN_mp_get_mag_u64(const mp_int *a) + uint64_t MP_WUR TclBN_mp_get_mag_ull(const mp_int *a) } declare 70 { - void TclBN_mp_set_i64(mp_int *a, int64_t i) + void TclBN_mp_set_ll(mp_int *a, int64_t i) } declare 71 { mp_err MP_WUR TclBN_mp_unpack(mp_int *rop, size_t count, mp_order order, size_t size, diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index be4dc88..a36c97a 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -106,8 +106,8 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b); #define mp_expt_d TclBN_mp_expt_d #define mp_expt_d_ex TclBN_mp_expt_d_ex #define mp_expt_u32 TclBN_s_mp_expt_u32 -#define mp_expt_n TclBN_mp_expt_n -#define mp_get_mag_u64 TclBN_mp_get_mag_u64 +#define mp_expt_n TclBN_mp_expt_d +#define mp_get_mag_u64 TclBN_mp_get_mag_ull #define mp_grow TclBN_mp_grow #define mp_init TclBN_mp_init #define mp_init_copy TclBN_mp_init_copy @@ -134,8 +134,8 @@ MODULE_SCOPE mp_err TclBN_mp_set_int(mp_int *a, unsigned long b); #define mp_s_rmap_reverse TclBN_mp_s_rmap_reverse #define mp_s_rmap_reverse_sz TclBN_mp_s_rmap_reverse_sz #define mp_set TclBN_s_mp_set -#define mp_set_i64 TclBN_mp_set_i64 -#define mp_set_u64 TclBN_mp_set_u64 +#define mp_set_i64 TclBN_mp_set_ll +#define mp_set_u64 TclBN_mp_set_ull #define mp_shrink TclBN_mp_shrink #define mp_sqr TclBN_mp_sqr #define mp_sqrt TclBN_mp_sqrt @@ -250,7 +250,7 @@ mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, /* 18 */ EXTERN void TclBN_mp_exch(mp_int *a, mp_int *b); /* 19 */ -EXTERN mp_err TclBN_mp_expt_n(const mp_int *a, int b, mp_int *c) MP_WUR; +EXTERN mp_err TclBN_mp_expt_d(const mp_int *a, int b, mp_int *c) MP_WUR; /* 20 */ EXTERN mp_err TclBN_mp_grow(mp_int *a, int size) MP_WUR; /* 21 */ @@ -368,7 +368,7 @@ mp_err TclBN_s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c); /* 61 */ TCL_DEPRECATED("macro calling mp_init_u64") -mp_err TclBN_mp_init_ul(mp_int *a, unsigned long i); +mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long i); /* 62 */ TCL_DEPRECATED("macro calling mp_set_u64") void TclBN_mp_set_ul(mp_int *a, unsigned long i); @@ -386,11 +386,11 @@ TCL_DEPRECATED("Use mp_expt_n") mp_err TclBN_mp_expt_d_ex(const mp_int *a, unsigned int b, mp_int *c, int fast); /* 68 */ -EXTERN void TclBN_mp_set_u64(mp_int *a, uint64_t i); +EXTERN void TclBN_mp_set_ull(mp_int *a, uint64_t i); /* 69 */ -EXTERN uint64_t TclBN_mp_get_mag_u64(const mp_int *a) MP_WUR; +EXTERN uint64_t TclBN_mp_get_mag_ull(const mp_int *a) MP_WUR; /* 70 */ -EXTERN void TclBN_mp_set_i64(mp_int *a, int64_t i); +EXTERN void TclBN_mp_set_ll(mp_int *a, int64_t i); /* 71 */ EXTERN mp_err TclBN_mp_unpack(mp_int *rop, size_t count, mp_order order, size_t size, @@ -452,7 +452,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r) MP_WUR; /* 16 */ TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_mp_div_3) (const mp_int *a, mp_int *q, unsigned int *r); /* 17 */ void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */ - mp_err (*tclBN_mp_expt_n) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 19 */ + mp_err (*tclBN_mp_expt_d) (const mp_int *a, int b, mp_int *c) MP_WUR; /* 19 */ mp_err (*tclBN_mp_grow) (mp_int *a, int size) MP_WUR; /* 20 */ mp_err (*tclBN_mp_init) (mp_int *a) MP_WUR; /* 21 */ mp_err (*tclBN_mp_init_copy) (mp_int *a, const mp_int *b) MP_WUR; /* 22 */ @@ -494,16 +494,16 @@ typedef struct TclTomMathStubs { TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_mul_digs) (const mp_int *a, const mp_int *b, mp_int *c, int digs); /* 58 */ TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_sqr) (const mp_int *a, mp_int *b); /* 59 */ TCL_DEPRECATED_API("is private function in libtommath") mp_err (*tclBN_s_mp_sub) (const mp_int *a, const mp_int *b, mp_int *c); /* 60 */ - TCL_DEPRECATED_API("macro calling mp_init_u64") mp_err (*tclBN_mp_init_ul) (mp_int *a, unsigned long i); /* 61 */ + TCL_DEPRECATED_API("macro calling mp_init_u64") mp_err (*tclBN_mp_init_set_int) (mp_int *a, unsigned long i); /* 61 */ TCL_DEPRECATED_API("macro calling mp_set_u64") void (*tclBN_mp_set_ul) (mp_int *a, unsigned long i); /* 62 */ int (*tclBN_mp_cnt_lsb) (const mp_int *a) MP_WUR; /* 63 */ TCL_DEPRECATED_API("macro calling mp_init_i64") int (*tclBN_mp_init_l) (mp_int *bignum, long initVal); /* 64 */ int (*tclBN_mp_init_i64) (mp_int *bignum, int64_t initVal) MP_WUR; /* 65 */ int (*tclBN_mp_init_u64) (mp_int *bignum, uint64_t initVal) MP_WUR; /* 66 */ TCL_DEPRECATED_API("Use mp_expt_n") mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, unsigned int b, mp_int *c, int fast); /* 67 */ - void (*tclBN_mp_set_u64) (mp_int *a, uint64_t i); /* 68 */ - uint64_t (*tclBN_mp_get_mag_u64) (const mp_int *a) MP_WUR; /* 69 */ - void (*tclBN_mp_set_i64) (mp_int *a, int64_t i); /* 70 */ + void (*tclBN_mp_set_ull) (mp_int *a, uint64_t i); /* 68 */ + uint64_t (*tclBN_mp_get_mag_ull) (const mp_int *a) MP_WUR; /* 69 */ + void (*tclBN_mp_set_ll) (mp_int *a, int64_t i); /* 70 */ mp_err (*tclBN_mp_unpack) (mp_int *rop, size_t count, mp_order order, size_t size, mp_endian endian, size_t nails, const void *op) MP_WUR; /* 71 */ mp_err (*tclBN_mp_pack) (void *rop, size_t maxcount, size_t *written, mp_order order, size_t size, mp_endian endian, size_t nails, const mp_int *op) MP_WUR; /* 72 */ TCL_DEPRECATED_API("merged with mp_and") mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */ @@ -566,8 +566,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_div_3) /* 17 */ #define TclBN_mp_exch \ (tclTomMathStubsPtr->tclBN_mp_exch) /* 18 */ -#define TclBN_mp_expt_n \ - (tclTomMathStubsPtr->tclBN_mp_expt_n) /* 19 */ +#define TclBN_mp_expt_d \ + (tclTomMathStubsPtr->tclBN_mp_expt_d) /* 19 */ #define TclBN_mp_grow \ (tclTomMathStubsPtr->tclBN_mp_grow) /* 20 */ #define TclBN_mp_init \ @@ -650,8 +650,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_s_mp_sqr) /* 59 */ #define TclBN_s_mp_sub \ (tclTomMathStubsPtr->tclBN_s_mp_sub) /* 60 */ -#define TclBN_mp_init_ul \ - (tclTomMathStubsPtr->tclBN_mp_init_ul) /* 61 */ +#define TclBN_mp_init_set_int \ + (tclTomMathStubsPtr->tclBN_mp_init_set_int) /* 61 */ #define TclBN_mp_set_ul \ (tclTomMathStubsPtr->tclBN_mp_set_ul) /* 62 */ #define TclBN_mp_cnt_lsb \ @@ -664,12 +664,12 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_init_u64) /* 66 */ #define TclBN_mp_expt_d_ex \ (tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */ -#define TclBN_mp_set_u64 \ - (tclTomMathStubsPtr->tclBN_mp_set_u64) /* 68 */ -#define TclBN_mp_get_mag_u64 \ - (tclTomMathStubsPtr->tclBN_mp_get_mag_u64) /* 69 */ -#define TclBN_mp_set_i64 \ - (tclTomMathStubsPtr->tclBN_mp_set_i64) /* 70 */ +#define TclBN_mp_set_ull \ + (tclTomMathStubsPtr->tclBN_mp_set_ull) /* 68 */ +#define TclBN_mp_get_mag_ull \ + (tclTomMathStubsPtr->tclBN_mp_get_mag_ull) /* 69 */ +#define TclBN_mp_set_ll \ + (tclTomMathStubsPtr->tclBN_mp_set_ll) /* 70 */ #define TclBN_mp_unpack \ (tclTomMathStubsPtr->tclBN_mp_unpack) /* 71 */ #define TclBN_mp_pack \ diff --git a/libtommath/bn_deprecated.c b/libtommath/bn_deprecated.c index fc19092..477bc29 100644 --- a/libtommath/bn_deprecated.c +++ b/libtommath/bn_deprecated.c @@ -249,6 +249,15 @@ mp_err mp_expt_d(const mp_int *a, mp_digit b, mp_int *c) return mp_expt_n(a, (int)b, c); } #endif +#ifdef BN_MP_EXPT_U32_C +mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c) +{ + if (b > MP_MIN(MP_DIGIT_MAX, INT_MAX)) { + return MP_VAL; + } + return mp_expt_n(a, (int)b, c); +} +#endif #ifdef BN_MP_N_ROOT_EX_C mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) { diff --git a/libtommath/bn_mp_expt_n.c b/libtommath/bn_mp_expt_n.c index 19c0225..2b8b6d4 100644 --- a/libtommath/bn_mp_expt_n.c +++ b/libtommath/bn_mp_expt_n.c @@ -3,16 +3,6 @@ /* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ -#ifdef BN_MP_EXPT_U32_C -mp_err mp_expt_u32(const mp_int *a, uint32_t b, mp_int *c) -{ - if (b > MP_MIN(MP_DIGIT_MAX, INT_MAX)) { - return MP_VAL; - } - return mp_expt_n(a, (int)b, c); -} -#endif - /* calculate c = a**b using a square-multiply algorithm */ mp_err mp_expt_n(const mp_int *a, int b, mp_int *c) { |