diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-04-16 11:46:34 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-04-16 11:46:34 +0000 |
commit | 5cbeb1586b7a5a0d5975ee7dc0cd6a2d471b940a (patch) | |
tree | 70abff35ecf47035630d2d3af29600bd6146bd5b /src/lib/tests/sha3_test.c | |
parent | 9c6750d70b591af5429fcafbad19aede69e21675 (diff) | |
parent | 97ef24340da7d3f55a39ba16b400d13f9bbe9e60 (diff) | |
download | ouroboros-5cbeb1586b7a5a0d5975ee7dc0cd6a2d471b940a.tar.gz ouroboros-5cbeb1586b7a5a0d5975ee7dc0cd6a2d471b940a.zip |
Merged in dstaesse/ouroboros/be-hashing (pull request #484)
Be hashing
Diffstat (limited to 'src/lib/tests/sha3_test.c')
-rw-r--r-- | src/lib/tests/sha3_test.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/tests/sha3_test.c b/src/lib/tests/sha3_test.c index 8f1bce05..0d0e8d0a 100644 --- a/src/lib/tests/sha3_test.c +++ b/src/lib/tests/sha3_test.c @@ -149,6 +149,12 @@ int sha3_test(int argc, "ijklmnopjklmnopqklmnopqrlmnopqrs" "mnopqrstnopqrstu"; + char * str4_inp2 = + " abcdefghbcdefghicdefghijdefghijk" + "efghijklfghijklmghijklmnhijklmno" + "ijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu"; + char * str4_224 = "543e6868e1666c1a643630df77367ae5" "a62a85070a51c14cbf665cbc"; @@ -292,5 +298,36 @@ int sha3_test(int argc, if (check_hash(str4_512, res, SHA3_512_HASH_LEN)) return -1; + /* unaligned 4th input string. */ + printf("test: %s.\n\n", str4_inp2 + 1); + + rhash_sha3_224_init(&ctx); + rhash_sha3_update(&ctx, str4_inp2 + 1, strlen(str4_inp2 + 1)); + rhash_sha3_final(&ctx, res); + + if (check_hash(str4_224, res, SHA3_224_HASH_LEN)) + return -1; + + rhash_sha3_256_init(&ctx); + rhash_sha3_update(&ctx, str4_inp2 + 1, strlen(str4_inp2 + 1)); + rhash_sha3_final(&ctx, res); + + if (check_hash(str4_256, res, SHA3_256_HASH_LEN)) + return -1; + + rhash_sha3_384_init(&ctx); + rhash_sha3_update(&ctx, str4_inp2 + 1, strlen(str4_inp2 + 1)); + rhash_sha3_final(&ctx, res); + + if (check_hash(str4_384, res, SHA3_384_HASH_LEN)) + return -1; + + rhash_sha3_512_init(&ctx); + rhash_sha3_update(&ctx, str4_inp2 + 1, strlen(str4_inp2 + 1)); + rhash_sha3_final(&ctx, res); + + if (check_hash(str4_512, res, SHA3_512_HASH_LEN)) + return -1; + return 0; } |