diff options
Diffstat (limited to 'com/BLAKE2')
-rw-r--r-- | com/BLAKE2/meson.build | 7 | ||||
-rw-r--r-- | com/BLAKE2/test/blake2s_selftest.c (renamed from com/BLAKE2/test_main.c) | 9 | ||||
-rw-r--r-- | com/BLAKE2/test_fns.c | 34 |
3 files changed, 11 insertions, 39 deletions
diff --git a/com/BLAKE2/meson.build b/com/BLAKE2/meson.build index 1592dd7..7d180e3 100644 --- a/com/BLAKE2/meson.build +++ b/com/BLAKE2/meson.build @@ -1,14 +1,15 @@ #BLAKE2s = static_library('BLAKE2s', 'blake2s.c') BLAKE2s_native = shared_library('BLAKE2s_native', 'blake2s.c', native: true) -test('BLAKE2s functions', executable('b2s_fns', 'test_fns.c', link_with: BLAKE2s_native, native: true), suite: 'BLAKE2') -test('BLAKE2s selftest', executable('b2s_selftest', 'test_main.c', link_with: BLAKE2s_native, native: true), suite: 'BLAKE2') - kat = generator(python3, arguments: '@INPUT@', capture: true, output: '@BASENAME@.h' ) +test('BLAKE2s selftest', + executable('b2s_selftest', 'test/blake2s_selftest.c', link_with: BLAKE2s_native, native: true), + suite: 'BLAKE2' +) test('BLAKE2s KAT', executable('b2s_kat', ['test/blake2s_kat.c', kat.process('test/blake2s_kat.py')], link_with: BLAKE2s_native, native: true), diff --git a/com/BLAKE2/test_main.c b/com/BLAKE2/test/blake2s_selftest.c index 80828bb..3ada150 100644 --- a/com/BLAKE2/test_main.c +++ b/com/BLAKE2/test/blake2s_selftest.c @@ -2,10 +2,12 @@ // Self test Modules for BLAKE2b and BLAKE2s -- and a stub main(). #include "blake2s.h" +#include <assert.h> #include <stdio.h> -// Deterministic sequences (Fibonacci generator). +_Static_assert(sizeof(struct BLAKE2s_param) == (8 * sizeof(uint32_t)), "sizeof struct BLAKE2s_param"); +// Deterministic sequences (Fibonacci generator). static void selftest_seq(uint8_t *out, size_t len, uint32_t seed) { @@ -66,10 +68,13 @@ blake2s_selftest() return 0; } -// Test driver. int main(void) { + // functions + assert(rotr_u32(0xdecafade, 16) == 0xfadedeca); + assert(rotr_u32(0xdecafade, 8) == 0xdedecafa); + const int good = blake2s_selftest(); printf("blake2s_selftest() = %s\n", good ? "FAIL" : "OK"); diff --git a/com/BLAKE2/test_fns.c b/com/BLAKE2/test_fns.c deleted file mode 100644 index ca3551a..0000000 --- a/com/BLAKE2/test_fns.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "blake2s.h" -#include <assert.h> -#include <stdio.h> - -_Static_assert(sizeof(struct BLAKE2s_param) == (8 * sizeof(uint32_t)), "sizeof struct BLAKE2s_param"); - -int -main(void) -{ - assert(rotr_u32(0xdecafade, 16) == 0xfadedeca); - assert(rotr_u32(0xdecafade, 8) == 0xdedecafa); - - union { - struct BLAKE2s_param block; - uint32_t data[8]; - } p; - p.block.outlen = 32; - p.block.keylen = 0; - p.block.fanout = 1; - p.block.depth = 1; - p.block.leaf_length = 0; - p.block.node_offset = 0; - p.block.node_offset_ex = 0; - p.block.node_depth = 0; - p.block.inner_length = 0; - p.block.salt = 0; - p.block.personalization = 0; - - for (int i = 0; i < 8; ++i) printf("%08x ", p.data[i]); - printf("\n"); - - assert(p.data[0] == (0x01010000 ^ 32)); - -} |