From 96e96fe1145f1d425abdae0572ff659e81a0150d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 10 Oct 2005 17:40:54 +0200
Subject: [PATCH] (test_hash_large): New function.

Rev: src/nettle/testsuite/testutils.c:1.28
Rev: src/nettle/testsuite/testutils.h:1.23
---
 testsuite/testutils.c | 28 ++++++++++++++++++++++++++++
 testsuite/testutils.h |  6 ++++++
 2 files changed, 34 insertions(+)

diff --git a/testsuite/testutils.c b/testsuite/testutils.c
index 801cf882..accf8429 100644
--- a/testsuite/testutils.c
+++ b/testsuite/testutils.c
@@ -341,6 +341,34 @@ test_hash(const struct nettle_hash *hash,
   free(buffer);
 }
 
+void
+test_hash_large(const struct nettle_hash *hash,
+		unsigned count, unsigned length,
+		uint8_t c,
+		const uint8_t *digest)
+{
+  void *ctx = xalloc(hash->context_size);
+  uint8_t *buffer = xalloc(hash->digest_size);
+  uint8_t *data = xalloc(length);
+  unsigned i;
+
+  memset(data, c, length);
+
+  hash->init(ctx);
+  for (i = 0; i < count; i++)
+    hash->update(ctx, length, data);
+  hash->digest(ctx, hash->digest_size, buffer);
+
+  print_hex(hash->digest_size, buffer);
+
+  if (!MEMEQ(hash->digest_size, digest, buffer))
+    FAIL();
+
+  free(ctx);
+  free(buffer);
+  free(data);
+}
+
 void
 test_armor(const struct nettle_armor *armor,
            unsigned data_length,
diff --git a/testsuite/testutils.h b/testsuite/testutils.h
index 46eb5c23..7cc4b1fb 100644
--- a/testsuite/testutils.h
+++ b/testsuite/testutils.h
@@ -86,6 +86,12 @@ test_hash(const struct nettle_hash *hash,
 	  const uint8_t *data,
 	  const uint8_t *digest);
 
+void
+test_hash_large(const struct nettle_hash *hash,
+		unsigned count, unsigned length,
+		uint8_t c,
+		const uint8_t *digest);
+
 void
 test_armor(const struct nettle_armor *armor,
            unsigned data_length,
-- 
GitLab