From: Niels Möller Date: Mon, 10 Oct 2005 15:40:54 +0000 (+0200) Subject: (test_hash_large): New function. X-Git-Tag: nettle_1.14_release_20051205~187 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96e96fe1145f1d425abdae0572ff659e81a0150d;p=thirdparty%2Fnettle.git (test_hash_large): New function. Rev: src/nettle/testsuite/testutils.c:1.28 Rev: src/nettle/testsuite/testutils.h:1.23 --- 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,