aboutsummaryrefslogtreecommitdiffstats
path: root/blake384.c
diff options
context:
space:
mode:
Diffstat (limited to 'blake384.c')
-rw-r--r--blake384.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/blake384.c b/blake384.c
index a333e09..d4031e5 100644
--- a/blake384.c
+++ b/blake384.c
@@ -119,8 +119,69 @@ static struct testcase testcases[] = {
#endif
+static int
+kat_test(void)
+{
+ TEST_MAIN("BLAKE384", BLAKE384);
+}
+
+
int
main(void)
{
- TEST_MAIN("BLAKE384", BLAKE384);
+#ifdef SUPPORT_BLAKE384
+ struct libhashsum_hasher hasher1, hasher2;
+ char salt1[32], salt2[32];
+#endif
+
+ int r = kat_test();
+ if (r)
+ return r;
+
+#ifdef SUPPORT_BLAKE384
+ memset(salt1, 0, sizeof(salt1));
+ memset(salt2, 0xAB, sizeof(salt2));
+
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher1, NULL));
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt1));
+ ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384"));
+ ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384"));
+ ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0));
+ ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0));
+ ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size));
+
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher1, NULL));
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt1));
+ ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0));
+ ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0));
+ ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size));
+
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher1, salt1));
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt2));
+ ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384"));
+ ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384[salt=abababababababababababababababab"
+ "abababababababababababababababab]"));
+ ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0));
+ ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0));
+ ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size));
+
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher1, salt1));
+ ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt2));
+ ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0));
+ ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0));
+ ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size));
+
+ ASSERT(!libhashsum_init_hasher_from_string(&hasher1, "BLAKE384[salt=00000000000000000000000000000000"
+ "00000000000000000000000000000000]"));
+ ASSERT(!libhashsum_init_hasher_from_string(&hasher2, "BLAKE384[salt=abababababababababababababababab"
+ "abababababababababababababababab]"));
+ ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384"));
+ ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384[salt=abababababababababababababababab"
+ "abababababababababababababababab]"));
+ ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0));
+ ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0));
+ ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size));
+#endif
+
+ return 0;
}