diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/blake2/include/blake2s.h (renamed from lib/blake2/blake2s.h) | 0 | ||||
-rw-r--r-- | lib/blake2/meson.build | 24 | ||||
-rw-r--r-- | lib/blake2/tests/blake2s_kat.h (renamed from lib/blake2/test_blake2_kat.h) | 2 | ||||
-rw-r--r-- | lib/blake2/tests/blake2s_selftest.cc (renamed from lib/blake2/test_blake2s_selftest.cc) | 13 | ||||
-rw-r--r-- | lib/libk/include/endian.h (renamed from lib/libk/endian.h) | 0 | ||||
-rw-r--r-- | lib/libk/include/stdio.h (renamed from lib/libk/stdio.h) | 0 | ||||
-rw-r--r-- | lib/libk/include/stdlib.h (renamed from lib/libk/stdlib.h) | 0 | ||||
-rw-r--r-- | lib/libk/include/string.h (renamed from lib/libk/string.h) | 0 | ||||
-rw-r--r-- | lib/libk/meson.build | 41 | ||||
-rwxr-xr-x | lib/mk | 36 |
10 files changed, 72 insertions, 44 deletions
diff --git a/lib/blake2/blake2s.h b/lib/blake2/include/blake2s.h index ede170c..ede170c 100644 --- a/lib/blake2/blake2s.h +++ b/lib/blake2/include/blake2s.h diff --git a/lib/blake2/meson.build b/lib/blake2/meson.build new file mode 100644 index 0000000..dc06f3e --- /dev/null +++ b/lib/blake2/meson.build @@ -0,0 +1,24 @@ + +blake2s_srcs = files('blake2s.c') +blake2s_incl = include_directories('include') + +blake2s = declare_dependency( + link_with: static_library('blake2s', blake2s_srcs, + include_directories: blake2s_incl, + dependencies: libk), + include_directories: blake2s_incl, +) + +# tests +blake2s_sut = declare_dependency( + link_with: library('blake2s_sut', blake2s_srcs, + include_directories: blake2s_incl, + native: true), + include_directories: blake2s_incl, +) + +test('blake2s selftest', + executable('test_blake2s_selftest', 'tests/blake2s_selftest.cc', + dependencies: [ blake2s_sut, gtest ], + native: true) +) diff --git a/lib/blake2/test_blake2_kat.h b/lib/blake2/tests/blake2s_kat.h index aa42ef5..dec250a 100644 --- a/lib/blake2/test_blake2_kat.h +++ b/lib/blake2/tests/blake2s_kat.h @@ -1,5 +1,7 @@ #pragma once +#include <cstdint> + static const unsigned KATs_len = 256; static const uint8_t KAT_secret[32] = { 0xba, 0x80, 0xfb, 0x8f, 0x1b, 0x7b, 0xa1, 0x49, 0x3c, 0x6a, 0xe8, 0x8f, 0xd, 0x66, 0xa1, 0xae, 0xff, 0xa2, 0x5c, 0x8a, 0x7d, 0x4c, 0x1f, 0xb6, 0x81, 0x1, 0xb5, 0xe4, 0xc2, 0x8e, 0x37, 0x3 }; static const uint8_t KATs[256][32] = { diff --git a/lib/blake2/test_blake2s_selftest.cc b/lib/blake2/tests/blake2s_selftest.cc index 2c046b2..420544d 100644 --- a/lib/blake2/test_blake2s_selftest.cc +++ b/lib/blake2/tests/blake2s_selftest.cc @@ -1,8 +1,11 @@ // Self test Modules for BLAKE2s -#include "blake2s.c" -#include "test_blake2_kat.h" +#include "blake2s_kat.h" #include <gtest/gtest.h> +extern "C" { +#include "blake2s.h" +} + static_assert(sizeof(BLAKE2s_param) == (8 * sizeof(uint32_t)), "sizeof struct BLAKE2s_param"); // Deterministic sequences (Fibonacci generator). @@ -66,12 +69,6 @@ blake2s_selftest() return 0; } -TEST(blake2s, rotr_u32) -{ - EXPECT_EQ(rotr_u32(0xdecafade, 16), 0xfadedeca); - EXPECT_EQ(rotr_u32(0xdecafade, 8), 0xdedecafa); -} - TEST(blake2s, selftest) { EXPECT_EQ(blake2s_selftest(), 0); } TEST(blake2s, selftestAllInOne) diff --git a/lib/libk/endian.h b/lib/libk/include/endian.h index 6aa2669..6aa2669 100644 --- a/lib/libk/endian.h +++ b/lib/libk/include/endian.h diff --git a/lib/libk/stdio.h b/lib/libk/include/stdio.h index 7a6e663..7a6e663 100644 --- a/lib/libk/stdio.h +++ b/lib/libk/include/stdio.h diff --git a/lib/libk/stdlib.h b/lib/libk/include/stdlib.h index 143c931..143c931 100644 --- a/lib/libk/stdlib.h +++ b/lib/libk/include/stdlib.h diff --git a/lib/libk/string.h b/lib/libk/include/string.h index 45b05a5..45b05a5 100644 --- a/lib/libk/string.h +++ b/lib/libk/include/string.h diff --git a/lib/libk/meson.build b/lib/libk/meson.build new file mode 100644 index 0000000..669780b --- /dev/null +++ b/lib/libk/meson.build @@ -0,0 +1,41 @@ + +libk_srcs = files( + 'endian/little.c', + 'stdio/printf.c', 'stdio/fprintf.c', 'stdio/vfprintf.c', + 'stdlib/memcpy.c', 'stdlib/memset.c', 'stdlib/linked_list_allocator.c', + 'string/itoa.c') +libk_incl = include_directories('include') + +libk = declare_dependency( + link_with: static_library('k', libk_srcs, include_directories: libk_incl), + include_directories: libk_incl, +) + +# tests +test('endian little', + executable('test_endian_little', 'endian/test_endian_little.cc', + dependencies: [ gtest ], + native: true), + suite: 'libk' +) + +test('linked list allocator', + executable('test_linked_list_allocator', 'stdlib/test_linked_list_allocator.cc', + dependencies: [ gtest ], + native: true), + suite: 'libk' +) + +test('mem', + executable('test_mem', 'stdlib/test_mem.cc', + dependencies: [ gtest ], + native: true), + suite: 'libk' +) + +test('string', + executable('test_string', 'string/test_string.cc', + dependencies: [ gtest ], + native: true), + suite: 'libk' +) @@ -1,36 +0,0 @@ -#!../mach - -# minimal C standard library -TARGETLIB += libk -libk.SRCS = \ - libk/endian/little.c \ - libk/stdio/printf.c libk/stdio/fprintf.c libk/stdio/vfprintf.cpp \ - libk/stdlib/memcpy.c libk/stdlib/memset.c libk/stdlib/linked_list_allocator.c \ - libk/string/itoa.c - -HOSTTARGETBIN += libk/endian/test_endian_little -libk/endian/test_endian_little.SRCS = libk/endian/test_endian_little.cc - -HOSTTARGETBIN += libk/stdlib/test_linked_list_allocator -libk/stdlib/test_linked_list_allocator.SRCS = libk/stdlib/test_linked_list_allocator.cc - -HOSTTARGETBIN += libk/stdlib/test_mem -libk/stdlib/test_mem.SRCS = libk/stdlib/test_mem.cc - -HOSTTARGETBIN += libk/string/test_string -libk/string/test_string.SRCS = libk/string/test_string.cc - -TESTS += \ - libk/endian/test_endian_little \ - libk/stdlib/test_linked_list_allocator libk/stdlib/test_mem \ - libk/string/test_string - -# blake2s hash algorithm -TARGETLIB += blake2 -blake2.SRCS = blake2/blake2s.c - -HOSTTARGETBIN += blake2/test_blake2s_selftest -blake2/test_blake2s_selftest.SRCS = blake2/test_blake2s_selftest.cc - -TESTS += blake2/test_blake2s_selftest - |