diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index aebd40f..6c33273 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,9 +47,9 @@ jobs: - name: Rename the binaries run: | cd bin/ - mv combined_static.lib libxeddsa-windows-amd64.lib - mv combined_dynamic.lib libxeddsa-windows-amd64.dll.lib - mv combined_dynamic.dll libxeddsa-windows-amd64.dll + mv static/libxeddsa.lib libxeddsa-windows-amd64.lib + mv dynamic/libxeddsa.lib libxeddsa-windows-amd64.dll.lib + mv dynamic/libxeddsa.dll libxeddsa-windows-amd64.dll - name: Upload the binaries uses: actions/upload-artifact@v3.1.1 @@ -85,8 +85,8 @@ jobs: - name: Rename the binaries run: | cd bin/ - mv libcombined_static.a libxeddsa-macos-amd64.a - mv libcombined_dynamic.dylib libxeddsa-macos-amd64.dylib + mv static/libxeddsa.a libxeddsa-macos-amd64.a + mv dynamic/libxeddsa.dylib libxeddsa-macos-amd64.dylib - name: Upload the binaries uses: actions/upload-artifact@v3.1.1 @@ -124,8 +124,8 @@ jobs: - name: Rename the binaries run: | cd bin/ - mv libcombined_static.a libxeddsa-macos-arm64.a - mv libcombined_dynamic.dylib libxeddsa-macos-arm64.dylib + mv static/libxeddsa.a libxeddsa-macos-arm64.a + mv dynamic/libxeddsa.dylib libxeddsa-macos-arm64.dylib - name: Upload the binaries uses: actions/upload-artifact@v3.1.1 @@ -163,8 +163,8 @@ jobs: - name: Rename the binaries run: | cd bin/ - mv libcombined_static.a libxeddsa-linux-amd64.a - mv libcombined_dynamic.so libxeddsa-linux-amd64.so + mv static/libxeddsa.a libxeddsa-linux-amd64.a + mv dynamic/libxeddsa.so libxeddsa-linux-amd64.so - name: Upload the binaries uses: actions/upload-artifact@v3.1.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d7158e..5d3ebed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,15 @@ include(CTest) add_subdirectory(ref10) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/static) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/dynamic) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin/static) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin/dynamic) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) endforeach () if (WIN32) @@ -79,24 +79,8 @@ target_compile_definitions(xeddsa_objects PRIVATE SODIUM_DLL_EXPORT) target_compile_definitions(xeddsa_objects PRIVATE BUILD) add_library(xeddsa_static STATIC $) - -if (NOT DEFINED EMSCRIPTEN) - add_library(xeddsa_dynamic SHARED $) - - if (WIN32) - # Correct the import library. - set_target_properties(xeddsa_dynamic PROPERTIES IMPORT_PREFIX "") - set_target_properties(xeddsa_dynamic PROPERTIES IMPORT_SUFFIX ".lib") - endif (WIN32) -endif () - -#################### -# combined library # -#################### - -add_library(combined_static STATIC CMakeLists.txt) -set_target_properties(combined_static PROPERTIES LINKER_LANGUAGE C) -target_link_libraries(combined_static PUBLIC +set_target_properties(xeddsa_static PROPERTIES OUTPUT_NAME xeddsa) +target_link_libraries(xeddsa_static PUBLIC xeddsa_objects crypto_sign_objects crypto_hash_objects @@ -110,10 +94,12 @@ target_link_libraries(combined_static PUBLIC sodium_static ) +install(TARGETS xeddsa_static) + if (NOT DEFINED EMSCRIPTEN) - add_library(combined_dynamic SHARED CMakeLists.txt) - set_target_properties(combined_dynamic PROPERTIES LINKER_LANGUAGE C) - target_link_libraries(combined_dynamic PUBLIC + add_library(xeddsa_dynamic SHARED $) + set_target_properties(xeddsa_dynamic PROPERTIES OUTPUT_NAME xeddsa) + target_link_libraries(xeddsa_dynamic PUBLIC xeddsa_objects crypto_sign_objects crypto_hash_objects @@ -126,6 +112,14 @@ if (NOT DEFINED EMSCRIPTEN) kernelrandombytes_objects sodium_shared ) + + if (WIN32) + # Correct the import library. + set_target_properties(xeddsa_dynamic PROPERTIES IMPORT_PREFIX "") + set_target_properties(xeddsa_dynamic PROPERTIES IMPORT_SUFFIX ".lib") + endif (WIN32) + + install(TARGETS xeddsa_dynamic) endif () ########################## @@ -147,24 +141,18 @@ target_include_directories(xeddsa_test_objects PRIVATE test) add_executable(xeddsa_test_static $) target_include_directories(xeddsa_test_static PRIVATE test) -target_link_libraries(xeddsa_test_static combined_static sodium_static) +target_link_libraries(xeddsa_test_static xeddsa_static sodium_static) if (NOT DEFINED EMSCRIPTEN) add_executable(xeddsa_test_dynamic $) target_include_directories(xeddsa_test_dynamic PRIVATE test) - target_link_libraries(xeddsa_test_dynamic combined_dynamic sodium_shared) + target_link_libraries(xeddsa_test_dynamic xeddsa_dynamic sodium_shared) endif () ################ # DEPENDENCIES # ################ -target_link_libraries(xeddsa_static crypto_sign_static sodium_static) - -if (NOT DEFINED EMSCRIPTEN) - target_link_libraries(xeddsa_dynamic crypto_sign_dynamic sodium_shared) -endif () - target_include_directories(xeddsa_objects PUBLIC ref10/crypto_sign ref10/crypto_hash diff --git a/docs/installation.rst b/docs/installation.rst index 9d7d807..287c9a2 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -48,7 +48,7 @@ where ``YourBuildEnv`` depends on your build environment. ``cmake --help`` lists The next step is to build the library, which again depends on your build system. With MinGW for example, use ``mingw32-make``. -When the build is done, run ``ctest ..`` to run the tests. +When the build is done, run ``ctest -C Debug ..`` to run the tests in debug configuration, and ``ctest -C Release ..`` to run them in release configuration. Emscripten ---------- diff --git a/ref10/CMakeLists.txt b/ref10/CMakeLists.txt index 87047de..d880cbc 100644 --- a/ref10/CMakeLists.txt +++ b/ref10/CMakeLists.txt @@ -45,15 +45,15 @@ if (NOT (UNIX OR WIN32)) message(FATAL_ERROR "Unsupported operating system (neither UNIX nor Windows). CMake will exit.") endif () -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/static) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/dynamic) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin/static) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin/dynamic) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin) endforeach () if (WIN32) @@ -86,6 +86,8 @@ target_include_directories(crypto_core_objects PUBLIC crypto_core) add_library(crypto_core_static STATIC $) add_library(crypto_core_dynamic SHARED $) +set_target_properties(crypto_core_static PROPERTIES OUTPUT_NAME crypto_core) +set_target_properties(crypto_core_dynamic PROPERTIES OUTPUT_NAME crypto_core) if (WIN32) # Correct the import library. @@ -109,6 +111,8 @@ target_include_directories(crypto_hash_objects PUBLIC crypto_hash) add_library(crypto_hash_static STATIC $) add_library(crypto_hash_dynamic SHARED $) +set_target_properties(crypto_hash_static PROPERTIES OUTPUT_NAME crypto_hash) +set_target_properties(crypto_hash_dynamic PROPERTIES OUTPUT_NAME crypto_hash) if (WIN32) # Correct the import library. @@ -132,6 +136,8 @@ target_include_directories(crypto_hashblocks_objects PUBLIC crypto_hashblocks) add_library(crypto_hashblocks_static STATIC $) add_library(crypto_hashblocks_dynamic SHARED $) +set_target_properties(crypto_hashblocks_static PROPERTIES OUTPUT_NAME crypto_hashblocks) +set_target_properties(crypto_hashblocks_dynamic PROPERTIES OUTPUT_NAME crypto_hashblocks) if (WIN32) # Correct the import library. @@ -155,6 +161,8 @@ target_include_directories(crypto_rng_objects PUBLIC crypto_rng) add_library(crypto_rng_static STATIC $) add_library(crypto_rng_dynamic SHARED $) +set_target_properties(crypto_rng_static PROPERTIES OUTPUT_NAME crypto_rng) +set_target_properties(crypto_rng_dynamic PROPERTIES OUTPUT_NAME crypto_rng) if (WIN32) # Correct the import library. @@ -191,6 +199,8 @@ target_include_directories(crypto_scalarmult_objects PUBLIC crypto_scalarmult) add_library(crypto_scalarmult_static STATIC $) add_library(crypto_scalarmult_dynamic SHARED $) +set_target_properties(crypto_scalarmult_static PROPERTIES OUTPUT_NAME crypto_scalarmult) +set_target_properties(crypto_scalarmult_dynamic PROPERTIES OUTPUT_NAME crypto_scalarmult) if (WIN32) # Correct the import library. @@ -252,6 +262,8 @@ target_include_directories(crypto_sign_objects PUBLIC crypto_sign) add_library(crypto_sign_static STATIC $) add_library(crypto_sign_dynamic SHARED $) +set_target_properties(crypto_sign_static PROPERTIES OUTPUT_NAME crypto_sign) +set_target_properties(crypto_sign_dynamic PROPERTIES OUTPUT_NAME crypto_sign) if (WIN32) # Correct the import library. @@ -276,6 +288,8 @@ target_include_directories(crypto_stream_objects PUBLIC crypto_stream) add_library(crypto_stream_static STATIC $) add_library(crypto_stream_dynamic SHARED $) +set_target_properties(crypto_stream_static PROPERTIES OUTPUT_NAME crypto_stream) +set_target_properties(crypto_stream_dynamic PROPERTIES OUTPUT_NAME crypto_stream) if (WIN32) # Correct the import library. @@ -299,6 +313,8 @@ target_include_directories(crypto_verify_objects PUBLIC crypto_verify) add_library(crypto_verify_static STATIC $) add_library(crypto_verify_dynamic SHARED $) +set_target_properties(crypto_verify_static PROPERTIES OUTPUT_NAME crypto_verify) +set_target_properties(crypto_verify_dynamic PROPERTIES OUTPUT_NAME crypto_verify) if (WIN32) # Correct the import library. @@ -322,6 +338,8 @@ target_include_directories(fastrandombytes_objects PUBLIC fastrandombytes) add_library(fastrandombytes_static STATIC $) add_library(fastrandombytes_dynamic SHARED $) +set_target_properties(fastrandombytes_static PROPERTIES OUTPUT_NAME fastrandombytes) +set_target_properties(fastrandombytes_dynamic PROPERTIES OUTPUT_NAME fastrandombytes) if (WIN32) # Correct the import library. @@ -396,6 +414,8 @@ target_include_directories(kernelrandombytes_objects PUBLIC kernelrandombytes) add_library(kernelrandombytes_static STATIC $) add_library(kernelrandombytes_dynamic SHARED $) +set_target_properties(kernelrandombytes_static PROPERTIES OUTPUT_NAME kernelrandombytes) +set_target_properties(kernelrandombytes_dynamic PROPERTIES OUTPUT_NAME kernelrandombytes) if (WIN32) # Correct the import library. diff --git a/ref10/kernelrandombytes/test.c b/ref10/kernelrandombytes/test.c index a42b579..f02f8d7 100644 --- a/ref10/kernelrandombytes/test.c +++ b/ref10/kernelrandombytes/test.c @@ -8,7 +8,7 @@ int main() unsigned long long i; unsigned long long j; - for (j = 0;j < 3;++j) { + for (j = 0;j < 10000;++j) { kernelrandombytes(x,sizeof x); for (i = 0;i < 256;++i) freq[i] = 0; for (i = 0;i < sizeof x;++i) ++freq[255 & (int) x[i]];