summaryrefslogtreecommitdiff
path: root/gmp-glue.h
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2018-11-08 14:47:13 -0500
committerNiels Möller <nisse@lysator.liu.se>2018-11-24 10:18:09 +0100
commit98e309bef52ff325b67d5aa083dd384eace426fa (patch)
tree17de7654e8ef686ccdd49bf2710f2f6340a4fafc /gmp-glue.h
parent51b64bb84ca860a7b39d1cd121b03e2db3b67743 (diff)
downloadnettle-98e309bef52ff325b67d5aa083dd384eace426fa.tar.gz
Add convenience macro for size calculation
Returns number of limbs needed to contain N bytes long number. Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'gmp-glue.h')
-rw-r--r--gmp-glue.h3
1 files changed, 3 insertions, 0 deletions
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. */