diff options
Diffstat (limited to 'generic/tclStubInit.c')
-rw-r--r-- | generic/tclStubInit.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 30fa411..2df2aae 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -10,7 +10,7 @@ */ #include "tclInt.h" -#include "tommath.h" +#include "tommath_private.h" #ifdef __CYGWIN__ # include <wchar.h> @@ -70,6 +70,31 @@ static int TclSockMinimumBuffersOld(int sock, int size) } #endif +static MP_SET_UNSIGNED(bn_mp_set_ull, Tcl_WideUInt) + + +mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) +{ + bn_mp_set_ull(a, i); + return MP_OKAY; +} + +mp_err TclBN_mp_set_int(mp_int *a, unsigned long i) +{ + return TclBN_mp_set_long(a, i); +} + +mp_err TclBN_mp_init_set_int(mp_int *a, unsigned long i) +{ + mp_init(a); + return TclBN_mp_set_long(a, i); +} + +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); +} + #define TclSetStartupScriptPath setStartupScriptPath static void TclSetStartupScriptPath(Tcl_Obj *path) { @@ -400,6 +425,38 @@ static int formatInt(char *buffer, int n){ # define TclpGmtime_unix TclpGmtime #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 |