@@ -8,10 +8,6 @@ set(CMAKE_VERBOSE_MAKEFILE ON) | |||||
set(UPQCL_LIBRARY_VER ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) | set(UPQCL_LIBRARY_VER ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) | ||||
set(CMAKE_C_STANDARD 99) | set(CMAKE_C_STANDARD 99) | ||||
if(PLATFORM STREQUAL "stm32disco") | |||||
include_directories(${PROJECT_SOURCE_DIR}/platform/stm32disco) | |||||
endif() | |||||
# Global configuration | # Global configuration | ||||
string(APPEND CMAKE_C_FLAGS "-Os ") | string(APPEND CMAKE_C_FLAGS "-Os ") | ||||
string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ") | string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ") | ||||
@@ -35,8 +31,6 @@ set(uEXAMPLE_SRC | |||||
${PROJECT_SOURCE_DIR}/src/common/keccakf1600.S | ${PROJECT_SOURCE_DIR}/src/common/keccakf1600.S | ||||
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s | ${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s | ||||
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512.c | ${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512.c | ||||
${PROJECT_SOURCE_DIR}/src/common/randombytes.c | |||||
#${PROJECT_SOURCE_DIR}/src/common/hal-stm32f4.c | |||||
${PROJECT_SOURCE_DIR}/src/saber/cbd.c | ${PROJECT_SOURCE_DIR}/src/saber/cbd.c | ||||
${PROJECT_SOURCE_DIR}/src/saber/kem.c | ${PROJECT_SOURCE_DIR}/src/saber/kem.c | ||||
${PROJECT_SOURCE_DIR}/src/saber/mul.S | ${PROJECT_SOURCE_DIR}/src/saber/mul.S | ||||
@@ -50,23 +44,15 @@ set(uEXAMPLE_SRC | |||||
${PROJECT_SOURCE_DIR}/src/saber/verify.c) | ${PROJECT_SOURCE_DIR}/src/saber/verify.c) | ||||
add_library( | add_library( | ||||
uexample_obj OBJECT | |||||
example STATIC | |||||
${uEXAMPLE_SRC}) | ${uEXAMPLE_SRC}) | ||||
target_include_directories( | target_include_directories( | ||||
uexample_obj PRIVATE | |||||
example PRIVATE | |||||
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include | #${PROJECT_SOURCE_DIR}/3rd/libopencm3/include | ||||
${PROJECT_SOURCE_DIR}/src/common | ${PROJECT_SOURCE_DIR}/src/common | ||||
${PROJECT_SOURCE_DIR}/src/sabre) | ${PROJECT_SOURCE_DIR}/src/sabre) | ||||
add_executable( | |||||
uexample_test | |||||
${uEXAMPLE_SRC} | |||||
${PROJECT_SOURCE_DIR}/src/test.c | |||||
) | |||||
target_include_directories( | |||||
uexample_test PRIVATE | |||||
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include | |||||
${PROJECT_SOURCE_DIR}/src/common | |||||
${PROJECT_SOURCE_DIR}/src/saber) | |||||
if(PLATFORM STREQUAL "stm32disco") | |||||
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/stm32disco) | |||||
endif() |
@@ -9,11 +9,7 @@ enum clock_mode { | |||||
CLOCK_BENCHMARK | CLOCK_BENCHMARK | ||||
}; | }; | ||||
static void hal_setup(const enum clock_mode clock) { | |||||
UNUSED(clock); | |||||
} | |||||
static void hal_send_str(const char* in) { | |||||
UNUSED(in); | |||||
} | |||||
void hal_setup(const enum clock_mode clock); | |||||
void hal_send_str(const char* in); | |||||
#endif | #endif |
@@ -1,9 +1,26 @@ | |||||
add_executable( | |||||
uexample_test | |||||
${PROJECT_SOURCE_DIR}/test/test.c | |||||
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/hal.c | |||||
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/randombytes.c | |||||
) | |||||
target_include_directories( | |||||
uexample_test PRIVATE | |||||
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include | |||||
${PROJECT_SOURCE_DIR}/src/common | |||||
${PROJECT_SOURCE_DIR}/src/saber | |||||
${PROJECT_SOURCE_DIR}/platform | |||||
${PROJECT_SOURCE_DIR}/platform/${PLATFORM} | |||||
${PROJECT_SOURCE_DIR}/${PLATFORM_INC}) | |||||
target_link_libraries( | target_link_libraries( | ||||
uexample_test PRIVATE | uexample_test PRIVATE | ||||
example | |||||
--static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group | --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group | ||||
-T${PROJECT_SOURCE_DIR}/platform/stm32disco/stm32f405x6.ld | -T${PROJECT_SOURCE_DIR}/platform/stm32disco/stm32f405x6.ld | ||||
-nostartfiles -Wl,--gc-sections | -nostartfiles -Wl,--gc-sections | ||||
cmsis) | |||||
-L${PROJECT_SOURCE_DIR}/3rd/libopencm3/lib -lm -lopencm3_stm32f4) | |||||
add_custom_command( | add_custom_command( | ||||
TARGET uexample_test POST_BUILD | TARGET uexample_test POST_BUILD | ||||
@@ -1,5 +1,5 @@ | |||||
#include <stdint.h> | #include <stdint.h> | ||||
//#include <libopencm3/stm32/rng.h> | |||||
#include <libopencm3/stm32/rng.h> | |||||
#include "randombytes.h" | #include "randombytes.h" | ||||
//TODO Maybe we do not want to use the hardware RNG for all randomness, but instead only read a seed and then expand that using fips202. | //TODO Maybe we do not want to use the hardware RNG for all randomness, but instead only read a seed and then expand that using fips202. | ||||
@@ -14,23 +14,19 @@ int randombytes(uint8_t *obuf, size_t len) | |||||
while (len > 4) | while (len > 4) | ||||
{ | { | ||||
/* | |||||
random.asint = rng_get_random_blocking(); | random.asint = rng_get_random_blocking(); | ||||
*obuf++ = random.aschar[0]; | *obuf++ = random.aschar[0]; | ||||
*obuf++ = random.aschar[1]; | *obuf++ = random.aschar[1]; | ||||
*obuf++ = random.aschar[2]; | *obuf++ = random.aschar[2]; | ||||
*obuf++ = random.aschar[3]; | *obuf++ = random.aschar[3]; | ||||
len -= 4; | len -= 4; | ||||
*/ | |||||
} | } | ||||
if (len > 0) | if (len > 0) | ||||
{ | { | ||||
/* | |||||
for (random.asint = rng_get_random_blocking(); len > 0; --len) | for (random.asint = rng_get_random_blocking(); len > 0; --len) | ||||
{ | { | ||||
*obuf++ = random.aschar[len - 1]; | *obuf++ = random.aschar[len - 1]; | ||||
} | } | ||||
*/ | |||||
} | } | ||||
return 0; | return 0; |
@@ -13,4 +13,5 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||||
set(PLATFORM "stm32disco") | |||||
set(PLATFORM "stm32disco") | |||||
set(PLATFORM_INC "3rd/libopencm3/include") |
@@ -89,7 +89,7 @@ int main(void) | |||||
for(i=0;i<10;i++) | for(i=0;i<10;i++) | ||||
hal_send_str("=========================="); | hal_send_str("=========================="); | ||||
test_keys(); | test_keys(); | ||||
hal_send_str("# That's all folks!"); | |||||
hal_send_str("## That's all folks! #"); | |||||
while(1); | while(1); | ||||