aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-07 16:07:31 +0200
committerMattias Andrée <maandree@kth.se>2022-07-07 16:07:31 +0200
commitc65cda9f1761a19eac33a2e9d1e16599472ae067 (patch)
tree7248789cf6b8cbab507d685e680a3553c99d6ed3 /common.h
parentBump year (diff)
downloadlibsha2-c65cda9f1761a19eac33a2e9d1e16599472ae067.tar.gz
libsha2-c65cda9f1761a19eac33a2e9d1e16599472ae067.tar.bz2
libsha2-c65cda9f1761a19eac33a2e9d1e16599472ae067.tar.xz
Use uint_leastN_t instead of uintN_t
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--common.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/common.h b/common.h
index c053fac..50e62ab 100644
--- a/common.h
+++ b/common.h
@@ -16,6 +16,23 @@
/**
+ * Truncate an unsigned integer to an unsigned 32-bit integer
+ *
+ * @param X:uint_least32_t The value to truncate
+ * @return :uint_least32_t The 32 lowest bits in `X`
+ */
+#define TRUNC32(X) ((X) & (uint_least32_t)0xFFFFFFFFUL)
+
+/**
+ * Truncate an unsigned integer to an unsigned 64-bit integer
+ *
+ * @param X:uint_least64_t The value to truncate
+ * @return :uint_least64_t The 64 lowest bits in `X`
+ */
+#define TRUNC64(X) ((X) & (uint_least64_t)0xFFFFFFFFFFFFFFFFULL)
+
+
+/**
* Process a chunk using SHA-2
*
* @param state The hashing state