]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(nettle_mpz_sizeinbase_256): New function.
authorNiels Möller <nisse@lysator.liu.se>
Sun, 29 Sep 2002 17:22:32 +0000 (19:22 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 29 Sep 2002 17:22:32 +0000 (19:22 +0200)
Rev: src/nettle/bignum.c:1.4
Rev: src/nettle/bignum.h:1.3

bignum.c
bignum.h

index d1c3c5d049e1cc974b4ca14c3a2bbc672a1a3c92..67abe5d834903dac2c66c47713a8988eb2f4457e 100644 (file)
--- a/bignum.c
+++ b/bignum.c
 #include <assert.h>
 #include <string.h>
 
+unsigned
+nettle_mpz_sizeinbase_256(const mpz_t x)
+{
+  return (mpz_sizeinbase(x, 2) + 7) / 8;
+}
+
 void
 nettle_mpz_get_str_256(unsigned length, uint8_t *s, const mpz_t x)
 {
@@ -49,7 +55,7 @@ nettle_mpz_get_str_256(unsigned length, uint8_t *s, const mpz_t x)
     }
   
   assert(mpz_sgn(x) >= 0);
-  assert( (mpz_sizeinbase(x, 2) + 7) / 8 <= length);
+  assert(nettle_mpz_sizeinbase_256(x) <= length);
 
   for (i = 0; i<size; i++)
     {
index b4cfcc372ab6d3e9d2c2bb93d6ac823dfb532fc4..c26d18477576874656e7a8ca24e3fd45c1480baf 100644 (file)
--- a/bignum.h
+++ b/bignum.h
@@ -29,6 +29,9 @@
 #include <gmp.h>
 #include <inttypes.h>
 
+unsigned
+nettle_mpz_sizeinbase_256(const mpz_t x);
+
 /* Writes an unsigned integer as length octets, using big endian byte
  * order. */
 void