From: Simo Sorce Date: Thu, 8 Nov 2018 19:47:13 +0000 (-0500) Subject: Add convenience macro for size calculation X-Git-Tag: nettle_3.4.1rc1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98e309bef52ff325b67d5aa083dd384eace426fa;p=thirdparty%2Fnettle.git Add convenience macro for size calculation Returns number of limbs needed to contain N bytes long number. Signed-off-by: Simo Sorce --- diff --git a/gmp-glue.h b/gmp-glue.h index 648724bc..38cdd197 100644 --- a/gmp-glue.h +++ b/gmp-glue.h @@ -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. */