]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Add convenience macro for size calculation
authorSimo Sorce <simo@redhat.com>
Thu, 8 Nov 2018 19:47:13 +0000 (14:47 -0500)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 24 Nov 2018 09:18:09 +0000 (10:18 +0100)
Returns number of limbs needed to contain N bytes long number.

Signed-off-by: Simo Sorce <simo@redhat.com>
gmp-glue.h

index 648724bc756f6c57c8942bf996d2392f353097ff..38cdd197ee0d82ddaaef286ef97d841b41acd33f 100644 (file)
@@ -81,6 +81,9 @@
 # define cnd_sub_n(cnd, rp, ap, n) mpn_submul_1 ((rp), (ap), (n), (cnd) != 0)
 #endif
 
+#define NETTLE_OCTET_SIZE_TO_LIMB_SIZE(n) \
+  (((n) * 8 + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)
+
 /* Some functions for interfacing between mpz and mpn code. Signs of
    the mpz numbers are generally ignored. */