From 4a70142872224ca09176533ed166500f85db6dbc Mon Sep 17 00:00:00 2001 From: Kris Kwiatkowski Date: Tue, 23 Mar 2021 09:31:12 +0000 Subject: [PATCH] Adds method registration --- CMakeLists.txt | 26 ++++++++++++++++++++++++++ src/capi/pqapi.c | 20 +------------------- test/mytest.cpp | 9 +++++++++ 3 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 test/mytest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 76a7ce9d..4b743ecf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,3 +233,29 @@ target_link_libraries( pqclean_dilithium3_clean pqclean_dilithium5_clean ) + +add_executable( + mytest + + test/mytest.cpp +) + +target_link_libraries( + mytest + gtest + pqclean_s + gtest_main) + +target_include_directories( + mytest PRIVATE + + ${CMAKE_SOURCE_DIR}) + + +install(TARGETS pqclean pqclean_s + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +install(FILES + ${QRS_PUBLIC_INC} + DESTINATION include/pqclean) diff --git a/src/capi/pqapi.c b/src/capi/pqapi.c index c0a69db9..ee08b9b7 100644 --- a/src/capi/pqapi.c +++ b/src/capi/pqapi.c @@ -1,4 +1,5 @@ #include +#include "pqapi.h" #include "kem/kyber/kyber512/clean/api.h" // helpers @@ -30,25 +31,6 @@ #define PQC_NAME(x) GLUE(A(x), CRYPTO_ALGNAME) -// Parameters of the scheme -typedef struct params_t { - const uint8_t alg_id; - const char* alg_name; - const uint32_t prv_key_bsz; - const uint32_t pub_key_bsz; -} params_t; - -typedef struct kem_params_t { - params_t p; - const uint32_t ciphertext_bsz; - const uint32_t secret_bsz; -} kem_params_t; - -typedef struct sig_params_t { - params_t p; - const uint32_t sign_bsz; -} sig_params_t; - // Macro magic needed to initialize parameters for a scheme #define REG_KEM(ID) \ { \ diff --git a/test/mytest.cpp b/test/mytest.cpp new file mode 100644 index 00000000..a2f38ce5 --- /dev/null +++ b/test/mytest.cpp @@ -0,0 +1,9 @@ +#include +#include "capi/pqapi.h" + +extern const kem_params_t kems[]; + +// TODO: change - just to see if function registration works OK. +TEST(Kyber,XXX) { + ASSERT_EQ(kems[0].p.prv_key_bsz, 1632); +} \ No newline at end of file