diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-11-17 16:24:37 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-11-17 16:24:37 (GMT) |
commit | 2287394ba1bcf13a8abb6b8097f03e995cd3258a (patch) | |
tree | 4e47d8e8427fcbad172ecc5ae3e1199345b1aef7 /libtommath | |
parent | 37f6932c0ae7967ce2de2576acdd0a2fa016791b (diff) | |
parent | 8d1caeae4dbe404a28c14bdc0bc3a8e97f6eaaf2 (diff) | |
download | tcl-2287394ba1bcf13a8abb6b8097f03e995cd3258a.zip tcl-2287394ba1bcf13a8abb6b8097f03e995cd3258a.tar.gz tcl-2287394ba1bcf13a8abb6b8097f03e995cd3258a.tar.bz2 |
Fix libtommath's mp_radix_size() function such that it returns 2 for single-digit numbers. Add testcases for mp_radix_size() and mp_iseven(). Undo useless change in bn_mp_add_d.c (bring back libtommath's version).
Diffstat (limited to 'libtommath')
-rw-r--r-- | libtommath/bn_mp_add_d.c | 11 | ||||
-rw-r--r-- | libtommath/bn_mp_radix_size.c | 19 |
2 files changed, 14 insertions, 16 deletions
diff --git a/libtommath/bn_mp_add_d.c b/libtommath/bn_mp_add_d.c index 5281ad4..aec8fc8 100644 --- a/libtommath/bn_mp_add_d.c +++ b/libtommath/bn_mp_add_d.c @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /* single digit addition */ @@ -37,9 +37,8 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c) /* c = |a| - b */ res = mp_sub_d(a, b, c); - /* fix signs */ - a->sign = MP_NEG; - c->sign = (c->used) ? MP_NEG : MP_ZPOS; + /* fix sign */ + a->sign = c->sign = MP_NEG; /* clamp */ mp_clamp(c); @@ -107,3 +106,7 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c) } #endif + +/* $Source$ */ +/* $Revision: 0.41 $ */ +/* $Date: 2007-04-18 09:58:18 +0000 $ */ diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c index 40c4d04..9d95c48 100644 --- a/libtommath/bn_mp_radix_size.c +++ b/libtommath/bn_mp_radix_size.c @@ -12,7 +12,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com + * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ /* returns size of ASCII reprensentation */ @@ -66,18 +66,13 @@ int mp_radix_size (mp_int * a, int radix, int *size) } mp_clear (&t); - /* - * return digs + 1, the 1 is for the NULL byte that would be required. - * mp_toradix_n requires a minimum of 3 bytes, so never report less than - * that. - */ - - if ( digs >= 2 ) { - *size = digs + 1; - } else { - *size = 3; - } + /* return digs + 1, the 1 is for the NULL byte that would be required. */ + *size = digs + 1; return MP_OKAY; } #endif + +/* $Source$ */ +/* $Revision: 0.41 $ */ +/* $Date: 2007-04-18 09:58:18 +0000 $ */ |