/* See LICENSE file for copyright and license details. */
#ifdef SUPPORT_SHAKE
# define TEST
# include "common.h"
#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
static struct testcase testcases[] = {
{1, 0, "", "3a1108d4a90a31b85a10bdce77f4bfbdcc5b1d70dd405686f8bbde834aa1a410"},
{1, 0, MSG1600, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2"}
};
#else
# define TEST_UNSUPPORTED
# include "common.h"
#endif
static int
main_test(void)
{
TEST_MAIN("RawSHAKE256", RAWSHAKE256);
}
int
main(void)
{
#ifdef SUPPORT_RAWSHAKE
struct libhashsum_hasher hasher;
char hexsum[1024];
#endif
int r = main_test();
if (r)
return r;
ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 8));
ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[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, "3a"));
ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 32));
ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[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, "3a1108d4"));
ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 32));
ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[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, "f353b126"));
ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 256));
ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256"));
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, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2"));
ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 512));
ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[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, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2"
"3898431eb2500666c27251025869b0a6251029ba184e6075f5b3118cdc4abaa9"));
return 0;
}