From df4e07bd995ce199fcc69ca82dd538c4e6e96746 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Sun, 29 Sep 2002 19:22:32 +0200
Subject: [PATCH] (nettle_mpz_sizeinbase_256): New function.

Rev: src/nettle/bignum.c:1.4
Rev: src/nettle/bignum.h:1.3
---
 bignum.c | 8 +++++++-
 bignum.h | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/bignum.c b/bignum.c
index d1c3c5d0..67abe5d8 100644
--- a/bignum.c
+++ b/bignum.c
@@ -34,6 +34,12 @@
 #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++)
     {
diff --git a/bignum.h b/bignum.h
index b4cfcc37..c26d1847 100644
--- 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
-- 
GitLab