Commit d9d72c36 authored by Niels Möller's avatar Niels Möller

Updated for new

hash function interface.

Rev: src/nettle/testsuite/md5-test.m4:1.3
Rev: src/nettle/testsuite/sha1-test.m4:1.3
Rev: src/nettle/testsuite/sha256-test.m4:1.2
Rev: src/nettle/testsuite/yarrow-test.c:1.10
parent e9c2786a
......@@ -6,7 +6,6 @@ struct md5_ctx ctx;
uint8_t digest[MD5_DIGEST_SIZE];
md5_init(&ctx);
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("D41D8CD98F00B204 E9800998ECF8427E")))
......@@ -18,50 +17,38 @@ md5_digest(&ctx, MD5_DIGEST_SIZE - 1, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("D41D8CD98F00B204 E9800998ECF84200")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 1, "a");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("0CC175B9C0F1B6A8 31C399E269772661")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 3, "abc");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("900150983cd24fb0 D6963F7D28E17F72")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 14, "message digest");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("F96B697D7CB7938D 525A2F31AAF161D0")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 26, "abcdefghijklmnopqrstuvwxyz");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("C3FCD3D76192E400 7DFB496CCA67E13B")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("D174AB98D277D9F5 A5611C2C9F419D9F")))
FAIL;
md5_init(&ctx);
md5_update(&ctx, 80, "1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890");
md5_final(&ctx);
md5_digest(&ctx, MD5_DIGEST_SIZE, digest);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("57EDF4A22BE3C955 AC49DA2E2107B67A")))
......
......@@ -6,16 +6,13 @@ struct sha1_ctx ctx;
uint8_t digest[SHA1_DIGEST_SIZE];
sha1_init(&ctx);
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("DA39A3EE5E6B4B0D 3255BFEF95601890 AFD80709")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 1, "a");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
......@@ -23,61 +20,50 @@ if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
FAIL;
memset(digest, 0, SHA1_DIGEST_SIZE);
sha1_update(&ctx, 1, "a");
sha1_digest(&ctx, SHA1_DIGEST_SIZE - 1, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("86F7E437FAA5A7FC E15D1DDCB9EAEAEA 37766700")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 1, "a");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("86F7E437FAA5A7FC E15D1DDCB9EAEAEA 377667B8")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 3, "abc");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("A9993E364706816A BA3E25717850C26C 9CD0D89D")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 26, "abcdefghijklmnopqrstuvwxyz");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("32D10C7B8CF96570 CA04CE37F2A19D84 240D3A89")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 14, "message digest");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("C12252CEDA8BE899 4D5FA0290A47231C 1D16AAE3")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
H("761C457BF73B14D2 7E9E9265C46F4B4D DA11F940")))
FAIL;
sha1_init(&ctx);
sha1_update(&ctx, 80, "1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890");
sha1_final(&ctx);
sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
if (!MEMEQ(SHA1_DIGEST_SIZE, digest,
......
......@@ -7,7 +7,6 @@ uint8_t digest[SHA256_DIGEST_SIZE];
sha256_init(&ctx);
sha256_update(&ctx, 3, "abc");
sha256_final(&ctx);
sha256_digest(&ctx, SHA256_DIGEST_SIZE, digest);
if (!MEMEQ(SHA256_DIGEST_SIZE, digest,
......@@ -15,25 +14,22 @@ if (!MEMEQ(SHA256_DIGEST_SIZE, digest,
FAIL;
memset(digest, 0, SHA256_DIGEST_SIZE);
sha256_update(&ctx, 3, "abc");
sha256_digest(&ctx, SHA256_DIGEST_SIZE - 1, digest);
if (!MEMEQ(SHA256_DIGEST_SIZE, digest,
H("ba7816bf8f01cfea 414140de5dae2223 b00361a396177a9c b410ff61f2001500")))
FAIL;
sha256_init(&ctx);
sha256_update(&ctx, 56, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
sha256_final(&ctx);
sha256_digest(&ctx, SHA256_DIGEST_SIZE, digest);
if (!MEMEQ(SHA256_DIGEST_SIZE, digest,
H("248d6a61d20638b8 e5c026930c3e6039 a33ce45964ff2167 f6ecedd419db06c1")))
FAIL;
sha256_init(&ctx);
sha256_update(&ctx, 112, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"
"ijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu");
sha256_final(&ctx);
sha256_digest(&ctx, SHA256_DIGEST_SIZE, digest);
if (!MEMEQ(SHA256_DIGEST_SIZE, digest,
......
......@@ -284,7 +284,7 @@ main(int argc, char **argv)
printf("Processed input: %d octets\n", processed);
printf(" sha256:");
}
sha256_final(&input_hash);
sha256_digest(&input_hash, sizeof(digest), digest);
if (verbose)
......@@ -318,7 +318,6 @@ main(int argc, char **argv)
printf(" sha256:");
}
sha256_final(&output_hash);
sha256_digest(&output_hash, sizeof(digest), digest);
if (verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment