]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
New constant NETTLE_MAX_HASH_CONTEXT_SIZE.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 20 Mar 2017 20:09:54 +0000 (21:09 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 20 Mar 2017 20:09:54 +0000 (21:09 +0100)
* nettle-internal.h (NETTLE_MAX_HASH_CONTEXT_SIZE): New constant.
* testsuite/meta-hash-test.c (test_main): Add sanity check for
NETTLE_MAX_HASH_CONTEXT_SIZE.

ChangeLog
nettle-internal.h
testsuite/meta-hash-test.c

index b67b44d10c927f133deff8d7c33963fb2bbc5273..d797e625b99779c33de9d1cb47972ba26041591c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-03-20  Niels Möller  <nisse@lysator.liu.se>
 
+       * nettle-internal.h (NETTLE_MAX_HASH_CONTEXT_SIZE): New constant.
+       * testsuite/meta-hash-test.c (test_main): Add sanity check for
+       NETTLE_MAX_HASH_CONTEXT_SIZE.
+
        * tools/nettle-hash.c (list_algorithms): Also display the internal
        context size.
 
index 4e3098bbdec38afaaa3e4bd3d9289b124f66b05d..9c4c699df0d7b1eb72df58ba64ddedffac2cb416 100644 (file)
@@ -54,6 +54,7 @@
 /* Arbitrary limits which apply to systems that don't have alloca */
 #define NETTLE_MAX_HASH_BLOCK_SIZE 128
 #define NETTLE_MAX_HASH_DIGEST_SIZE 64
+#define NETTLE_MAX_HASH_CONTEXT_SIZE (sizeof(struct sha3_224_ctx))
 #define NETTLE_MAX_SEXP_ASSOC 17
 #define NETTLE_MAX_CIPHER_BLOCK_SIZE 32
 
index 0dcd1b9b0b6b0fa55974f15ac71534f84bd005a7..f7fa536991cb8c92d231edcacf678c5ed2f68123 100644 (file)
@@ -1,6 +1,8 @@
 #include "testutils.h"
 #include "nettle-internal.h"
 #include "nettle-meta.h"
+/* For NETTLE_MAX_HASH_CONTEXT_SIZE */
+#include "sha3.h"
 
 const char* hashes[] = {
   "md2",
@@ -34,7 +36,8 @@ test_main(void)
   while (NULL != nettle_hashes[j])
     j++;
   ASSERT(j == count); /* we are not missing testing any hashes */
-  for (j = 0; NULL != nettle_hashes[j]; j++)
+  for (j = 0; NULL != nettle_hashes[j]; j++) {
     ASSERT(nettle_hashes[j]->digest_size <= NETTLE_MAX_HASH_DIGEST_SIZE);
+    ASSERT(nettle_hashes[j]->context_size <= NETTLE_MAX_HASH_CONTEXT_SIZE);
+  }
 }
-