Skip to content

Commit

Permalink
Shorter CI run: less repetitions and a single KAT per level
Browse files Browse the repository at this point in the history
Fixes a few memory leaks in debug code
Fix for big-endian support
Sync test vectors for prof testing
  • Loading branch information
bhess committed Mar 14, 2024
1 parent df24e34 commit ff34a8c
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 48 deletions.
47 changes: 20 additions & 27 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,21 @@ jobs:

strategy:
matrix:
sqisign_build_type: [opt]
sqisign_build_type: [ref]
sqisign_test_reps: [10]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies Valgrind, GMP, Doxygen, TeX
run: |
sudo apt --fix-missing install valgrind libgmp-dev doxygen texlive-xetex
sudo apt update && sudo apt --fix-missing install valgrind libgmp-dev doxygen texlive-xetex
echo "Valgrind installed"
- name: Install Valgrind dependencies
run: |
python -m pip install --upgrade pip
pip install ValgrindCI
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DSQISIGN_TEST_REPS=${{ matrix.sqisign_test_reps }}

- name: Build
# Build your program with the given configuration
Expand All @@ -61,23 +53,21 @@ jobs:
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
run: ctest -j4 -C ${{env.BUILD_TYPE}}

- name: Examples
if: false
working-directory: ${{github.workspace}}/build/apps
run: |
./PQCgenKAT_sign_lvl1
./PQCgenKAT_sign_lvl1_varp6983
./example_nistapi_lvl1
./example_nistapi_lvl1_varp6983
./example_nistapi_lvl3
./example_nistapi_lvl5
- name: CT-Tests
# TODO: re-enable for those tests that should be ct
if: false
run: |
rm -rf build
cmake -Bbuild -DENABLE_CT_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }}
cmake -Bbuild -DENABLE_CT_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DSQISIGN_TEST_REPS=${{ matrix.sqisign_test_reps }}
cmake --build build
# valgrind --track-origins=yes build/
# valgrind --track-origins=yes build/
Expand All @@ -87,35 +77,38 @@ jobs:
- name: Memcheck
run: |
rm -rf build
cmake -Bbuild -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DSQISIGN_TEST_REPS=10
cmake -Bbuild -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DSQISIGN_TEST_REPS=${{ matrix.sqisign_test_reps }}
cmake --build build
ctest -T memcheck --test-dir build
if: false

- name: Address Sanitizer ASAN
run: |
rm -rf build
cmake -Bbuild -DCMAKE_BUILD_TYPE=ASAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang
cmake -Bbuild -DCMAKE_BUILD_TYPE=ASAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang -DSQISIGN_TEST_REPS=1
cmake --build build
ctest -v --test-dir build
ctest -j4 -v --test-dir build
# MSAN needs instrumented gmp
- name: Memory Sanitizer MSAN
run: |
rm -rf build
cmake -Bbuild -DCMAKE_BUILD_TYPE=MSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang
cmake -Bbuild -DCMAKE_BUILD_TYPE=MSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang -DSQISIGN_TEST_REPS=1
cmake --build build
ctest -v --test-dir build
ctest -j4 -v --test-dir build
if: false

- name: Leak Sanitizer LSAN
run: |
rm -rf build
cmake -Bbuild -DCMAKE_BUILD_TYPE=LSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang
cmake -Bbuild -DCMAKE_BUILD_TYPE=LSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang -DSQISIGN_TEST_REPS=1
cmake --build build
ctest -v --test-dir build
ctest -j4 -v --test-dir build
- name: Undefined Behavior Sanitizer UBSAN
run: |
rm -rf build
cmake -Bbuild -DCMAKE_BUILD_TYPE=UBSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang
cmake -Bbuild -DCMAKE_BUILD_TYPE=UBSAN -DSQISIGN_BUILD_TYPE=${{ matrix.sqisign_build_type }} -DCMAKE_C_COMPILER=clang -DSQISIGN_TEST_REPS=1
cmake --build build
ctest -v --test-dir build
ctest -j4 -v --test-dir build
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(SELECT_SQISIGN_VARIANT ${PROJECT_SOURCE_DIR}/.cmake/sqisign_variant.cmake)

set(INC_PUBLIC ${PROJECT_SOURCE_DIR}/include)


add_subdirectory(src)
add_subdirectory(apps)

