summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclInt.h3
-rw-r--r--generic/tclStubInit.c5
-rw-r--r--generic/tclTomMath.decls15
-rw-r--r--generic/tclTomMath.h8
-rw-r--r--generic/tclTomMathDecls.h30
-rw-r--r--libtommath/tommath_private.h3
-rw-r--r--unix/Makefile.in5
-rw-r--r--win/Makefile.in1
-rw-r--r--win/makefile.vc1
9 files changed, 60 insertions, 11 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index a0955c9..cb18889 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4039,9 +4039,6 @@ MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
int before, int after, int *indexPtr);
MODULE_SCOPE int TclIndexDecode(int encoded, int endValue);
-MODULE_SCOPE int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written);
-MODULE_SCOPE size_t TclBN_mp_ubin_size(const mp_int *a);
-MODULE_SCOPE int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix);
MODULE_SCOPE void TclBN_int_reverse(unsigned char *s, size_t len);
/* Constants used in index value encoding routines. */
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 2df2aae..ce389bf 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -924,12 +924,15 @@ const TclTomMathStubs tclTomMathStubs = {
0, /* 69 */
TclBN_mp_set_long, /* 70 */
0, /* 71 */
- 0, /* 72 */
+ TclBN_mp_isodd, /* 72 */
TclBN_mp_tc_and, /* 73 */
TclBN_mp_tc_or, /* 74 */
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 = {
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index 1ac1cb9..01df31b 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -240,6 +240,9 @@ declare 67 {
declare 70 {
mp_err TclBN_mp_set_long(mp_int *a, unsigned long i)
}
+declare 72 {
+ mp_bool TclBN_mp_isodd(const mp_int *a)
+}
# Added in libtommath 1.1.0
declare 73 {
@@ -254,11 +257,21 @@ declare 75 {
declare 76 {
mp_err TclBN_mp_signed_rsh(const mp_int *a, int b, mp_int *c)
}
-
declare 77 {
mp_bool TclBN_mp_get_bit(const mp_int *a, unsigned int b)
}
+# Added in libtommath 1.2.0
+declare 78 {
+ int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written)
+}
+declare 79 {
+ size_t TclBN_mp_ubin_size(const mp_int *a)
+}
+declare 80 {
+ int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix)
+}
+
# Local Variables:
# mode: tcl
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 83a31d6..7b720e9 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -323,8 +323,12 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR;
/* ---> Basic Manipulations <--- */
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
-#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
+/*
+mp_bool mp_iseven(const mp_int *a) MP_WUR;
+*/
+/*
+mp_bool mp_isodd(const mp_int *a) MP_WUR;
+*/
#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
/* set to zero */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index be9d28e..a4c7e02 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -90,6 +90,7 @@
#define s_mp_karatsuba_mul TclBN_mp_karatsuba_mul
#define mp_karatsuba_sqr TclBN_mp_karatsuba_sqr
#define s_mp_karatsuba_sqr TclBN_mp_karatsuba_sqr
+#define mp_isodd TclBN_mp_isodd
#define mp_lshd TclBN_mp_lshd
#define mp_mod TclBN_mp_mod
#define mp_mod_2d TclBN_mp_mod_2d
@@ -331,7 +332,8 @@ EXTERN mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b,
/* 70 */
EXTERN mp_err TclBN_mp_set_long(mp_int *a, unsigned long i);
/* Slot 71 is reserved */
-/* Slot 72 is reserved */
+/* 72 */
+EXTERN mp_bool TclBN_mp_isodd(const mp_int *a);
/* 73 */
EXTERN mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b,
mp_int *c);
@@ -346,6 +348,14 @@ EXTERN mp_err TclBN_mp_signed_rsh(const mp_int *a, int b,
mp_int *c);
/* 77 */
EXTERN mp_bool TclBN_mp_get_bit(const mp_int *a, unsigned int b);
+/* 78 */
+EXTERN int TclBN_mp_to_ubin(const mp_int *a, unsigned char *buf,
+ size_t maxlen, size_t *written);
+/* 79 */
+EXTERN size_t TclBN_mp_ubin_size(const mp_int *a);
+/* 80 */
+EXTERN int TclBN_mp_to_radix(const mp_int *a, char *str,
+ size_t maxlen, size_t *written, int radix);
typedef struct TclTomMathStubs {
int magic;
@@ -423,12 +433,15 @@ typedef struct TclTomMathStubs {
void (*reserved69)(void);
mp_err (*tclBN_mp_set_long) (mp_int *a, unsigned long i); /* 70 */
void (*reserved71)(void);
- void (*reserved72)(void);
+ mp_bool (*tclBN_mp_isodd) (const mp_int *a); /* 72 */
mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */
mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */
mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */
mp_err (*tclBN_mp_signed_rsh) (const mp_int *a, int b, mp_int *c); /* 76 */
mp_bool (*tclBN_mp_get_bit) (const mp_int *a, unsigned int b); /* 77 */
+ int (*tclBN_mp_to_ubin) (const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written); /* 78 */
+ size_t (*tclBN_mp_ubin_size) (const mp_int *a); /* 79 */
+ int (*tclBN_mp_to_radix) (const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); /* 80 */
} TclTomMathStubs;
extern const TclTomMathStubs *tclTomMathStubsPtr;
@@ -584,7 +597,8 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
#define TclBN_mp_set_long \
(tclTomMathStubsPtr->tclBN_mp_set_long) /* 70 */
/* Slot 71 is reserved */
-/* Slot 72 is reserved */
+#define TclBN_mp_isodd \
+ (tclTomMathStubsPtr->tclBN_mp_isodd) /* 72 */
#define TclBN_mp_tc_and \
(tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */
#define TclBN_mp_tc_or \
@@ -595,11 +609,21 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
(tclTomMathStubsPtr->tclBN_mp_signed_rsh) /* 76 */
#define TclBN_mp_get_bit \
(tclTomMathStubsPtr->tclBN_mp_get_bit) /* 77 */
+#define TclBN_mp_to_ubin \
+ (tclTomMathStubsPtr->tclBN_mp_to_ubin) /* 78 */
+#define TclBN_mp_ubin_size \
+ (tclTomMathStubsPtr->tclBN_mp_ubin_size) /* 79 */
+#define TclBN_mp_to_radix \
+ (tclTomMathStubsPtr->tclBN_mp_to_radix) /* 80 */
#endif /* defined(USE_TCL_STUBS) */
/* !END!: Do not edit above this line. */
+#undef mp_isodd
+#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
+#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h
index fe78d27..654d294 100644
--- a/libtommath/tommath_private.h
+++ b/libtommath/tommath_private.h
@@ -304,4 +304,7 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len);
return (a->sign == MP_NEG) ? (type)-res : (type)res; \
}
+#undef mp_isodd
+#define mp_isodd TclBN_mp_isodd
+
#endif
diff --git a/unix/Makefile.in b/unix/Makefile.in
index a4715a8..91a8e20 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -326,7 +326,7 @@ TOMMATH_OBJS = bn_s_mp_reverse.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_get_bit.o bn_mp_grow.o bn_mp_init.o \
bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
bn_mp_init_size.o bn_s_mp_karatsuba_mul.o \
- bn_s_mp_karatsuba_sqr.o bn_s_mp_balance_mul.o \
+ bn_s_mp_karatsuba_sqr.o bn_s_mp_balance_mul.o bn_mp_isodd.o \
bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mul.o bn_mp_mul_2.o \
bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_neg.o bn_mp_or.o \
bn_mp_radix_size.o bn_mp_radix_smap.o \
@@ -1544,6 +1544,9 @@ bn_s_mp_karatsuba_sqr.o: $(TOMMATH_DIR)/bn_s_mp_karatsuba_sqr.c $(MATHHDRS)
bn_s_mp_balance_mul.o: $(TOMMATH_DIR)/bn_s_mp_balance_mul.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_s_mp_balance_mul.c
+bn_mp_isodd.o: $(TOMMATH_DIR)/bn_mp_isodd.c $(MATHHDRS)
+ $(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_isodd.c
+
bn_mp_lshd.o: $(TOMMATH_DIR)/bn_mp_lshd.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_lshd.c
diff --git a/win/Makefile.in b/win/Makefile.in
index 5e3252e..105fd41 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -337,6 +337,7 @@ TOMMATH_OBJS = \
bn_mp_init_multi.${OBJEXT} \
bn_mp_init_set.${OBJEXT} \
bn_mp_init_size.${OBJEXT} \
+ bn_mp_isodd.${OBJEXT} \
bn_mp_lshd.${OBJEXT} \
bn_mp_mod.${OBJEXT} \
bn_mp_mod_2d.${OBJEXT} \
diff --git a/win/makefile.vc b/win/makefile.vc
index 01cdb1f..7eb1d63 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -340,6 +340,7 @@ TOMMATHOBJS = \
$(TMP_DIR)\bn_mp_init_multi.obj \
$(TMP_DIR)\bn_mp_init_set.obj \
$(TMP_DIR)\bn_mp_init_size.obj \
+ $(TMP_DIR)\bn_mp_isodd.obj \
$(TMP_DIR)\bn_mp_lshd.obj \
$(TMP_DIR)\bn_mp_mod.obj \
$(TMP_DIR)\bn_mp_mod_2d.obj \