Skip to content

Commit

Permalink
Merge pull request #463 from cryspen/protz_all_kyber_variants
Browse files Browse the repository at this point in the history
Add all variants of kyber to hacl-packages, with compilation and all
  • Loading branch information
franziskuskiefer authored May 15, 2024
2 parents 5e51d8a + 826413c commit aee06b1
Show file tree
Hide file tree
Showing 26 changed files with 9,493 additions and 3,771 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,11 @@ if(ENABLE_TESTS)
target_compile_options(${TEST_NAME} PRIVATE /std:c++20)
endif(MSVC)

add_dependencies(${TEST_NAME} hacl hacl_cpu_features)
add_dependencies(${TEST_NAME} hacl libcrux_static hacl_cpu_features)
target_link_libraries(${TEST_NAME} PRIVATE
gtest_main
hacl_static
libcrux_static
hacl_cpu_features
nlohmann_json::nlohmann_json
)
Expand Down Expand Up @@ -513,7 +514,7 @@ if(ENABLE_TESTS)
target_compile_options(${TEST_NAME} PRIVATE /std:c++20)
endif(MSVC)

add_dependencies(${TEST_NAME} hacl hacl_cpu_features)
add_dependencies(${TEST_NAME} hacl libcrux_static hacl_cpu_features)
target_link_libraries(${TEST_NAME} PRIVATE
gtest_main
hacl_cpu_features
Expand Down Expand Up @@ -553,7 +554,8 @@ if(ENABLE_BENCHMARKS)
FetchContent_Populate(benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
# The latest release 1.7.1 is broken due to https://github.com/google/benchmark/pull/1517
GIT_TAG b177433f3ee2513b1075140c723d73ab8901790f
# But also: need the fix for https://github.com/google/benchmark/pull/1669
GIT_TAG bc946b919cac6f25a199a526da571638cfde109f
)
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR})

Expand Down Expand Up @@ -591,9 +593,10 @@ if(ENABLE_BENCHMARKS)
target_compile_options(${BENCH_NAME} PRIVATE /std:c++20)
endif(NOT MSVC)

add_dependencies(${BENCH_NAME} hacl hacl_cpu_features)
add_dependencies(${BENCH_NAME} hacl libcrux_static hacl_cpu_features)
target_link_libraries(${BENCH_NAME} PRIVATE
hacl_static
libcrux_static
ecckiila
blake2
digestif
Expand All @@ -620,7 +623,7 @@ if(ENABLE_BENCHMARKS)

target_compile_definitions(${BENCH_NAME} PUBLIC NO_OPENSSL)

add_dependencies(${BENCH_NAME} hacl hacl_cpu_features)
add_dependencies(${BENCH_NAME} hacl libcrux_static hacl_cpu_features)
target_link_libraries(${BENCH_NAME} PRIVATE
hacl_cpu_features
benchmark::benchmark
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ $ ./mach build --test

... to build HACL Packages and run the tests. All actions are driven by [mach]. See `./mach --help` for details.

### MSVC Build

The hacl-packages build is designed for non-MSVC compilers.
Building with MSVC can be achieved as follows.


<details>
<summary><b>MSVC Build</b></summary>

```powershell
# Setup build directory
mkdir build
cp config\default_config_msvc.cmake build\config.cmake
cp config\default_config_msvc.h build\config.h
# Build
cmake -B build -DBUILD_LIBCRUX=1 -G "Visual Studio 17 2022" -A x64 -DUSE_MSVC=1 -DENABLE_TESTS=ON -DENABLE_BENCHMARKS=ON
# Use --config Release to build in release mode
cmake --build build
```
</details>

## Platform support

The HACL Packages are supported based on the following tiers.
Expand Down
8 changes: 7 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,13 @@
"file": "Libcrux_Kem_Kyber_Kyber768.c"
},
{
"file": "libcrux_kyber.c"
"file": "libcrux_kyber512.c"
},
{
"file": "libcrux_kyber768.c"
},
{
"file": "libcrux_kyber1024.c"
},
{
"file": "libcrux_hacl_glue.c"
Expand Down
6 changes: 6 additions & 0 deletions config/default_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ set(BENCHMARK_SOURCES
${PROJECT_SOURCE_DIR}/benchmarks/drbg.cc
${PROJECT_SOURCE_DIR}/benchmarks/hmac.cc
${PROJECT_SOURCE_DIR}/benchmarks/rsapss.cc
${PROJECT_SOURCE_DIR}/benchmarks/kyber.cc
)
set(VALE_SOURCES_osx
${PROJECT_SOURCE_DIR}/vale/src/cpuid-x86_64-darwin.S
Expand Down Expand Up @@ -476,6 +477,11 @@ set(VALE_SOURCES_msvc
)
set(LIBCRUX_SOURCES
${PROJECT_SOURCE_DIR}/libcrux/src/Libcrux_Kem_Kyber_Kyber768.c
${PROJECT_SOURCE_DIR}/libcrux/src/libcrux_kyber512.c
${PROJECT_SOURCE_DIR}/libcrux/src/libcrux_kyber768.c
${PROJECT_SOURCE_DIR}/libcrux/src/libcrux_kyber1024.c
${PROJECT_SOURCE_DIR}/libcrux/src/libcrux_hacl_glue.c
${PROJECT_SOURCE_DIR}/libcrux/src/core.c
)
set(ALGORITHM_TEST_FILES
TEST_FILES_detection
Expand Down
Loading

0 comments on commit aee06b1

Please sign in to comment.