summaryrefslogtreecommitdiffstats
path: root/generic/tclStubInit.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-10-22 10:38:02 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-10-22 10:38:02 (GMT)
commit03475f06485c403570643f9b359d100d9a6f9ced (patch)
treea6c73d8e59bf06c49ebbc3b9c7905cf56a0bccac /generic/tclStubInit.c
parent9943a8a5796e398895d09e2d34c163704f90a8c3 (diff)
parent13e26826469250ca5f7887974c3ac716567cdf6d (diff)
downloadtcl-03475f06485c403570643f9b359d100d9a6f9ced.zip
tcl-03475f06485c403570643f9b359d100d9a6f9ced.tar.gz
tcl-03475f06485c403570643f9b359d100d9a6f9ced.tar.bz2
Update to latest libtommath, version 1.2.0
Diffstat (limited to 'generic/tclStubInit.c')
-rw-r--r--generic/tclStubInit.c59
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