From 85b12e691577b4d4fe09b80b06e91a801dc3dfa9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 1 Sep 2024 18:12:21 +0200 Subject: Move test files into t/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- shake256.c | 89 -------------------------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 shake256.c (limited to 'shake256.c') diff --git a/shake256.c b/shake256.c deleted file mode 100644 index 38c9b40..0000000 --- a/shake256.c +++ /dev/null @@ -1,89 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifdef SUPPORT_SHAKE -# define TEST -# include "common.h" - - -#define MSG5 "\x13" -#define MSG30 "\x53\x58\x7B\x19" -#define MSG1600_32 "\xA3\xA3\xA3\xA3" -#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 -#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 -#define MSG1600 MSG1600_800 MSG1600_800 -#define MSG1605 MSG1600_800 MSG1600_800 "\x03" -#define MSG1630 MSG1600_800 MSG1600_800 "\xA3\xA3\xA3\x23" - - -static struct testcase testcases[] = { - {1, 0, "", "46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762f"}, - {1, 5, MSG5, "48a5c11abaeeff092f3646ef0d6b3d3ff76c2f55f9c732ac6470c03764008212"}, - {1, 6, MSG30, "465d081dff875e396200e4481a3e9dcd88d079aa6d66226cb6ba454107cb81a7"}, - {1, 0, MSG1600, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d"}, - {1, 5, MSG1605, "98d093b067475760124ffb9204a5b327c6bb05c54ff234f0b43fac7240415166"}, - {1, 6, MSG1630, "8a8325079b0fc3265d52f59855cafe655df438aa639f6fec991f2494330ce32f"} -}; - - -#else -# define TEST_UNSUPPORTED -# include "common.h" -#endif - - -static int -main_test(void) -{ - TEST_MAIN("SHAKE256", SHAKE256); -} - - -int -main(void) -{ -#ifdef SUPPORT_SHAKE - struct libhashsum_hasher hasher; - char hexsum[1024]; -#endif - - int r = main_test(); - if (r) - return r; - - ASSERT(!libhashsum_init_shake256_hasher(&hasher, 8)); - ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=8]")); - ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); - ASSERT(hasher.hash_size == 1); - hex(hexsum, hasher.hash_output, hasher.hash_size); - ASSERT(!strcmp(hexsum, "46")); - - ASSERT(!libhashsum_init_shake256_hasher(&hasher, 32)); - ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=32]")); - ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); - ASSERT(hasher.hash_size == 4); - hex(hexsum, hasher.hash_output, hasher.hash_size); - ASSERT(!strcmp(hexsum, "46b9dd2b")); - - ASSERT(!libhashsum_init_shake256_hasher(&hasher, 32)); - ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=32]")); - ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); - ASSERT(hasher.hash_size == 4); - hex(hexsum, hasher.hash_output, hasher.hash_size); - ASSERT(!strcmp(hexsum, "cd8a920e")); - - ASSERT(!libhashsum_init_shake256_hasher(&hasher, 256)); - ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256")); - ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); - ASSERT(hasher.hash_size == 256/8); - hex(hexsum, hasher.hash_output, hasher.hash_size); - ASSERT(!strcmp(hexsum, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d")); - - ASSERT(!libhashsum_init_shake256_hasher(&hasher, 512)); - ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=512]")); - ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); - ASSERT(hasher.hash_size == 512/8); - hex(hexsum, hasher.hash_output, hasher.hash_size); - ASSERT(!strcmp(hexsum, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d" - "2d700caae7396ece96604440577da4f3aa22aeb8857f961c4cd8e06f0ae6610b")); - - return 0; -} -- cgit v1.2.3-70-g09d2