Expand Down
7 changes: 6 additions & 1 deletion src/id2iso/ref/id2isox/test/id2iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,17 @@ int id2iso_test_long_id2iso() {
// var finalize
quat_alg_elem_finalize(&gen_key);
quat_alg_elem_finalize(&gen_check);
quat_alg_elem_finalize(&quat_temp);
ibq_finalize(&ibq_norm);
ibz_finalize(&temp);ibz_finalize(&remainder);
ibz_finalize(&temp);ibz_finalize(&remainder);ibz_finalize(&n);
quat_alg_elem_finalize(&gen);
quat_alg_elem_finalize(&gen_two);
quat_left_ideal_finalize(&lideal_small);
quat_left_ideal_finalize(&lideal_check);
quat_left_ideal_finalize(&lideal_two);
quat_left_ideal_finalize(&lideal_two_one);
quat_left_ideal_finalize(&lideal_small_one);
quat_left_ideal_finalize(&ideal_test);
quat_order_finalize(&right_order);
quat_alg_coord_finalize(&coeffs);
ibz_mat_4x4_finalize(&reduced);ibz_mat_4x4_finalize(&gram);
Expand Down
2 changes: 2 additions & 0 deletions src/id2iso/ref/id2isox/test/ker2id.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ int _id2iso_test_ker2id() {
id2iso_kernel_dlogs_to_ideal(&I, &vec2, &vec3);
// quat_left_ideal_print(&I);
quat_left_ideal_finalize(&I);
ibz_vec_2_finalize(&vec2);
ibz_vec_2_finalize(&vec3);

//TODO FIXME this really only tests that the function doesn't crash

Expand Down
5 changes: 5 additions & 0 deletions src/protocols/ref/protocolsx/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ void hash_to_challenge(ibz_vec_2_t *scalars, const ec_curve_t *curve, const unsi
//FIXME should use SHAKE128 for smaller parameter sets?
SHAKE256((void *) digits, sizeof(digits), buf, FP2_ENCODED_BYTES + length);

#ifdef TARGET_BIG_ENDIAN
for (size_t i = 0; i < NWORDS_FIELD; i++)
digits[i] = BSWAP_DIGIT(digits[i]);
#endif

ibz_set(&(*scalars)[0], 1); //FIXME
ibz_copy_digit_array(&(*scalars)[1], digits);
}
Expand Down
3 changes: 3 additions & 0 deletions src/protocols/ref/protocolsx/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ void protocols_commit(quat_left_ideal_t *ideal, ec_curve_t *E1, ec_basis_t *basi
ibz_gcd(&temp,&temp,&DEGREE_COMMITMENT);
ibz_div(&temp,&remainder,&temp,&DEGREE_COMMITMENT);
assert(0==ibz_cmp(&remainder,&ibz_const_zero));
ibz_finalize(&temp);ibz_finalize(&remainder);
quat_alg_coord_finalize(&coeffs);
#endif


Expand Down Expand Up @@ -699,6 +701,7 @@ int protocols_sign(signature_t *sig,const public_key_t *pk, const secret_key_t *
quat_alg_conj(&delta,&gen);
quat_lideal_create_from_primitive(&ideal_signing_test,&delta,&ideal_eichler_rand.norm,&right_order_key,&QUATALG_PINFTY);
assert(quat_lideal_equals(&ideal_signing_test,&ideal_eichler_rand,&QUATALG_PINFTY));
quat_left_ideal_finalize(&ideal_signing_test);
#endif

// checking cyclicity
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FOREACH(SVARIANT ${SVARIANT_S})
target_link_libraries(sqisign_test_prof_${SVARIANT} sqisign_${SVARIANT_LOWER})
target_include_directories(sqisign_test_prof_${SVARIANT} PUBLIC ${PROJECT_SOURCE_DIR}/src/common ${INC_PUBLIC} ${PROJECT_SOURCE_DIR}/src/nistapi/${SVARIANT_LOWER})

add_test(sqisign_${SVARIANT}_KAT sqisign_test_kat_${SVARIANT})
add_test(sqisign_${SVARIANT}_KAT sqisign_test_kat_${SVARIANT} 0) # testing only the first KAT
add_test(sqisign_${SVARIANT}_SELFTEST sqisign_test_scheme_${SVARIANT})

set_tests_properties(sqisign_${SVARIANT}_KAT PROPERTIES TIMEOUT 0)
Expand Down
38 changes: 19 additions & 19 deletions test/test_sqisign_prof.c

Large diffs are not rendered by default.

0 comments on commit ff34a8c

Please sign in to comment.