summaryrefslogtreecommitdiffstats
path: root/generic/tclStubInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclStubInit.c')
-rw-r--r--generic/tclStubInit.c85
1 files changed, 48 insertions, 37 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index ef49ca9..8aea217 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -93,10 +93,13 @@ mp_err TclBN_mp_set_int(mp_int *a, unsigned long i)
mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long i)
{
- mp_init(a);
+ mp_err result = mp_init(a);
+ if (result == MP_OKAY) {
TclBN_mp_set_ul(a, i);
- return MP_OKAY;
+ }
+ return result;
}
+
static mp_err TclBN_mp_set_long(mp_int *a, unsigned long i)
{
TclBN_mp_set_ul(a, i);
@@ -105,12 +108,10 @@ static mp_err TclBN_mp_set_long(mp_int *a, unsigned long i)
#define TclBN_mp_set_ul (void (*)(mp_int *a, unsigned long i))TclBN_mp_set_long
-int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
-{
- return mp_expt_u32(a, b, c);
-}
-
#if defined(TCL_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
+# define TclBN_mp_expt_d_ex 0
+# define TclBN_mp_to_unsigned_bin 0
+# define TclBN_mp_to_unsigned_bin_n 0
# define TclSetStartupScriptPath 0
# define TclGetStartupScriptPath 0
# define TclSetStartupScriptFileName 0
@@ -142,6 +143,42 @@ int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
# define Tcl_DbNewLongObj 0
# define Tcl_BackgroundError 0
#else
+
+int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
+{
+ return mp_expt_u32(a, b, c);
+}
+
+mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
+{
+ return mp_to_ubin(a, b, INT_MAX, NULL);
+}
+
+mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
+{
+ size_t n = mp_ubin_size(a);
+ if (*outlen < (unsigned long)n) {
+ return MP_VAL;
+ }
+ *outlen = (unsigned long)n;
+ return mp_to_ubin(a, b, n, NULL);
+}
+
+void bn_reverse(unsigned char *s, int len)
+{
+ if (len > 0) {
+ s_mp_reverse(s, (size_t)len);
+ }
+}
+
+mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
+{
+ if (maxlen < 0) {
+ return MP_VAL;
+ }
+ return mp_to_radix(a, str, (size_t)maxlen, NULL, radix);
+}
+
#define TclBNInitBignumFromLong initBignumFromLong
static void TclBNInitBignumFromLong(mp_int *a, long b)
{
@@ -505,38 +542,9 @@ tellOld(
#define Tcl_WinTCharToUtf 0
#endif
-mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
-{
- return mp_to_ubin(a, b, INT_MAX, NULL);
-}
-
-mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
-{
- size_t n = mp_ubin_size(a);
- if (*outlen < (unsigned long)n) {
- return MP_VAL;
- }
- *outlen = (unsigned long)n;
- return mp_to_ubin(a, b, n, NULL);
-}
-
-mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen)
-{
- if (maxlen < 0) {
- return MP_VAL;
- }
- return mp_to_radix(a, str, (size_t)maxlen, NULL, radix);
-}
#undef TclBN_mp_unsigned_bin_size
#define TclBN_mp_unsigned_bin_size (int (*)(const mp_int *a)) mp_ubin_size
-void bn_reverse(unsigned char *s, int len)
-{
- if (len > 0) {
- s_mp_reverse(s, (size_t)len);
- }
-}
-
/*
* WARNING: The contents of this file is automatically generated by the
* tools/genStubs.tcl script. Any modifications to the function declarations
@@ -960,7 +968,7 @@ const TclTomMathStubs tclTomMathStubs = {
TclBN_mp_div_2d, /* 16 */
TclBN_mp_div_3, /* 17 */
TclBN_mp_exch, /* 18 */
- TclBN_mp_expt_d, /* 19 */
+ TclBN_mp_expt_u32, /* 19 */
TclBN_mp_grow, /* 20 */
TclBN_mp_init, /* 21 */
TclBN_mp_init_copy, /* 22 */
@@ -1019,6 +1027,9 @@ const TclTomMathStubs tclTomMathStubs = {
TclBN_mp_tc_xor, /* 75 */
TclBN_mp_signed_rsh, /* 76 */
TclBN_mp_get_bit, /* 77 */
+ TclBN_mp_to_ubin, /* 78 */
+ TclBN_mp_ubin_size, /* 79 */
+ TclBN_mp_to_radix, /* 80 */
};
static const TclStubHooks tclStubHooks = {