diff options
| -rw-r--r-- | generic/tclStubInit.c | 22 | ||||
| -rw-r--r-- | generic/tclTomMath.decls | 8 | ||||
| -rw-r--r-- | generic/tclTomMathDecls.h | 29 |
3 files changed, 23 insertions, 36 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index ce389bf..ea53e42 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -73,21 +73,19 @@ static int TclSockMinimumBuffersOld(int sock, int size) static MP_SET_UNSIGNED(bn_mp_set_ull, Tcl_WideUInt) -mp_err TclBN_mp_set_long(mp_int *a, unsigned long i) +mp_err TclBN_mp_set_int(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); + mp_err result = mp_init(a); + if (result == MP_OKAY) { + bn_mp_set_ull(a, i); + } + return result; } int TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) @@ -432,7 +430,7 @@ mp_err mp_to_unsigned_bin(const mp_int *a, unsigned char *b) mp_err mp_to_unsigned_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen) { - size_t n = mp_ubin_size(a); + size_t n = TclBN_mp_unsigned_bin_size(a); if (*outlen < (unsigned long)n) { return MP_VAL; } @@ -447,8 +445,6 @@ mp_err mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) } 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) { @@ -922,7 +918,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_expt_d_ex, /* 67 */ 0, /* 68 */ 0, /* 69 */ - TclBN_mp_set_long, /* 70 */ + 0, /* 70 */ 0, /* 71 */ TclBN_mp_isodd, /* 72 */ TclBN_mp_tc_and, /* 73 */ @@ -931,7 +927,7 @@ const TclTomMathStubs tclTomMathStubs = { TclBN_mp_signed_rsh, /* 76 */ TclBN_mp_get_bit, /* 77 */ TclBN_mp_to_ubin, /* 78 */ - TclBN_mp_ubin_size, /* 79 */ + 0, /* 79 */ TclBN_mp_to_radix, /* 80 */ }; diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 01df31b..c8092aa 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -166,7 +166,7 @@ declare 46 { mp_err TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen) } declare 47 { - int TclBN_mp_unsigned_bin_size(const mp_int *a) + size_t TclBN_mp_unsigned_bin_size(const mp_int *a) } declare 48 { mp_err TclBN_mp_xor(const mp_int *a, const mp_int *b, mp_int *c) @@ -237,9 +237,6 @@ declare 66 { declare 67 { mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) } -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) } @@ -265,9 +262,6 @@ declare 77 { 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) } diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index a4c7e02..8d8ca67 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -104,8 +104,9 @@ #define mp_read_radix TclBN_mp_read_radix #define mp_rshd TclBN_mp_rshd #define mp_set TclBN_mp_set -#define mp_set_int TclBN_mp_set_int -#define mp_set_long TclBN_mp_set_long +#define mp_set_int(a,b) (TclBN_mp_set_int(a,(unsigned int)(b)),MP_OKAY) +#define mp_set_long(a,b) (TclBN_mp_set_int(a,b),MP_OKAY) +#define mp_set_ul(a,b) (void)TclBN_mp_set_int(a,b) #define mp_shrink TclBN_mp_shrink #define mp_sqr TclBN_mp_sqr #define mp_sqrt TclBN_mp_sqrt @@ -126,8 +127,8 @@ #define mp_toradix_n TclBN_mp_toradix_n #define mp_to_radix TclBN_mp_to_radix #define mp_to_ubin TclBN_mp_to_ubin -#define mp_ubin_size TclBN_mp_ubin_size -#define mp_unsigned_bin_size TclBN_mp_unsigned_bin_size +#define mp_ubin_size TclBN_mp_unsigned_bin_size +#define mp_unsigned_bin_size(a) ((int)TclBN_mp_unsigned_bin_size(a)) #define mp_xor TclBN_mp_xor #define mp_zero TclBN_mp_zero #define s_mp_add TclBN_s_mp_add @@ -276,7 +277,7 @@ EXTERN mp_err TclBN_mp_to_unsigned_bin_n(const mp_int *a, EXTERN mp_err TclBN_mp_toradix_n(const mp_int *a, char *str, int radix, int maxlen); /* 47 */ -EXTERN int TclBN_mp_unsigned_bin_size(const mp_int *a); +EXTERN size_t TclBN_mp_unsigned_bin_size(const mp_int *a); /* 48 */ EXTERN mp_err TclBN_mp_xor(const mp_int *a, const mp_int *b, mp_int *c); @@ -329,8 +330,7 @@ EXTERN mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast); /* Slot 68 is reserved */ /* Slot 69 is reserved */ -/* 70 */ -EXTERN mp_err TclBN_mp_set_long(mp_int *a, unsigned long i); +/* Slot 70 is reserved */ /* Slot 71 is reserved */ /* 72 */ EXTERN mp_bool TclBN_mp_isodd(const mp_int *a); @@ -351,8 +351,7 @@ 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); +/* Slot 79 is reserved */ /* 80 */ EXTERN int TclBN_mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); @@ -408,7 +407,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_to_unsigned_bin) (const mp_int *a, unsigned char *b); /* 44 */ mp_err (*tclBN_mp_to_unsigned_bin_n) (const mp_int *a, unsigned char *b, unsigned long *outlen); /* 45 */ mp_err (*tclBN_mp_toradix_n) (const mp_int *a, char *str, int radix, int maxlen); /* 46 */ - int (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */ + size_t (*tclBN_mp_unsigned_bin_size) (const mp_int *a); /* 47 */ mp_err (*tclBN_mp_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 48 */ void (*tclBN_mp_zero) (mp_int *a); /* 49 */ void (*tclBN_reverse) (unsigned char *s, int len); /* 50 */ @@ -431,7 +430,7 @@ typedef struct TclTomMathStubs { mp_err (*tclBN_mp_expt_d_ex) (const mp_int *a, mp_digit b, mp_int *c, int fast); /* 67 */ void (*reserved68)(void); void (*reserved69)(void); - mp_err (*tclBN_mp_set_long) (mp_int *a, unsigned long i); /* 70 */ + void (*reserved70)(void); void (*reserved71)(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 */ @@ -440,7 +439,7 @@ typedef struct TclTomMathStubs { 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 */ + void (*reserved79)(void); int (*tclBN_mp_to_radix) (const mp_int *a, char *str, size_t maxlen, size_t *written, int radix); /* 80 */ } TclTomMathStubs; @@ -594,8 +593,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (tclTomMathStubsPtr->tclBN_mp_expt_d_ex) /* 67 */ /* Slot 68 is reserved */ /* Slot 69 is reserved */ -#define TclBN_mp_set_long \ - (tclTomMathStubsPtr->tclBN_mp_set_long) /* 70 */ +/* Slot 70 is reserved */ /* Slot 71 is reserved */ #define TclBN_mp_isodd \ (tclTomMathStubsPtr->tclBN_mp_isodd) /* 72 */ @@ -611,8 +609,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr; (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 */ +/* Slot 79 is reserved */ #define TclBN_mp_to_radix \ (tclTomMathStubsPtr->tclBN_mp_to_radix) /* 80 */ |
