Skip to content
Snippets Groups Projects
Commit 4ba3332c authored by Niels Möller's avatar Niels Möller
Browse files

New constant NETTLE_MAX_HASH_CONTEXT_SIZE.

* 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.
parent a7dba70c
Branches
Tags
No related merge requests found
2017-03-20 Niels Möller <nisse@lysator.liu.se> 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 * tools/nettle-hash.c (list_algorithms): Also display the internal
context size. context size.
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
/* Arbitrary limits which apply to systems that don't have alloca */ /* Arbitrary limits which apply to systems that don't have alloca */
#define NETTLE_MAX_HASH_BLOCK_SIZE 128 #define NETTLE_MAX_HASH_BLOCK_SIZE 128
#define NETTLE_MAX_HASH_DIGEST_SIZE 64 #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_SEXP_ASSOC 17
#define NETTLE_MAX_CIPHER_BLOCK_SIZE 32 #define NETTLE_MAX_CIPHER_BLOCK_SIZE 32
......
#include "testutils.h" #include "testutils.h"
#include "nettle-internal.h" #include "nettle-internal.h"
#include "nettle-meta.h" #include "nettle-meta.h"
/* For NETTLE_MAX_HASH_CONTEXT_SIZE */
#include "sha3.h"
const char* hashes[] = { const char* hashes[] = {
"md2", "md2",
...@@ -34,7 +36,8 @@ test_main(void) ...@@ -34,7 +36,8 @@ test_main(void)
while (NULL != nettle_hashes[j]) while (NULL != nettle_hashes[j])
j++; j++;
ASSERT(j == count); /* we are not missing testing any hashes */ 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]->digest_size <= NETTLE_MAX_HASH_DIGEST_SIZE);
ASSERT(nettle_hashes[j]->context_size <= NETTLE_MAX_HASH_CONTEXT_SIZE);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment