diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-03-14 13:20:06 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-03-14 13:20:06 (GMT) |
commit | 2f7b3b25a44b2d4cae788262d093a4c2cbfee216 (patch) | |
tree | 02c154fcc3fcad9cbbb9be91ecb192bd6cf75ebf /libtommath/bn_mp_radix_size.c | |
parent | 072f17eb971ae3d3aff015ca39063774c876a17a (diff) | |
parent | e37816295674d1f53f8a42ed360885bfd7b1bb26 (diff) | |
download | tcl-2f7b3b25a44b2d4cae788262d093a4c2cbfee216.zip tcl-2f7b3b25a44b2d4cae788262d093a4c2cbfee216.tar.gz tcl-2f7b3b25a44b2d4cae788262d093a4c2cbfee216.tar.bz2 |
Revert previous commit: I was not aware that we have a fork of libtommathmistake_20110314
Diffstat (limited to 'libtommath/bn_mp_radix_size.c')
-rw-r--r-- | libtommath/bn_mp_radix_size.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c index 1b61e3a..40c4d04 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://libtom.org + * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com */ /* returns size of ASCII reprensentation */ @@ -66,13 +66,18 @@ 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. */ - *size = digs + 1; + /* + * 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 MP_OKAY; } #endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ |