diff options
Diffstat (limited to 'com/BLAKE2/test/blake2s_kat.c')
-rw-r--r-- | com/BLAKE2/test/blake2s_kat.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/com/BLAKE2/test/blake2s_kat.c b/com/BLAKE2/test/blake2s_kat.c new file mode 100644 index 0000000..0581c18 --- /dev/null +++ b/com/BLAKE2/test/blake2s_kat.c @@ -0,0 +1,31 @@ +#include <assert.h> +#include <blake2s.h> +#include <stdio.h> +#include <string.h> + +#include "blake2s_kat.h" + +int +main(void) +{ + uint8_t in[256]; + for (int i = 0; i < 256; ++i) in[i] = i; + uint8_t out[32]; + + for (unsigned i = 0; i < KATs_len; ++i) { + assert(BLAKE2s(out, 32, NULL, 0, in, i) == 0); + assert(memcmp(out, KATs[i], 32) == 0); + } + + for (unsigned i = 0; i < 1; ++i) { + _Static_assert(sizeof(KAT_secret) == 32, "sizeof KAT_secret"); + assert(BLAKE2s(out, 32, KAT_secret, 32, in, i) == 0); + + for (unsigned j = 0; j < 32; ++j) printf("%02x ", out[j]); + printf("\n"); + for (unsigned j = 0; j < 32; ++j) printf("%02x ", secret_KATs[i][j]); + printf("\n"); + + assert(memcmp(out, secret_KATs[i], 32) == 0); + } +} |