]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(test_hash_large): New function.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 10 Oct 2005 15:40:54 +0000 (17:40 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 10 Oct 2005 15:40:54 +0000 (17:40 +0200)
Rev: src/nettle/testsuite/testutils.c:1.28
Rev: src/nettle/testsuite/testutils.h:1.23

testsuite/testutils.c
testsuite/testutils.h

index 801cf882d9a6a2c6e187658a600ac4678a55ba91..accf842924c2428c23a9fe8f7cb8dd781ebada58 100644 (file)
@@ -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,
index 46eb5c23e75a88d90407ed85fa470760408148bc..7cc4b1fb68ce077daa5de22794d529f8ea171902 100644 (file)
@@ -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,