diff --git a/.CMake/alg_support.cmake b/.CMake/alg_support.cmake index 60e4b098a1..d499d99a3b 100644 --- a/.CMake/alg_support.cmake +++ b/.CMake/alg_support.cmake @@ -214,6 +214,38 @@ cmake_dependent_option(OQS_ENABLE_SIG_cross_rsdpg_256_balanced "" ON "OQS_ENABLE cmake_dependent_option(OQS_ENABLE_SIG_cross_rsdpg_256_fast "" ON "OQS_ENABLE_SIG_CROSS" OFF) cmake_dependent_option(OQS_ENABLE_SIG_cross_rsdpg_256_small "" ON "OQS_ENABLE_SIG_CROSS" OFF) +option(OQS_ENABLE_SIG_QRUOV "Enable qruov algorithm family" ON) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q7L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q7L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q7L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q7L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q7L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q7L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L3aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L3shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L10aes "" ON "OQS_ENABLE_SIG_QRUOV" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L10shake "" ON "OQS_ENABLE_SIG_QRUOV" OFF) + option(OQS_ENABLE_SIG_UOV "Enable uov algorithm family" ON) cmake_dependent_option(OQS_ENABLE_SIG_uov_ov_Is "" ON "OQS_ENABLE_SIG_UOV" OFF) cmake_dependent_option(OQS_ENABLE_SIG_uov_ov_Ip "" ON "OQS_ENABLE_SIG_UOV" OFF) @@ -887,6 +919,187 @@ if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS)) endif() +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q7L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q7L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q31L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q31L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q31L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q31L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q127L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q127L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q127L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_1q127L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q7L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q7L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q31L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q31L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q31L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q31L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q127L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q127L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q127L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_3q127L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q7L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q7L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q31L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q31L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q31L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q31L10shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q127L3aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q127L3shake" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q127L10aes" OFF) +endif() +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_BMI2_INSTRUCTIONS AND OQS_USE_AES_INSTRUCTIONS)) + cmake_dependent_option(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2 "" ON "OQS_ENABLE_SIG_qruov_5q127L10shake" OFF) +endif() +endif() + + if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") if(OQS_DIST_ARM64_V8_BUILD OR (OQS_USE_ARM_NEON_INSTRUCTIONS AND OQS_USE_ARM_NEON_INSTRUCTIONS)) cmake_dependent_option(OQS_ENABLE_SIG_uov_ov_Is_neon "" ON "OQS_ENABLE_SIG_uov_ov_Is" OFF) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 009ad4649e..ed8df094cb 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -30,6 +30,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v4 + - name: Ensure the build system can reach everything that ships + run: python3 -m pytest --verbose tests/test_cmake_option_coverage.py tests/test_kats_json.py - name: Ensure code conventions are upheld run: python3 -m pytest --verbose tests/test_code_conventions.py - name: Check that doxygen can parse the documentation diff --git a/.github/workflows/extended.yml b/.github/workflows/extended.yml index 983bd942ba..ac282077bd 100644 --- a/.github/workflows/extended.yml +++ b/.github/workflows/extended.yml @@ -96,6 +96,135 @@ jobs: timeout-minutes: 360 run: mkdir -p tmp && python3 -m pytest --verbose ${{ matrix.PYTEST_ARGS }} + # QR-UOV ships three implementations per parameter set, and all three + # produce identical KAT vectors. A build that silently fell back to `ref` + # would therefore pass every existing test while covering nothing, which is + # how `opt` came to ship for 30 parameter sets without being compiled + # anywhere. Each job below asserts which implementation it actually got + # before it runs anything. + # + # All three set OQS_DIST_BUILD=OFF deliberately. Under a dist build the + # generated wrapper keeps a run-time CPU check and falls back to `ref` when + # the host lacks AVX2, BMI2 or AES, so the compile-time define alone would + # not tell us which code executed. With the dist build off there is no + # run-time branch and the define does imply the code path, which is what + # makes the assertion meaningful. + qruov-implementations: + name: QR-UOV ${{ matrix.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: ref + # Portable C, and this family's default implementation. + IMPLEMENTATION: ref + CMAKE_ARGS: -DOQS_DIST_BUILD=OFF -DOQS_OPT_TARGET=generic -DOQS_USE_AVX2_INSTRUCTIONS=OFF -DOQS_USE_BMI2_INSTRUCTIONS=OFF -DOQS_USE_AES_INSTRUCTIONS=OFF + - name: avx2 + # The optimised x86-64 path. + IMPLEMENTATION: avx2 + CMAKE_ARGS: -DOQS_DIST_BUILD=OFF -DOQS_OPT_TARGET=auto -DOQS_USE_AVX2_INSTRUCTIONS=ON -DOQS_USE_BMI2_INSTRUCTIONS=ON -DOQS_USE_AES_INSTRUCTIONS=ON + - name: opt + # Ships but is not selectable through any option: see + # tests/test_cmake_option_coverage.py. Reached here only by + # setting the cache variables directly, so that the sources in the + # tarball are still built and KAT-checked on x86-64 while the + # ARM64 behaviour is investigated. This says nothing about ARM64. + IMPLEMENTATION: opt + CMAKE_ARGS: -DOQS_DIST_BUILD=OFF -DOQS_OPT_TARGET=generic -DOQS_USE_AVX2_INSTRUCTIONS=OFF -DOQS_USE_BMI2_INSTRUCTIONS=OFF -DOQS_USE_AES_INSTRUCTIONS=OFF + container: + image: openquantumsafe/ci-ubuntu-latest:latest + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v4 + - name: Set the opt cache variables + if: matrix.IMPLEMENTATION == 'opt' + id: force_opt + run: | + set -eu + # Scheme names are matched as [A-Za-z0-9]+, which keeps anything + # that reaches the shell below to that character set. + schemes=$(grep -oE 'OQS_ENABLE_SIG_qruov_[A-Za-z0-9]+_avx2' .CMake/alg_support.cmake \ + | sed -e 's/^OQS_ENABLE_SIG_qruov_//' -e 's/_avx2$//' | sort -u) + count=$(printf '%s\n' "$schemes" | grep -c . || true) + if [ "$count" -eq 0 ]; then + echo "Found no QR-UOV schemes in .CMake/alg_support.cmake" >&2 + exit 1 + fi + flags="" + for scheme in $schemes; do + flags="$flags -DOQS_ENABLE_SIG_qruov_${scheme}_opt=ON" + done + echo "flags=$flags" >> "$GITHUB_OUTPUT" + - name: Configure + env: + FORCE_OPT: ${{ steps.force_opt.outputs.flags }} + run: | + mkdir build && cd build + cmake -GNinja -DOQS_MINIMAL_BUILD="SIG_qruov" ${{ matrix.CMAKE_ARGS }} $FORCE_OPT .. \ + && cmake -LA -N .. + - name: Confirm the intended implementation was selected + env: + IMPLEMENTATION: ${{ matrix.IMPLEMENTATION }} + run: | + set -eu + header=build/include/oqs/oqsconfig.h + # helpers.py reads this same path to decide what is enabled, so if + # it is missing every KAT would skip and pytest would still exit 0. + test -s "$header" || { echo "missing or empty $header" >&2; exit 1; } + + # Without this the avx2 assertion below would be vacuous: a dist + # build dispatches at run time and falls back to ref on a host + # without the instructions, so the define would not imply the path. + if grep -qE '^#define OQS_DIST_BUILD' "$header"; then + echo "OQS_DIST_BUILD is set; the implementation would be chosen at run time" >&2 + exit 1 + fi + + # `|| true` would also swallow a real grep error (exit 2) and + # yield an empty string, and `[ "" -ne 0 ]` inside an `if` is read + # as false rather than tripping `set -e`. Tolerate only "no match". + count_impl () { + grep -cE "^#define OQS_ENABLE_SIG_qruov_[A-Za-z0-9]+_$1 " "$header" || [ $? -eq 1 ] + } + # `ref` is the family default, so it is carried by the bare scheme + # option rather than by a define of its own. + schemes=$(grep -cE "^#define OQS_ENABLE_SIG_qruov_[A-Za-z0-9]+ " "$header" || [ $? -eq 1 ]) + opt=$(count_impl opt) + avx2=$(count_impl avx2) + echo "schemes=$schemes opt=$opt avx2=$avx2 expected=$IMPLEMENTATION" + + if [ "$schemes" -eq 0 ]; then + echo "No QR-UOV schemes were enabled at all" >&2 + exit 1 + fi + + case "$IMPLEMENTATION" in + ref) + [ "$opt" -eq 0 ] && [ "$avx2" -eq 0 ] \ + || { echo "Wanted ref only, got opt=$opt avx2=$avx2" >&2; exit 1; } + ;; + avx2) + [ "$avx2" -eq "$schemes" ] && [ "$opt" -eq 0 ] \ + || { echo "Wanted avx2 for all $schemes schemes, got avx2=$avx2 opt=$opt" >&2; exit 1; } + ;; + opt) + # The wrapper selects with `#if _opt / #elif _avx2`, so opt wins + # wherever both are defined. Keeping avx2 off states the intent + # rather than relying on that ordering. + [ "$opt" -eq "$schemes" ] && [ "$avx2" -eq 0 ] \ + || { echo "Wanted opt for all $schemes schemes, got opt=$opt avx2=$avx2" >&2; exit 1; } + ;; + esac + - name: Build + run: ninja + working-directory: build + - name: Run tests + # Matches nistkat-x64, which is the other job that runs test_kat_all: + # 30 parameter sets at 100 vectors each is slow on ref in particular. + timeout-minutes: 360 + run: mkdir -p tmp && python3 -m pytest --verbose --numprocesses=auto -k QRUOV tests/test_kat.py tests/test_kat_all.py + libjadecheck: name: Check libjade code is properly integrated runs-on: ubuntu-latest @@ -166,7 +295,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 60 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_acvp_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 --ignore=tests/test_distbuild.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --maxprocesses=10 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_acvp_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 --ignore=tests/test_distbuild.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --maxprocesses=10 address-sanitizer-stfl: name: ASAN with STFL key generation @@ -183,7 +312,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 60 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_distbuild.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --numprocesses=logical --dist load --maxschedchunk=1 --maxprocesses=10 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_distbuild.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --numprocesses=logical --dist load --maxschedchunk=1 --maxprocesses=10 stfl-tests: name: STFL key generation tests @@ -215,7 +344,7 @@ jobs: timeout-minutes: 90 env: OQS_TEST_SIG_CTX_STEP: "255" - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_acvp_vectors.py --numprocesses=auto --ignore=tests/test_alg_info.py --ignore=tests/test_kat_all.py + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_acvp_vectors.py --numprocesses=auto --ignore=tests/test_alg_info.py --ignore=tests/test_kat_all.py slhdsa-openssl330-test: name: SLH-DSA with OpenSSL 3.3.0 @@ -261,7 +390,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 90 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --numprocesses=logical --dist load --maxschedchunk=1 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --numprocesses=logical --dist load --maxschedchunk=1 slhdsa-linux-tests: name: SLH-DSA Linux platform tests @@ -302,7 +431,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 90 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --numprocesses=auto ${{ matrix.PYTEST_ARGS }} + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --numprocesses=auto ${{ matrix.PYTEST_ARGS }} slhdsa-windows-arm64-tests: name: SLH-DSA Windows arm64 tests @@ -340,7 +469,7 @@ jobs: run: pip.exe install --require-hashes -r .github\workflows\requirements.txt - name: Run tests run: | - python -m pytest --numprocesses=logical --dist load --maxschedchunk=1 -vv --maxfail=10 --ignore=tests/test_code_conventions.py --ignore=tests/test_kat_all.py --durations=0 --junitxml=build\test-results\pytest\test-results.xml + python -m pytest --numprocesses=logical --dist load --maxschedchunk=1 -vv --maxfail=10 --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_kat_all.py --durations=0 --junitxml=build\test-results\pytest\test-results.xml slhdsa-macos-tests: name: SLH-DSA macOS tests @@ -366,7 +495,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 60 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_kat_all.py --durations=0 --numprocesses=logical --dist load --maxschedchunk=1 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_kat_all.py --durations=0 --numprocesses=logical --dist load --maxschedchunk=1 acvp-tests: name: Run ACVP vector tests @@ -423,7 +552,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 60 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --numprocesses=auto ${{ matrix.PYTEST_ARGS }} + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --numprocesses=auto ${{ matrix.PYTEST_ARGS }} full-code-coverage: name: Run full code coverage with ACVP tests diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 750362cc82..0c04caea88 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -112,7 +112,7 @@ jobs: timeout-minutes: 60 env: OQS_TEST_SIG_CTX_STEP: "255" - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 ${{ matrix.PYTEST_ARGS }} + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 ${{ matrix.PYTEST_ARGS }} - name: Package .deb if: matrix.name == 'jammy-std-openssl3' run: cpack @@ -192,7 +192,7 @@ jobs: working-directory: build - name: Run tests timeout-minutes: 60 - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_leaks.py --ignore=tests/test_kat_all.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 scan_build: runs-on: ubuntu-latest diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index ab57bbf3c1..cfc41e5e38 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -45,5 +45,5 @@ jobs: - name: Run tests env: OQS_TEST_SIG_CTX_STEP: "255" - run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_kat_all.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 + run: mkdir -p tmp && python3 -m pytest --verbose --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_kat_all.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --numprocesses=logical --dist load --maxschedchunk=1 timeout-minutes: 60 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e620ba66b1..9358128e98 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -45,5 +45,5 @@ jobs: env: OQS_TEST_SIG_CTX_STEP: "255" run: | - python -m pytest --numprocesses=logical --dist load --maxschedchunk=1 -vv --maxfail=10 --ignore=tests/test_code_conventions.py --ignore=tests/test_kat_all.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --junitxml=build\test-results\pytest\test-results.xml + python -m pytest --numprocesses=logical --dist load --maxschedchunk=1 -vv --maxfail=10 --ignore=tests/test_code_conventions.py --ignore=tests/test_cmake_option_coverage.py --ignore=tests/test_kats_json.py --ignore=tests/test_kat_all.py --ignore=tests/test_acvp_vectors.py --ignore=tests/test_wycheproof_vectors.py --junitxml=build\test-results\pytest\test-results.xml diff --git a/ALGORITHMS.md b/ALGORITHMS.md index 61669e524c..3d34a1da0e 100644 --- a/ALGORITHMS.md +++ b/ALGORITHMS.md @@ -46,6 +46,7 @@ The **OQS tier** column records OQS's own support commitment for each algorithm. | MAYO | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`PQCMayo/MAYO-C@74de637`](https://github.com/PQCMayo/MAYO-C/commit/74de637a7c4a7f9fafa888183bc05f5cf920cd2d) | [Actively maintained](https://github.com/PQCMayo/MAYO-C) | Tier 3 (Community) | 1, 3, 5 | ✓ | — | portable, ARM64_V8, x86_64 (avx2) | | ML-DSA | Standardized by [NIST](https://csrc.nist.gov/pubs/fips/204/final) | [`pq-code-package/mldsa-native@834a90d`](https://github.com/pq-code-package/mldsa-native/commit/834a90d5e846ffa1e1611bd24e160bb2e9b86d35) | [Actively maintained](https://github.com/pq-code-package/mldsa-native) | Tier 2 (Supported) | 2, 3, 5 | ✓ | — | portable, ARM64_V8, x86_64 (avx2+bmi2+popcnt) | | MQOM | Under [NIST](https://csrc.nist.gov/projects/pqc-dig-sig) consideration | [`mqom/mqom-v3@df26239`](https://github.com/mqom/mqom-v3/commit/df26239dd22f194371003f403ec1a9920772b769) | [Actively maintained](https://github.com/mqom/mqom-v3/blob/main/integration/liboqs/SUPPORT.md) | Tier 3 (Community) | 1, 3, 5 | ✓ | — | portable, ARM64_V8 (sha3), x86_64 (aes+avx2) | +| QR-UOV | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`0rlych1kk4/round3@df619f4`](https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d) | TBD | Tier 3 (Community) | 1, 3, 5 | — | — | portable, x86_64 (aes+avx2+bmi2) | | SLH-DSA | Standardized by [NIST](https://csrc.nist.gov/pubs/fips/205/final) | [`pq-code-package/slhdsa-c@a0fc1ff`](https://github.com/pq-code-package/slhdsa-c/commit/a0fc1ff253930060d0246aebca06c2538eb92b88) | Best effort | Tier 3 (Community) | 1, 3, 5 | — | — | portable | | SNOVA | Under [NIST](https://csrc.nist.gov/csrc/media/Projects/pqc-dig-sig/documents/round-3/spec-files/snova-spec-round3-web.pdf) consideration | [`PQCLAB-SNOVA/S@9b29c1e`](https://github.com/PQCLAB-SNOVA/S/commit/9b29c1e332cbd85757c8d6362a57b9a8c8298a38) | Best effort | Tier 3 (Community) | 1, 3, 5 | ✓ | — | portable, ARM64_V8, x86_64 (avx2) | | UOV | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`pqov/pqov@fac2ec1`](https://github.com/pqov/pqov/commit/fac2ec1fe6d8ea508eab4b98eb5341e1eed930a4) | Best effort | Tier 3 (Community) | 1, 3, 5 | ✓ | — | portable, ARM64_V8, x86_64 (avx2) | diff --git a/CMakeLists.txt b/CMakeLists.txt index 7addb4758f..0357cba896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,9 @@ endif() if(OQS_ENABLE_SIG_CROSS) set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ${PROJECT_SOURCE_DIR}/src/sig/cross/sig_cross.h) endif() +if(OQS_ENABLE_SIG_QRUOV) + set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ${PROJECT_SOURCE_DIR}/src/sig/qruov/sig_qruov.h) +endif() if(OQS_ENABLE_SIG_UOV) set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ${PROJECT_SOURCE_DIR}/src/sig/uov/sig_uov.h) endif() diff --git a/README.md b/README.md index 5a680e070c..e02e7c2786 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Names of algorithms standardized by NIST — [`ML-KEM`](https://csrc.nist.gov/pu | MAYO | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`PQCMayo/MAYO-C@74de637`](https://github.com/PQCMayo/MAYO-C/commit/74de637a7c4a7f9fafa888183bc05f5cf920cd2d) | [Actively maintained](https://github.com/PQCMayo/MAYO-C) | Tier 3 (Community) | | ML-DSA | Standardized by [NIST](https://csrc.nist.gov/pubs/fips/204/final) | [`pq-code-package/mldsa-native@834a90d`](https://github.com/pq-code-package/mldsa-native/commit/834a90d5e846ffa1e1611bd24e160bb2e9b86d35) | [Actively maintained](https://github.com/pq-code-package/mldsa-native) | Tier 2 (Supported) | | MQOM | Under [NIST](https://csrc.nist.gov/projects/pqc-dig-sig) consideration | [`mqom/mqom-v3@df26239`](https://github.com/mqom/mqom-v3/commit/df26239dd22f194371003f403ec1a9920772b769) | [Actively maintained](https://github.com/mqom/mqom-v3/blob/main/integration/liboqs/SUPPORT.md) | Tier 3 (Community) | +| QR-UOV | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`0rlych1kk4/round3@df619f4`](https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d) | TBD | Tier 3 (Community) | | SLH-DSA | Standardized by [NIST](https://csrc.nist.gov/pubs/fips/205/final) | [`pq-code-package/slhdsa-c@a0fc1ff`](https://github.com/pq-code-package/slhdsa-c/commit/a0fc1ff253930060d0246aebca06c2538eb92b88) | Best effort | Tier 3 (Community) | | SNOVA | Under [NIST](https://csrc.nist.gov/csrc/media/Projects/pqc-dig-sig/documents/round-3/spec-files/snova-spec-round3-web.pdf) consideration | [`PQCLAB-SNOVA/S@9b29c1e`](https://github.com/PQCLAB-SNOVA/S/commit/9b29c1e332cbd85757c8d6362a57b9a8c8298a38) | Best effort | Tier 3 (Community) | | UOV | Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) consideration | [`pqov/pqov@fac2ec1`](https://github.com/pqov/pqov/commit/fac2ec1fe6d8ea508eab4b98eb5341e1eed930a4) | Best effort | Tier 3 (Community) | diff --git a/docs/algorithms/sig/qruov.md b/docs/algorithms/sig/qruov.md new file mode 100644 index 0000000000..c593ba0d6f --- /dev/null +++ b/docs/algorithms/sig/qruov.md @@ -0,0 +1,304 @@ +# QR-UOV + +- **Algorithm type**: Digital signature scheme. +- **Main cryptographic assumption**: multivariate quadratic equations, oil and vinegar. +- **Principal submitters**: Rika Akiyama, Hiroki Furue, Yasuhiko Ikematsu, Fumitaka Hoshino, Koha Kinjo, Haruhisa Kosuge, Satoshi Nakamura, Shingo Orihara, Tsuyoshi Takagi, Kimihiro Yamakoshi. +- **Authors' website**: https://info.isl.ntt.co.jp/crypt/eng/qr-uov/ +- **Specification version**: NIST Round 3. +- **Primary Source**: + - **Source**: https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d + - **Implementation license (SPDX-Identifier)**: 0BSD +- **Optimized Implementation sources**: + - **opt**: + - **Source**: https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d + - **Implementation license (SPDX-Identifier)**: 0BSD + - **avx2**: + - **Source**: https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d + - **Implementation license (SPDX-Identifier)**: 0BSD + + +## Support + +- **Upstream maintenance**: TBD +- **OQS support tier**: Tier 3 + +## Parameter set summary + +| Parameter set | Parameter set alias | Security model | Claimed NIST Level | Public key size (bytes) | Secret key size (bytes) | Signature size (bytes) | +|:--------------------:|:----------------------|:-----------------|---------------------:|--------------------------:|--------------------------:|-------------------------:| +| QRUOV-1q127L10-aes | NA | EUF-CMA | 1 | 11041 | 32 | 541 | +| QRUOV-1q127L10-shake | NA | EUF-CMA | 1 | 11041 | 32 | 541 | +| QRUOV-1q127L3-aes | NA | EUF-CMA | 1 | 24256 | 32 | 200 | +| QRUOV-1q127L3-shake | NA | EUF-CMA | 1 | 24256 | 32 | 200 | +| QRUOV-1q31L10-aes | NA | EUF-CMA | 1 | 12266 | 32 | 435 | +| QRUOV-1q31L10-shake | NA | EUF-CMA | 1 | 12266 | 32 | 435 | +| QRUOV-1q31L3-aes | NA | EUF-CMA | 1 | 23641 | 32 | 157 | +| QRUOV-1q31L3-shake | NA | EUF-CMA | 1 | 23641 | 32 | 157 | +| QRUOV-1q7L10-aes | NA | EUF-CMA | 1 | 20641 | 32 | 331 | +| QRUOV-1q7L10-shake | NA | EUF-CMA | 1 | 20641 | 32 | 331 | +| QRUOV-3q127L10-aes | NA | EUF-CMA | 3 | 35454 | 32 | 821 | +| QRUOV-3q127L10-shake | NA | EUF-CMA | 3 | 35454 | 32 | 821 | +| QRUOV-3q127L3-aes | NA | EUF-CMA | 3 | 71884 | 32 | 292 | +| QRUOV-3q127L3-shake | NA | EUF-CMA | 3 | 71884 | 32 | 292 | +| QRUOV-3q31L10-aes | NA | EUF-CMA | 3 | 34391 | 32 | 643 | +| QRUOV-3q31L10-shake | NA | EUF-CMA | 3 | 34391 | 32 | 643 | +| QRUOV-3q31L3-aes | NA | EUF-CMA | 3 | 70976 | 32 | 233 | +| QRUOV-3q31L3-shake | NA | EUF-CMA | 3 | 70976 | 32 | 233 | +| QRUOV-3q7L10-aes | NA | EUF-CMA | 3 | 55141 | 32 | 489 | +| QRUOV-3q7L10-shake | NA | EUF-CMA | 3 | 55141 | 32 | 489 | +| QRUOV-5q127L10-aes | NA | EUF-CMA | 5 | 63541 | 32 | 1039 | +| QRUOV-5q127L10-shake | NA | EUF-CMA | 5 | 63541 | 32 | 1039 | +| QRUOV-5q127L3-aes | NA | EUF-CMA | 5 | 173660 | 32 | 392 | +| QRUOV-5q127L3-shake | NA | EUF-CMA | 5 | 173660 | 32 | 392 | +| QRUOV-5q31L10-aes | NA | EUF-CMA | 5 | 58516 | 32 | 807 | +| QRUOV-5q31L10-shake | NA | EUF-CMA | 5 | 58516 | 32 | 807 | +| QRUOV-5q31L3-aes | NA | EUF-CMA | 5 | 158405 | 32 | 306 | +| QRUOV-5q31L3-shake | NA | EUF-CMA | 5 | 158405 | 32 | 306 | +| QRUOV-5q7L10-aes | NA | EUF-CMA | 5 | 135391 | 32 | 662 | +| QRUOV-5q7L10-shake | NA | EUF-CMA | 5 | 135391 | 32 | 662 | + +## QRUOV-1q127L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage?‡ | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:----------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + + ‡For an explanation of what this denotes, consult the [Explanation of Terms](#explanation-of-terms) section at the end of this file. + +## QRUOV-1q127L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q127L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q127L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q31L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q31L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q31L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q31L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q7L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-1q7L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q127L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q127L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q127L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q127L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q31L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q31L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q31L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q31L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q7L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-3q7L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q127L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q127L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q127L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q127L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q31L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q31L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q31L3-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q31L3-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q7L10-aes implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## QRUOV-5q7L10-shake implementation characteristics + +| Implementation source | Identifier in upstream | Supported architecture(s) | Supported operating system(s) | CPU extension(s) used | No branching-on-secrets claimed? | No branching-on-secrets checked by valgrind? | Large stack usage? | +|:---------------------------------:|:-------------------------|:----------------------------|:--------------------------------|:------------------------|:-----------------------------------|:-----------------------------------------------|:---------------------| +| [Primary Source](#primary-source) | avx2 | x86\_64 | Linux,Darwin | AVX2,BMI2,AES | False | False | False | + +Are implementations chosen based on runtime CPU feature detection? **Yes**. + +## Explanation of Terms + +- **Large Stack Usage**: Implementations identified as having such may cause failures when running in threads or in constrained environments. \ No newline at end of file diff --git a/docs/algorithms/sig/qruov.yml b/docs/algorithms/sig/qruov.yml new file mode 100644 index 0000000000..c5e1f318f6 --- /dev/null +++ b/docs/algorithms/sig/qruov.yml @@ -0,0 +1,1286 @@ +name: QR-UOV +type: signature +principal-submitters: +- Rika Akiyama +- Hiroki Furue +- Yasuhiko Ikematsu +- Fumitaka Hoshino +- Koha Kinjo +- Haruhisa Kosuge +- Satoshi Nakamura +- Shingo Orihara +- Tsuyoshi Takagi +- Kimihiro Yamakoshi +crypto-assumption: multivariate quadratic equations, oil and vinegar +nist-round: 3 +standardization-status: Under [NIST](https://csrc.nist.gov/Projects/pqc-dig-sig/round-3-additional-signatures) + consideration +spec-version: NIST Round 3 +upstream-maintenance: TBD +upstream-statement-url: null +oqs-support-tier: 3 +primary-upstream: + source: https://github.com/0rlych1kk4/round3/commit/df619f46a6c937c1b14907a933f74ae7d82a202d + spdx-license-identifier: 0BSD +parameter-sets: +- name: QRUOV-1q127L10-aes + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 11041 + length-secret-key: 32 + length-signature: 541 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q127L10-shake + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 11041 + length-secret-key: 32 + length-signature: 541 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q127L3-aes + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 24256 + length-secret-key: 32 + length-signature: 200 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q127L3-shake + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 24256 + length-secret-key: 32 + length-signature: 200 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q31L10-aes + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 12266 + length-secret-key: 32 + length-signature: 435 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q31L10-shake + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 12266 + length-secret-key: 32 + length-signature: 435 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q31L3-aes + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 23641 + length-secret-key: 32 + length-signature: 157 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q31L3-shake + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 23641 + length-secret-key: 32 + length-signature: 157 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q7L10-aes + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 20641 + length-secret-key: 32 + length-signature: 331 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-1q7L10-shake + claimed-nist-level: 1 + claimed-security: EUF-CMA + length-public-key: 20641 + length-secret-key: 32 + length-signature: 331 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q127L10-aes + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 35454 + length-secret-key: 32 + length-signature: 821 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q127L10-shake + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 35454 + length-secret-key: 32 + length-signature: 821 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q127L3-aes + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 71884 + length-secret-key: 32 + length-signature: 292 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q127L3-shake + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 71884 + length-secret-key: 32 + length-signature: 292 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q31L10-aes + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 34391 + length-secret-key: 32 + length-signature: 643 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q31L10-shake + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 34391 + length-secret-key: 32 + length-signature: 643 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q31L3-aes + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 70976 + length-secret-key: 32 + length-signature: 233 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q31L3-shake + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 70976 + length-secret-key: 32 + length-signature: 233 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q7L10-aes + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 55141 + length-secret-key: 32 + length-signature: 489 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-3q7L10-shake + claimed-nist-level: 3 + claimed-security: EUF-CMA + length-public-key: 55141 + length-secret-key: 32 + length-signature: 489 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q127L10-aes + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 63541 + length-secret-key: 32 + length-signature: 1039 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q127L10-shake + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 63541 + length-secret-key: 32 + length-signature: 1039 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q127L3-aes + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 173660 + length-secret-key: 32 + length-signature: 392 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q127L3-shake + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 173660 + length-secret-key: 32 + length-signature: 392 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q31L10-aes + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 58516 + length-secret-key: 32 + length-signature: 807 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q31L10-shake + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 58516 + length-secret-key: 32 + length-signature: 807 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q31L3-aes + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 158405 + length-secret-key: 32 + length-signature: 306 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q31L3-shake + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 158405 + length-secret-key: 32 + length-signature: 306 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q7L10-aes + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 135391 + length-secret-key: 32 + length-signature: 662 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + - AES: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +- name: QRUOV-5q7L10-shake + claimed-nist-level: 5 + claimed-security: EUF-CMA + length-public-key: 135391 + length-secret-key: 32 + length-signature: 662 + implementations-switch-on-runtime-cpu-features: true + implementations: + - upstream: primary-upstream + upstream-id: ref + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + default: true + - upstream: primary-upstream + upstream-id: opt + supported-platforms: [] + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false + - upstream: primary-upstream + upstream-id: avx2 + supported-platforms: + - architecture: x86_64 + operating_systems: + - Linux + - Darwin + required_flags: + - avx2 + - bmi2 + - aes + common-crypto: + - SHA3: liboqs + no-secret-dependent-branching-claimed: false + no-secret-dependent-branching-checked-by-valgrind: false + large-stack-usage: false +website: https://info.isl.ntt.co.jp/crypt/eng/qr-uov/ diff --git a/docs/cbom.json b/docs/cbom.json index 05368e3efa..7238c09962 100644 --- a/docs/cbom.json +++ b/docs/cbom.json @@ -2,23 +2,23 @@ "$schema": "https://raw.githubusercontent.com/CycloneDX/specification/1.6/schema/bom-1.6.schema.json", "bomFormat": "CycloneDX", "specVersion": "1.6", - "serialNumber": "urn:uuid:f2006179-6bc4-458a-ad7d-6baebcab6e60", + "serialNumber": "urn:uuid:8aef1183-a364-451a-be1d-f35fc5b2cef3", "version": 1, "metadata": { - "timestamp": "2026-09-16T07:12:12.278055+00:00", + "timestamp": "2026-09-22T16:48:43.819494+00:00", "component": { "type": "library", - "bom-ref": "pkg:github/open-quantum-safe/liboqs@5e97276fc3c1baeb7bff3c6569c9dfd49428b9f1", + "bom-ref": "pkg:github/open-quantum-safe/liboqs@078c4d3c73b982de8d7a1665d68073bfdaf48147", "name": "liboqs", - "version": "5e97276fc3c1baeb7bff3c6569c9dfd49428b9f1" + "version": "078c4d3c73b982de8d7a1665d68073bfdaf48147" } }, "components": [ { "type": "library", - "bom-ref": "pkg:github/open-quantum-safe/liboqs@5e97276fc3c1baeb7bff3c6569c9dfd49428b9f1", + "bom-ref": "pkg:github/open-quantum-safe/liboqs@078c4d3c73b982de8d7a1665d68073bfdaf48147", "name": "liboqs", - "version": "5e97276fc3c1baeb7bff3c6569c9dfd49428b9f1" + "version": "078c4d3c73b982de8d7a1665d68073bfdaf48147" }, { "type": "cryptographic-asset", @@ -4500,6 +4500,606 @@ } } }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q127L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q127L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q127L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q127L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q127L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q127L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q127L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q127L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q31L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q31L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q31L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q31L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q31L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q31L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q31L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q31L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q7L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q7L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-1q7L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-1q7L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 1, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q127L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q127L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q127L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q127L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q127L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q127L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q127L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q127L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q31L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q31L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q31L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q31L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q31L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q31L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q31L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q31L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q7L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q7L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-3q7L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-3q7L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 3, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q127L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q127L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q127L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q127L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q127L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q127L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q127L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q127L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q31L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q31L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q31L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q31L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q31L3-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q31L3-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q31L3-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q31L3-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q7L10-aes:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q7L10-aes", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "alg:QRUOV-5q7L10-shake:avx2:x86_64", + "name": "QR-UOV", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "parameterSetIdentifier": "QRUOV-5q7L10-shake", + "primitive": "signature", + "executionEnvironment": "software-plain-ram", + "cryptoFunctions": [ + "keygen", + "sign", + "verify" + ], + "nistQuantumSecurityLevel": 5, + "implementationPlatform": "x86_64" + } + } + }, { "type": "cryptographic-asset", "bom-ref": "alg:SLH_DSA_PURE_SHA2_128S:slhdsa-c:generic", @@ -9807,7 +10407,7 @@ ], "dependencies": [ { - "ref": "pkg:github/open-quantum-safe/liboqs@5e97276fc3c1baeb7bff3c6569c9dfd49428b9f1", + "ref": "pkg:github/open-quantum-safe/liboqs@078c4d3c73b982de8d7a1665d68073bfdaf48147", "provides": [ "alg:BIKE-L1:master:x86_64", "alg:BIKE-L3:master:x86_64", @@ -10033,6 +10633,36 @@ "alg:mqom3_cat5_gf2_shorter_ot:memopt:generic", "alg:mqom3_cat5_gf2_shorter_ot:avx2:x86_64", "alg:mqom3_cat5_gf2_shorter_ot:neon:armv8-a", + "alg:QRUOV-1q127L10-aes:avx2:x86_64", + "alg:QRUOV-1q127L10-shake:avx2:x86_64", + "alg:QRUOV-1q127L3-aes:avx2:x86_64", + "alg:QRUOV-1q127L3-shake:avx2:x86_64", + "alg:QRUOV-1q31L10-aes:avx2:x86_64", + "alg:QRUOV-1q31L10-shake:avx2:x86_64", + "alg:QRUOV-1q31L3-aes:avx2:x86_64", + "alg:QRUOV-1q31L3-shake:avx2:x86_64", + "alg:QRUOV-1q7L10-aes:avx2:x86_64", + "alg:QRUOV-1q7L10-shake:avx2:x86_64", + "alg:QRUOV-3q127L10-aes:avx2:x86_64", + "alg:QRUOV-3q127L10-shake:avx2:x86_64", + "alg:QRUOV-3q127L3-aes:avx2:x86_64", + "alg:QRUOV-3q127L3-shake:avx2:x86_64", + "alg:QRUOV-3q31L10-aes:avx2:x86_64", + "alg:QRUOV-3q31L10-shake:avx2:x86_64", + "alg:QRUOV-3q31L3-aes:avx2:x86_64", + "alg:QRUOV-3q31L3-shake:avx2:x86_64", + "alg:QRUOV-3q7L10-aes:avx2:x86_64", + "alg:QRUOV-3q7L10-shake:avx2:x86_64", + "alg:QRUOV-5q127L10-aes:avx2:x86_64", + "alg:QRUOV-5q127L10-shake:avx2:x86_64", + "alg:QRUOV-5q127L3-aes:avx2:x86_64", + "alg:QRUOV-5q127L3-shake:avx2:x86_64", + "alg:QRUOV-5q31L10-aes:avx2:x86_64", + "alg:QRUOV-5q31L10-shake:avx2:x86_64", + "alg:QRUOV-5q31L3-aes:avx2:x86_64", + "alg:QRUOV-5q31L3-shake:avx2:x86_64", + "alg:QRUOV-5q7L10-aes:avx2:x86_64", + "alg:QRUOV-5q7L10-shake:avx2:x86_64", "alg:SLH_DSA_PURE_SHA2_128S:slhdsa-c:generic", "alg:SLH_DSA_PURE_SHA2_128F:slhdsa-c:generic", "alg:SLH_DSA_PURE_SHA2_192S:slhdsa-c:generic", @@ -11697,6 +12327,186 @@ "alg:sha3" ] }, + { + "ref": "alg:QRUOV-1q127L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q127L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q127L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q127L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q31L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q31L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q31L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q31L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q7L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-1q7L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q127L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q127L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q127L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q127L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q31L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q31L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q31L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q31L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q7L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-3q7L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q127L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q127L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q127L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q127L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q31L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q31L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q31L3-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q31L3-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q7L10-aes:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, + { + "ref": "alg:QRUOV-5q7L10-shake:avx2:x86_64", + "dependsOn": [ + "alg:sha3" + ] + }, { "ref": "alg:SNOVA_I_K:opt:generic", "dependsOn": [ diff --git a/scripts/copy_from_upstream/copy_from_upstream.yml b/scripts/copy_from_upstream/copy_from_upstream.yml index b7fedb6588..2b6ae6e43f 100644 --- a/scripts/copy_from_upstream/copy_from_upstream.yml +++ b/scripts/copy_from_upstream/copy_from_upstream.yml @@ -93,6 +93,14 @@ upstreams: git_commit: fac2ec1fe6d8ea508eab4b98eb5341e1eed930a4 sig_scheme_path: '.' sig_meta_path: 'integration/liboqs/{pretty_name_full}_META.yml' + - + name: qruov + git_url: https://github.com/0rlych1kk4/round3.git + git_branch: feat/liboqs-integration + git_commit: df619f46a6c937c1b14907a933f74ae7d82a202d + sig_scheme_path: '.' + sig_meta_path: 'integration/liboqs/{pretty_name_full}_META.yml' + common_meta_path: 'integration/liboqs/META_Common.yml' - name: snova git_url: https://github.com/PQCLAB-SNOVA/SNOVA @@ -394,6 +402,161 @@ sigs: pqclean_scheme: cross-rsdpg-256-small pretty_name_full: cross-rsdpg-256-small signed_msg_order: msg_then_sig + - + name: qruov + default_implementation: ref + upstream_location: qruov + schemes: + - + scheme: "1q7L10aes" + pqclean_scheme: qruov_1q7L10_aes + pretty_name_full: QRUOV-1q7L10-aes + signed_msg_order: sig_then_msg + - + scheme: "1q7L10shake" + pqclean_scheme: qruov_1q7L10_shake + pretty_name_full: QRUOV-1q7L10-shake + signed_msg_order: sig_then_msg + - + scheme: "1q31L3aes" + pqclean_scheme: qruov_1q31L3_aes + pretty_name_full: QRUOV-1q31L3-aes + signed_msg_order: sig_then_msg + - + scheme: "1q31L3shake" + pqclean_scheme: qruov_1q31L3_shake + pretty_name_full: QRUOV-1q31L3-shake + signed_msg_order: sig_then_msg + - + scheme: "1q31L10aes" + pqclean_scheme: qruov_1q31L10_aes + pretty_name_full: QRUOV-1q31L10-aes + signed_msg_order: sig_then_msg + - + scheme: "1q31L10shake" + pqclean_scheme: qruov_1q31L10_shake + pretty_name_full: QRUOV-1q31L10-shake + signed_msg_order: sig_then_msg + - + scheme: "1q127L3aes" + pqclean_scheme: qruov_1q127L3_aes + pretty_name_full: QRUOV-1q127L3-aes + signed_msg_order: sig_then_msg + - + scheme: "1q127L3shake" + pqclean_scheme: qruov_1q127L3_shake + pretty_name_full: QRUOV-1q127L3-shake + signed_msg_order: sig_then_msg + - + scheme: "1q127L10aes" + pqclean_scheme: qruov_1q127L10_aes + pretty_name_full: QRUOV-1q127L10-aes + signed_msg_order: sig_then_msg + - + scheme: "1q127L10shake" + pqclean_scheme: qruov_1q127L10_shake + pretty_name_full: QRUOV-1q127L10-shake + signed_msg_order: sig_then_msg + - + scheme: "3q7L10aes" + pqclean_scheme: qruov_3q7L10_aes + pretty_name_full: QRUOV-3q7L10-aes + signed_msg_order: sig_then_msg + - + scheme: "3q7L10shake" + pqclean_scheme: qruov_3q7L10_shake + pretty_name_full: QRUOV-3q7L10-shake + signed_msg_order: sig_then_msg + - + scheme: "3q31L3aes" + pqclean_scheme: qruov_3q31L3_aes + pretty_name_full: QRUOV-3q31L3-aes + signed_msg_order: sig_then_msg + - + scheme: "3q31L3shake" + pqclean_scheme: qruov_3q31L3_shake + pretty_name_full: QRUOV-3q31L3-shake + signed_msg_order: sig_then_msg + - + scheme: "3q31L10aes" + pqclean_scheme: qruov_3q31L10_aes + pretty_name_full: QRUOV-3q31L10-aes + signed_msg_order: sig_then_msg + - + scheme: "3q31L10shake" + pqclean_scheme: qruov_3q31L10_shake + pretty_name_full: QRUOV-3q31L10-shake + signed_msg_order: sig_then_msg + - + scheme: "3q127L3aes" + pqclean_scheme: qruov_3q127L3_aes + pretty_name_full: QRUOV-3q127L3-aes + signed_msg_order: sig_then_msg + - + scheme: "3q127L3shake" + pqclean_scheme: qruov_3q127L3_shake + pretty_name_full: QRUOV-3q127L3-shake + signed_msg_order: sig_then_msg + - + scheme: "3q127L10aes" + pqclean_scheme: qruov_3q127L10_aes + pretty_name_full: QRUOV-3q127L10-aes + signed_msg_order: sig_then_msg + - + scheme: "3q127L10shake" + pqclean_scheme: qruov_3q127L10_shake + pretty_name_full: QRUOV-3q127L10-shake + signed_msg_order: sig_then_msg + - + scheme: "5q7L10aes" + pqclean_scheme: qruov_5q7L10_aes + pretty_name_full: QRUOV-5q7L10-aes + signed_msg_order: sig_then_msg + - + scheme: "5q7L10shake" + pqclean_scheme: qruov_5q7L10_shake + pretty_name_full: QRUOV-5q7L10-shake + signed_msg_order: sig_then_msg + - + scheme: "5q31L3aes" + pqclean_scheme: qruov_5q31L3_aes + pretty_name_full: QRUOV-5q31L3-aes + signed_msg_order: sig_then_msg + - + scheme: "5q31L3shake" + pqclean_scheme: qruov_5q31L3_shake + pretty_name_full: QRUOV-5q31L3-shake + signed_msg_order: sig_then_msg + - + scheme: "5q31L10aes" + pqclean_scheme: qruov_5q31L10_aes + pretty_name_full: QRUOV-5q31L10-aes + signed_msg_order: sig_then_msg + - + scheme: "5q31L10shake" + pqclean_scheme: qruov_5q31L10_shake + pretty_name_full: QRUOV-5q31L10-shake + signed_msg_order: sig_then_msg + - + scheme: "5q127L3aes" + pqclean_scheme: qruov_5q127L3_aes + pretty_name_full: QRUOV-5q127L3-aes + signed_msg_order: sig_then_msg + - + scheme: "5q127L3shake" + pqclean_scheme: qruov_5q127L3_shake + pretty_name_full: QRUOV-5q127L3-shake + signed_msg_order: sig_then_msg + - + scheme: "5q127L10aes" + pqclean_scheme: qruov_5q127L10_aes + pretty_name_full: QRUOV-5q127L10-aes + signed_msg_order: sig_then_msg + - + scheme: "5q127L10shake" + pqclean_scheme: qruov_5q127L10_shake + pretty_name_full: QRUOV-5q127L10-shake + signed_msg_order: sig_then_msg - name: uov default_implementation: ref diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8e813d220..1878e3fa20 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,6 +59,10 @@ if(OQS_ENABLE_SIG_CROSS) add_subdirectory(sig/cross) set(SIG_OBJS ${SIG_OBJS} ${CROSS_OBJS}) endif() +if(OQS_ENABLE_SIG_QRUOV) + add_subdirectory(sig/qruov) + set(SIG_OBJS ${SIG_OBJS} ${QRUOV_OBJS}) +endif() if(OQS_ENABLE_SIG_UOV) add_subdirectory(sig/uov) set(SIG_OBJS ${SIG_OBJS} ${UOV_OBJS}) diff --git a/src/oqsconfig.h.cmake b/src/oqsconfig.h.cmake index 1709573f7b..aad797187d 100644 --- a/src/oqsconfig.h.cmake +++ b/src/oqsconfig.h.cmake @@ -252,6 +252,98 @@ #cmakedefine OQS_ENABLE_SIG_cross_rsdpg_256_small 1 #cmakedefine OQS_ENABLE_SIG_cross_rsdpg_256_small_avx2 1 +#cmakedefine OQS_ENABLE_SIG_QRUOV 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q7L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q31L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_1q127L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q7L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q31L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_3q127L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q7L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q31L10shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L3shake_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10aes 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10aes_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10aes_avx2 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10shake 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10shake_opt 1 +#cmakedefine OQS_ENABLE_SIG_qruov_5q127L10shake_avx2 1 + #cmakedefine OQS_ENABLE_SIG_UOV 1 #cmakedefine OQS_ENABLE_SIG_uov_ov_Is 1 #cmakedefine OQS_ENABLE_SIG_uov_ov_Is_neon 1 diff --git a/src/sig/qruov/CMakeLists.txt b/src/sig/qruov/CMakeLists.txt new file mode 100644 index 0000000000..1dceaffa02 --- /dev/null +++ b/src/sig/qruov/CMakeLists.txt @@ -0,0 +1,968 @@ +# SPDX-License-Identifier: MIT + +# This file was generated by +# scripts/copy_from_upstream/copy_from_upstream.py + +set(_QRUOV_OBJS "") + +if(OQS_ENABLE_SIG_qruov_1q7L10aes) + add_library(qruov_1q7L10aes_ref OBJECT sig_qruov_1q7L10aes.c qruov_qruov_1q7L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q7L10aes_ref PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_aes_ref) + target_include_directories(qruov_1q7L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q7L10aes_ref PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q7L10aes_opt) + add_library(qruov_1q7L10aes_opt OBJECT qruov_qruov_1q7L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_aes_opt) + target_include_directories(qruov_1q7L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q7L10aes_opt PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2) + add_library(qruov_1q7L10aes_avx2 OBJECT qruov_qruov_1q7L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_aes_avx2) + target_include_directories(qruov_1q7L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q7L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q7L10aes_avx2 PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q7L10shake) + add_library(qruov_1q7L10shake_ref OBJECT sig_qruov_1q7L10shake.c qruov_qruov_1q7L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q7L10shake_ref PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_shake_ref) + target_include_directories(qruov_1q7L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q7L10shake_ref PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q7L10shake_opt) + add_library(qruov_1q7L10shake_opt OBJECT qruov_qruov_1q7L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_shake_opt) + target_include_directories(qruov_1q7L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q7L10shake_opt PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2) + add_library(qruov_1q7L10shake_avx2 OBJECT qruov_qruov_1q7L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q7L10_shake_avx2) + target_include_directories(qruov_1q7L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q7L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q7L10shake_avx2 PUBLIC -DQRUOV_PARAM_1q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q7L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3aes) + add_library(qruov_1q31L3aes_ref OBJECT sig_qruov_1q31L3aes.c qruov_qruov_1q31L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q31L3aes_ref PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_aes_ref) + target_include_directories(qruov_1q31L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q31L3aes_ref PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3aes_opt) + add_library(qruov_1q31L3aes_opt OBJECT qruov_qruov_1q31L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_aes_opt) + target_include_directories(qruov_1q31L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q31L3aes_opt PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2) + add_library(qruov_1q31L3aes_avx2 OBJECT qruov_qruov_1q31L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_aes_avx2) + target_include_directories(qruov_1q31L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q31L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q31L3aes_avx2 PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3shake) + add_library(qruov_1q31L3shake_ref OBJECT sig_qruov_1q31L3shake.c qruov_qruov_1q31L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q31L3shake_ref PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_shake_ref) + target_include_directories(qruov_1q31L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q31L3shake_ref PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3shake_opt) + add_library(qruov_1q31L3shake_opt OBJECT qruov_qruov_1q31L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_shake_opt) + target_include_directories(qruov_1q31L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q31L3shake_opt PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2) + add_library(qruov_1q31L3shake_avx2 OBJECT qruov_qruov_1q31L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L3_shake_avx2) + target_include_directories(qruov_1q31L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q31L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q31L3shake_avx2 PUBLIC -DQRUOV_PARAM_1q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10aes) + add_library(qruov_1q31L10aes_ref OBJECT sig_qruov_1q31L10aes.c qruov_qruov_1q31L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q31L10aes_ref PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_aes_ref) + target_include_directories(qruov_1q31L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q31L10aes_ref PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10aes_opt) + add_library(qruov_1q31L10aes_opt OBJECT qruov_qruov_1q31L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_aes_opt) + target_include_directories(qruov_1q31L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q31L10aes_opt PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2) + add_library(qruov_1q31L10aes_avx2 OBJECT qruov_qruov_1q31L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_aes_avx2) + target_include_directories(qruov_1q31L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q31L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q31L10aes_avx2 PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10shake) + add_library(qruov_1q31L10shake_ref OBJECT sig_qruov_1q31L10shake.c qruov_qruov_1q31L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q31L10shake_ref PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_shake_ref) + target_include_directories(qruov_1q31L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q31L10shake_ref PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10shake_opt) + add_library(qruov_1q31L10shake_opt OBJECT qruov_qruov_1q31L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_shake_opt) + target_include_directories(qruov_1q31L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q31L10shake_opt PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2) + add_library(qruov_1q31L10shake_avx2 OBJECT qruov_qruov_1q31L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q31L10_shake_avx2) + target_include_directories(qruov_1q31L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q31L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q31L10shake_avx2 PUBLIC -DQRUOV_PARAM_1q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q31L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3aes) + add_library(qruov_1q127L3aes_ref OBJECT sig_qruov_1q127L3aes.c qruov_qruov_1q127L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q127L3aes_ref PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_aes_ref) + target_include_directories(qruov_1q127L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q127L3aes_ref PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3aes_opt) + add_library(qruov_1q127L3aes_opt OBJECT qruov_qruov_1q127L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_aes_opt) + target_include_directories(qruov_1q127L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q127L3aes_opt PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2) + add_library(qruov_1q127L3aes_avx2 OBJECT qruov_qruov_1q127L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_aes_avx2) + target_include_directories(qruov_1q127L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q127L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q127L3aes_avx2 PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3shake) + add_library(qruov_1q127L3shake_ref OBJECT sig_qruov_1q127L3shake.c qruov_qruov_1q127L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q127L3shake_ref PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_shake_ref) + target_include_directories(qruov_1q127L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q127L3shake_ref PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3shake_opt) + add_library(qruov_1q127L3shake_opt OBJECT qruov_qruov_1q127L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_shake_opt) + target_include_directories(qruov_1q127L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q127L3shake_opt PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2) + add_library(qruov_1q127L3shake_avx2 OBJECT qruov_qruov_1q127L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L3_shake_avx2) + target_include_directories(qruov_1q127L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q127L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q127L3shake_avx2 PUBLIC -DQRUOV_PARAM_1q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10aes) + add_library(qruov_1q127L10aes_ref OBJECT sig_qruov_1q127L10aes.c qruov_qruov_1q127L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q127L10aes_ref PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_aes_ref) + target_include_directories(qruov_1q127L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q127L10aes_ref PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10aes_opt) + add_library(qruov_1q127L10aes_opt OBJECT qruov_qruov_1q127L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_aes_opt) + target_include_directories(qruov_1q127L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q127L10aes_opt PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2) + add_library(qruov_1q127L10aes_avx2 OBJECT qruov_qruov_1q127L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_aes_avx2) + target_include_directories(qruov_1q127L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q127L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q127L10aes_avx2 PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10shake) + add_library(qruov_1q127L10shake_ref OBJECT sig_qruov_1q127L10shake.c qruov_qruov_1q127L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_1q127L10shake_ref PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_1q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_shake_ref) + target_include_directories(qruov_1q127L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_1q127L10shake_ref PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10shake_opt) + add_library(qruov_1q127L10shake_opt OBJECT qruov_qruov_1q127L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_1q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_shake_opt) + target_include_directories(qruov_1q127L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_1q127L10shake_opt PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2) + add_library(qruov_1q127L10shake_avx2 OBJECT qruov_qruov_1q127L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_1q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_1q127L10_shake_avx2) + target_include_directories(qruov_1q127L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_1q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_1q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_1q127L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_1q127L10shake_avx2 PUBLIC -DQRUOV_PARAM_1q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_1q127L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10aes) + add_library(qruov_3q7L10aes_ref OBJECT sig_qruov_3q7L10aes.c qruov_qruov_3q7L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q7L10aes_ref PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_aes_ref) + target_include_directories(qruov_3q7L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q7L10aes_ref PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10aes_opt) + add_library(qruov_3q7L10aes_opt OBJECT qruov_qruov_3q7L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_aes_opt) + target_include_directories(qruov_3q7L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q7L10aes_opt PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2) + add_library(qruov_3q7L10aes_avx2 OBJECT qruov_qruov_3q7L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_aes_avx2) + target_include_directories(qruov_3q7L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q7L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q7L10aes_avx2 PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10shake) + add_library(qruov_3q7L10shake_ref OBJECT sig_qruov_3q7L10shake.c qruov_qruov_3q7L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q7L10shake_ref PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_shake_ref) + target_include_directories(qruov_3q7L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q7L10shake_ref PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10shake_opt) + add_library(qruov_3q7L10shake_opt OBJECT qruov_qruov_3q7L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_shake_opt) + target_include_directories(qruov_3q7L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q7L10shake_opt PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2) + add_library(qruov_3q7L10shake_avx2 OBJECT qruov_qruov_3q7L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q7L10_shake_avx2) + target_include_directories(qruov_3q7L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q7L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q7L10shake_avx2 PUBLIC -DQRUOV_PARAM_3q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q7L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3aes) + add_library(qruov_3q31L3aes_ref OBJECT sig_qruov_3q31L3aes.c qruov_qruov_3q31L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q31L3aes_ref PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_aes_ref) + target_include_directories(qruov_3q31L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q31L3aes_ref PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3aes_opt) + add_library(qruov_3q31L3aes_opt OBJECT qruov_qruov_3q31L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_aes_opt) + target_include_directories(qruov_3q31L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q31L3aes_opt PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2) + add_library(qruov_3q31L3aes_avx2 OBJECT qruov_qruov_3q31L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_aes_avx2) + target_include_directories(qruov_3q31L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q31L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q31L3aes_avx2 PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3shake) + add_library(qruov_3q31L3shake_ref OBJECT sig_qruov_3q31L3shake.c qruov_qruov_3q31L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q31L3shake_ref PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_shake_ref) + target_include_directories(qruov_3q31L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q31L3shake_ref PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3shake_opt) + add_library(qruov_3q31L3shake_opt OBJECT qruov_qruov_3q31L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_shake_opt) + target_include_directories(qruov_3q31L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q31L3shake_opt PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2) + add_library(qruov_3q31L3shake_avx2 OBJECT qruov_qruov_3q31L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L3_shake_avx2) + target_include_directories(qruov_3q31L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q31L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q31L3shake_avx2 PUBLIC -DQRUOV_PARAM_3q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10aes) + add_library(qruov_3q31L10aes_ref OBJECT sig_qruov_3q31L10aes.c qruov_qruov_3q31L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q31L10aes_ref PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_aes_ref) + target_include_directories(qruov_3q31L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q31L10aes_ref PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10aes_opt) + add_library(qruov_3q31L10aes_opt OBJECT qruov_qruov_3q31L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_aes_opt) + target_include_directories(qruov_3q31L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q31L10aes_opt PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2) + add_library(qruov_3q31L10aes_avx2 OBJECT qruov_qruov_3q31L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_aes_avx2) + target_include_directories(qruov_3q31L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q31L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q31L10aes_avx2 PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10shake) + add_library(qruov_3q31L10shake_ref OBJECT sig_qruov_3q31L10shake.c qruov_qruov_3q31L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q31L10shake_ref PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_shake_ref) + target_include_directories(qruov_3q31L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q31L10shake_ref PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10shake_opt) + add_library(qruov_3q31L10shake_opt OBJECT qruov_qruov_3q31L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_shake_opt) + target_include_directories(qruov_3q31L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q31L10shake_opt PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2) + add_library(qruov_3q31L10shake_avx2 OBJECT qruov_qruov_3q31L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q31L10_shake_avx2) + target_include_directories(qruov_3q31L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q31L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q31L10shake_avx2 PUBLIC -DQRUOV_PARAM_3q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q31L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3aes) + add_library(qruov_3q127L3aes_ref OBJECT sig_qruov_3q127L3aes.c qruov_qruov_3q127L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q127L3aes_ref PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_aes_ref) + target_include_directories(qruov_3q127L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q127L3aes_ref PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3aes_opt) + add_library(qruov_3q127L3aes_opt OBJECT qruov_qruov_3q127L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_aes_opt) + target_include_directories(qruov_3q127L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q127L3aes_opt PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2) + add_library(qruov_3q127L3aes_avx2 OBJECT qruov_qruov_3q127L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_aes_avx2) + target_include_directories(qruov_3q127L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q127L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q127L3aes_avx2 PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3shake) + add_library(qruov_3q127L3shake_ref OBJECT sig_qruov_3q127L3shake.c qruov_qruov_3q127L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q127L3shake_ref PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_shake_ref) + target_include_directories(qruov_3q127L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q127L3shake_ref PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3shake_opt) + add_library(qruov_3q127L3shake_opt OBJECT qruov_qruov_3q127L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_shake_opt) + target_include_directories(qruov_3q127L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q127L3shake_opt PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2) + add_library(qruov_3q127L3shake_avx2 OBJECT qruov_qruov_3q127L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L3_shake_avx2) + target_include_directories(qruov_3q127L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q127L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q127L3shake_avx2 PUBLIC -DQRUOV_PARAM_3q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10aes) + add_library(qruov_3q127L10aes_ref OBJECT sig_qruov_3q127L10aes.c qruov_qruov_3q127L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q127L10aes_ref PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_aes_ref) + target_include_directories(qruov_3q127L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q127L10aes_ref PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10aes_opt) + add_library(qruov_3q127L10aes_opt OBJECT qruov_qruov_3q127L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_aes_opt) + target_include_directories(qruov_3q127L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q127L10aes_opt PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2) + add_library(qruov_3q127L10aes_avx2 OBJECT qruov_qruov_3q127L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_aes_avx2) + target_include_directories(qruov_3q127L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q127L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q127L10aes_avx2 PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10shake) + add_library(qruov_3q127L10shake_ref OBJECT sig_qruov_3q127L10shake.c qruov_qruov_3q127L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_3q127L10shake_ref PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_3q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_shake_ref) + target_include_directories(qruov_3q127L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_3q127L10shake_ref PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10shake_opt) + add_library(qruov_3q127L10shake_opt OBJECT qruov_qruov_3q127L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_3q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_shake_opt) + target_include_directories(qruov_3q127L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_3q127L10shake_opt PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2) + add_library(qruov_3q127L10shake_avx2 OBJECT qruov_qruov_3q127L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_3q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_3q127L10_shake_avx2) + target_include_directories(qruov_3q127L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_3q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_3q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_3q127L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_3q127L10shake_avx2 PUBLIC -DQRUOV_PARAM_3q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_3q127L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10aes) + add_library(qruov_5q7L10aes_ref OBJECT sig_qruov_5q7L10aes.c qruov_qruov_5q7L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q7L10aes_ref PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_aes_ref) + target_include_directories(qruov_5q7L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q7L10aes_ref PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10aes_opt) + add_library(qruov_5q7L10aes_opt OBJECT qruov_qruov_5q7L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_aes_opt) + target_include_directories(qruov_5q7L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q7L10aes_opt PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2) + add_library(qruov_5q7L10aes_avx2 OBJECT qruov_qruov_5q7L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_aes_avx2) + target_include_directories(qruov_5q7L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q7L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q7L10aes_avx2 PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10shake) + add_library(qruov_5q7L10shake_ref OBJECT sig_qruov_5q7L10shake.c qruov_qruov_5q7L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q7L10shake_ref PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_shake_ref) + target_include_directories(qruov_5q7L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q7L10shake_ref PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10shake_opt) + add_library(qruov_5q7L10shake_opt OBJECT qruov_qruov_5q7L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_shake_opt) + target_include_directories(qruov_5q7L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q7L10shake_opt PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2) + add_library(qruov_5q7L10shake_avx2 OBJECT qruov_qruov_5q7L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q7L10_shake_avx2) + target_include_directories(qruov_5q7L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q7L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q7L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q7L10shake_avx2 PUBLIC -DQRUOV_PARAM_5q7L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q7L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3aes) + add_library(qruov_5q31L3aes_ref OBJECT sig_qruov_5q31L3aes.c qruov_qruov_5q31L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q31L3aes_ref PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_aes_ref) + target_include_directories(qruov_5q31L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q31L3aes_ref PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3aes_opt) + add_library(qruov_5q31L3aes_opt OBJECT qruov_qruov_5q31L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_aes_opt) + target_include_directories(qruov_5q31L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q31L3aes_opt PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2) + add_library(qruov_5q31L3aes_avx2 OBJECT qruov_qruov_5q31L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_aes_avx2) + target_include_directories(qruov_5q31L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q31L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q31L3aes_avx2 PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3shake) + add_library(qruov_5q31L3shake_ref OBJECT sig_qruov_5q31L3shake.c qruov_qruov_5q31L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q31L3shake_ref PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_shake_ref) + target_include_directories(qruov_5q31L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q31L3shake_ref PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3shake_opt) + add_library(qruov_5q31L3shake_opt OBJECT qruov_qruov_5q31L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_shake_opt) + target_include_directories(qruov_5q31L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q31L3shake_opt PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2) + add_library(qruov_5q31L3shake_avx2 OBJECT qruov_qruov_5q31L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L3_shake_avx2) + target_include_directories(qruov_5q31L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q31L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q31L3shake_avx2 PUBLIC -DQRUOV_PARAM_5q31L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10aes) + add_library(qruov_5q31L10aes_ref OBJECT sig_qruov_5q31L10aes.c qruov_qruov_5q31L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q31L10aes_ref PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_aes_ref) + target_include_directories(qruov_5q31L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q31L10aes_ref PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10aes_opt) + add_library(qruov_5q31L10aes_opt OBJECT qruov_qruov_5q31L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_aes_opt) + target_include_directories(qruov_5q31L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q31L10aes_opt PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2) + add_library(qruov_5q31L10aes_avx2 OBJECT qruov_qruov_5q31L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_aes_avx2) + target_include_directories(qruov_5q31L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q31L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q31L10aes_avx2 PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10shake) + add_library(qruov_5q31L10shake_ref OBJECT sig_qruov_5q31L10shake.c qruov_qruov_5q31L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q31L10shake_ref PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_shake_ref) + target_include_directories(qruov_5q31L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q31L10shake_ref PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10shake_opt) + add_library(qruov_5q31L10shake_opt OBJECT qruov_qruov_5q31L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_shake_opt) + target_include_directories(qruov_5q31L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q31L10shake_opt PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2) + add_library(qruov_5q31L10shake_avx2 OBJECT qruov_qruov_5q31L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q31L10_shake_avx2) + target_include_directories(qruov_5q31L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q31L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q31L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q31L10shake_avx2 PUBLIC -DQRUOV_PARAM_5q31L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q31L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3aes) + add_library(qruov_5q127L3aes_ref OBJECT sig_qruov_5q127L3aes.c qruov_qruov_5q127L3_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q127L3aes_ref PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_aes_ref) + target_include_directories(qruov_5q127L3aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q127L3aes_ref PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3aes_opt) + add_library(qruov_5q127L3aes_opt OBJECT qruov_qruov_5q127L3_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_aes_opt) + target_include_directories(qruov_5q127L3aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q127L3aes_opt PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2) + add_library(qruov_5q127L3aes_avx2 OBJECT qruov_qruov_5q127L3_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_aes_avx2) + target_include_directories(qruov_5q127L3aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q127L3aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q127L3aes_avx2 PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3shake) + add_library(qruov_5q127L3shake_ref OBJECT sig_qruov_5q127L3shake.c qruov_qruov_5q127L3_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q127L3shake_ref PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_shake_ref) + target_include_directories(qruov_5q127L3shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q127L3shake_ref PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3shake_opt) + add_library(qruov_5q127L3shake_opt OBJECT qruov_qruov_5q127L3_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_shake_opt) + target_include_directories(qruov_5q127L3shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q127L3shake_opt PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2) + add_library(qruov_5q127L3shake_avx2 OBJECT qruov_qruov_5q127L3_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L3_shake_avx2) + target_include_directories(qruov_5q127L3shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L3shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q127L3shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q127L3shake_avx2 PUBLIC -DQRUOV_PARAM_5q127L3 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L3_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10aes) + add_library(qruov_5q127L10aes_ref OBJECT sig_qruov_5q127L10aes.c qruov_qruov_5q127L10_aes_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q127L10aes_ref PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_aes_ref) + target_include_directories(qruov_5q127L10aes_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10aes_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q127L10aes_ref PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_aes_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10aes_opt) + add_library(qruov_5q127L10aes_opt OBJECT qruov_qruov_5q127L10_aes_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_aes_opt) + target_include_directories(qruov_5q127L10aes_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10aes_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q127L10aes_opt PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_aes_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2) + add_library(qruov_5q127L10aes_avx2 OBJECT qruov_qruov_5q127L10_aes_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_aes_avx2) + target_include_directories(qruov_5q127L10aes_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10aes_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q127L10aes_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q127L10aes_avx2 PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=1 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_aes_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10shake) + add_library(qruov_5q127L10shake_ref OBJECT sig_qruov_5q127L10shake.c qruov_qruov_5q127L10_shake_ref/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_ref/qruov.c) + target_compile_options(qruov_5q127L10shake_ref PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + target_include_directories(qruov_5q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_shake_ref) + target_include_directories(qruov_5q127L10shake_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10shake_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_ref) + target_compile_options(qruov_5q127L10shake_ref PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_shake_ref_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10shake_opt) + add_library(qruov_5q127L10shake_opt OBJECT qruov_qruov_5q127L10_shake_opt/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_opt/emi_transform.c qruov_qruov_opt/emi_transform_gen.c qruov_qruov_opt/qruov.c) + target_include_directories(qruov_5q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_shake_opt) + target_include_directories(qruov_5q127L10shake_opt PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10shake_opt PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_opt) + target_compile_options(qruov_5q127L10shake_opt PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_shake_opt_ $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +if(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2) + add_library(qruov_5q127L10shake_avx2 OBJECT qruov_qruov_5q127L10_shake_avx2/signature.c qruov_qruov_common/linsys.c qruov_qruov_common/prg.c qruov_qruov_common/prim.c qruov_qruov_common/qrop.c qruov_qruov_common/qruov_common.c qruov_qruov_common/randombytes.c qruov_qruov_common/sign.c qruov_qruov_avx2/emi_matrix.c qruov_qruov_avx2/emi_transform.c qruov_qruov_avx2/emi_transform_gen.c qruov_qruov_avx2/helpers.c qruov_qruov_avx2/kernel.c qruov_qruov_avx2/qruov.c qruov_qruov_avx2/x86aesni.c) + target_include_directories(qruov_5q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_5q127L10_shake_avx2) + target_include_directories(qruov_5q127L10shake_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_include_directories(qruov_5q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_common) + target_include_directories(qruov_5q127L10shake_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/qruov_qruov_avx2) + target_compile_options(qruov_5q127L10shake_avx2 PRIVATE -mavx2 -mbmi2 -maes) + target_compile_options(qruov_5q127L10shake_avx2 PUBLIC -DQRUOV_PARAM_5q127L10 -DPRG_IS_AES=0 -DQRUOV_PRIM_OQS -DQRUOV_NAMESPACE_PREFIX=qruov_5q127L10_shake_avx2_ -DPRIM_AES_BACKEND_X86AESNI=1 -mavx2 -mbmi2 -maes $<$:/FInamespace.h> $<$>:-include> $<$>:namespace.h>) + set(_QRUOV_OBJS ${_QRUOV_OBJS} $) +endif() + +set(QRUOV_OBJS ${_QRUOV_OBJS} PARENT_SCOPE) diff --git a/src/sig/qruov/qruov_qruov_1q127L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_1q127L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q127L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_1q127L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q127L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_1q31L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q31L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_1q31L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q31L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_1q7L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_1q7L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_1q7L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_3q127L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q127L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_3q127L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q127L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_3q31L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q31L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_3q31L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q31L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_3q7L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_3q7L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_3q7L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_5q127L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q127L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_5q127L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q127L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_5q31L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q31L3_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_5q31L3_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q31L3_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_aes_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_aes_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_aes_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_aes_opt/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_aes_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_aes_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_aes_ref/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_aes_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_aes_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_shake_avx2/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_shake_avx2/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_shake_avx2/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_shake_opt/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_shake_opt/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_shake_opt/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_5q7L10_shake_ref/signature.c b/src/sig/qruov/qruov_qruov_5q7L10_shake_ref/signature.c new file mode 100644 index 0000000000..924e7b2f03 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_5q7L10_shake_ref/signature.c @@ -0,0 +1,87 @@ +#include +#include +#include + +#include "qruov.h" +#include "qrop.h" +#include "rng.h" +#include "util.h" + +int crypto_sign_signature(unsigned char *sig, + size_t *siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *sk) +{ + int ret = -1; + + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + + *siglen = 0; + + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + + qruov_init(); + + if (qruov_sign(seed_pk, seed_sk, + seed_y, seed_r, seed_sol, + m, mlen, + sig_r, sig_s) != 0) { + goto cleanup; + } + + memcpy(sig, sig_r, SALT_LEN); + store_fq(sig + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + + *siglen = QRUOV_SIG_LEN; + ret = 0; + +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + + return ret; +} + +int crypto_sign_verify(const unsigned char *sig, + size_t siglen, + const unsigned char *m, + size_t mlen, + const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + + if (siglen != QRUOV_SIG_LEN) { + return -1; + } + + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sig, SALT_LEN); + + if (!load_fq_checked(sig_s, + sig + SALT_LEN, + SIG_S_COEFF_LEN)) { + return -1; + } + + qruov_init(); + + return qruov_verify(seed_pk, + pk + SEED_PK_LEN, + m, + mlen, + sig_r, + sig_s) ? 0 : -1; +} diff --git a/src/sig/qruov/qruov_qruov_avx2/emi_matrix.c b/src/sig/qruov/qruov_qruov_avx2/emi_matrix.c new file mode 100644 index 0000000000..f10d90beb3 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/emi_matrix.c @@ -0,0 +1,23 @@ +// auto generated by genmat.py +#include "emi_transform.h" +#if QRUOV_q == 31 && QRUOV_L == 3 +const int MAT_EVAL[] = {1, 0, 0, 1, 1, 1, 1, 30, 1, 1, 2, 4, 0, 0, 1}; +const int MAT_INTERP[] = {17, 15, 5, 26, 29, 0, 16, 15, 0, 1, 30, 16, 16, 0, 0}; +const int MAT_REEVAL[] = {17, 15, 5, 26, 29, 16, 16, 5, 26, 30, 16, 15, 6, 26, 28, 13, 18, 6, 26, 0, 30, 16, 16, 0, 0}; +#elif QRUOV_q == 127 && QRUOV_L == 3 +const int MAT_EVAL[] = {1, 0, 0, 1, 1, 1, 1, 126, 1, 1, 2, 4, 0, 0, 1}; +const int MAT_INTERP[] = {65, 63, 21, 106, 125, 0, 64, 63, 0, 1, 126, 64, 64, 0, 0}; +const int MAT_REEVAL[] = {65, 63, 21, 106, 125, 64, 64, 21, 106, 126, 64, 63, 22, 106, 124, 61, 66, 22, 106, 0, 126, 64, 64, 0, 0}; +#elif QRUOV_q == 31 && QRUOV_L == 10 +const int MAT_EVAL[] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 2, 4, 8, 16, 1, 2, 4, 8, 16, 1, 29, 4, 23, 16, 30, 2, 27, 8, 15, 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 1, 28, 9, 4, 19, 5, 16, 14, 20, 2, 1, 4, 16, 2, 8, 1, 4, 16, 2, 8, 1, 27, 16, 29, 8, 30, 4, 15, 2, 23, 1, 5, 25, 1, 5, 25, 1, 5, 25, 1, 1, 26, 25, 30, 5, 6, 1, 26, 25, 30, 1, 6, 5, 30, 25, 26, 1, 6, 5, 30, 1, 25, 5, 1, 25, 5, 1, 25, 5, 1, 1, 7, 18, 2, 14, 5, 4, 28, 10, 8, 1, 24, 18, 29, 14, 26, 4, 3, 10, 23, 1, 8, 2, 16, 4, 1, 8, 2, 16, 4, 1, 23, 2, 15, 4, 30, 8, 29, 16, 27, 1, 9, 19, 16, 20, 25, 8, 10, 28, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +const int MAT_INTERP[] = {20, 10, 2, 19, 25, 17, 4, 30, 7, 9, 1, 30, 9, 29, 21, 3, 27, 17, 3, 14, 30, 13, 17, 25, 10, 12, 2, 26, 24, 28, 13, 0, 1, 14, 23, 19, 8, 13, 23, 13, 13, 6, 6, 26, 26, 23, 23, 16, 16, 15, 15, 13, 13, 16, 16, 0, 6, 27, 24, 22, 2, 14, 1, 6, 20, 29, 17, 24, 16, 14, 25, 6, 25, 14, 24, 16, 11, 20, 6, 15, 1, 16, 16, 3, 12, 25, 28, 30, 17, 29, 17, 11, 24, 29, 16, 10, 0, 10, 0, 24, 1, 2, 14, 8, 20, 22, 28, 6, 25, 16, 2, 25, 4, 18, 6, 10, 13, 27, 30, 18, 6, 24, 8, 12, 19, 19, 23, 2, 4, 29, 10, 19, 22, 27, 16, 7, 8, 4, 29, 2, 9, 4, 1, 9, 19, 24, 2, 28, 17, 26, 16, 7, 22, 12, 21, 18, 6, 15, 7, 8, 26, 28, 0, 15, 5, 8, 5, 10, 7, 4, 16, 7, 3, 11, 25, 15, 17, 2, 13, 0, 17, 18, 2, 22, 3, 14, 18, 28, 2, 5}; +const int MAT_REEVAL[] = {20, 10, 2, 19, 25, 17, 4, 30, 7, 9, 1, 30, 9, 29, 21, 3, 27, 17, 3, 12, 14, 25, 13, 26, 26, 21, 22, 19, 14, 10, 1, 11, 13, 14, 30, 10, 30, 29, 28, 23, 23, 2, 17, 3, 4, 30, 9, 11, 25, 0, 3, 25, 13, 15, 3, 15, 4, 20, 25, 16, 2, 26, 20, 19, 22, 17, 23, 29, 26, 1, 28, 15, 24, 7, 22, 22, 2, 10, 21, 30, 10, 23, 8, 15, 21, 24, 19, 4, 16, 20, 27, 25, 10, 26, 20, 30, 20, 22, 8, 15, 11, 4, 15, 26, 27, 15, 5, 4, 13, 19, 23, 11, 12, 4, 23, 27, 26, 29, 17, 12, 2, 18, 15, 5, 25, 7, 6, 29, 22, 2, 14, 1, 16, 5, 22, 7, 4, 8, 4, 14, 7, 14, 3, 4, 25, 27, 8, 12, 20, 27, 7, 12, 29, 25, 15, 10, 18, 20, 11, 7, 11, 19, 25, 29, 17, 17, 26, 16, 8, 8, 0, 21, 10, 7, 5, 18, 14, 20, 11, 5, 14, 4, 29, 24, 5, 12, 7, 12, 0, 17, 4, 23, 16, 11, 20, 3, 12, 3, 22, 29, 0, 9, 1, 2, 23, 10, 26, 4, 22, 6, 26, 0, 13, 10, 14, 21, 30, 20, 14, 2, 22, 15, 13, 10, 4, 18, 11, 17, 23, 24, 19, 15, 22, 26, 13, 11, 15, 13, 17, 16, 14, 4, 16, 2, 29, 1, 30, 17, 19, 28, 25, 14, 3, 7, 26, 2, 15, 19, 21, 15, 27, 2, 14, 15, 11, 9, 4, 16, 20, 16, 20, 30, 23, 27, 24, 13, 7, 11, 1, 30, 0, 6, 19, 13, 10, 30, 2, 24, 11, 25, 27, 21, 22, 29, 30, 25, 14, 24, 20, 5, 16, 13, 4, 24, 29, 30, 30, 1, 16, 15, 12, 19, 17, 7, 11, 14, 5, 21, 15, 27, 30, 12, 6, 29, 8, 3, 30, 11, 24, 11, 6, 27, 0, 9, 30, 17, 23, 2, 16, 30, 4, 21, 7, 3, 11, 25, 15, 17, 2, 13, 0, 17, 18, 2, 22, 3, 14, 18, 28, 2, 5}; +#elif QRUOV_q == 7 && QRUOV_L == 10 +const int MAT_EVAL[] = {1, 2, 6, 0, 6, 5, 6, 3, 1, 5, 1, 2, 3, 6, 2, 6, 4, 2, 3, 6, 1, 4, 4, 0, 0, 4, 1, 2, 2, 5, 1, 5, 4, 2, 2, 3, 5, 5, 1, 0, 1, 0, 6, 1, 4, 3, 5, 2, 5, 3, 1, 2, 1, 2, 1, 1, 2, 0, 4, 2, 1, 4, 4, 6, 6, 4, 1, 6, 0, 5, 1, 6, 2, 0, 3, 3, 2, 1, 3, 2, 1, 1, 4, 1, 2, 3, 5, 2, 1, 5, 1, 2, 6, 3, 5, 0, 6, 1, 6, 6, 1, 6, 6, 1, 2, 4, 1, 4, 1, 3, 1, 5, 2, 6, 2, 0, 1, 3, 0, 3, 1, 6, 4, 3, 6, 1, 0, 4, 4, 6, 1, 4, 2, 4, 6, 3, 2, 6, 0, 3, 1, 6, 2, 4, 2, 6, 3, 5, 0, 1, 1, 4, 2, 1, 0, 5, 4, 1, 5, 5, 1, 4, 5, 0, 2, 3, 5, 5, 5, 5, 1, 1, 3, 0, 6, 3, 0, 6, 1, 5, 1, 5, 5, 6, 2, 6, 6, 1, 6, 3, 1, 6, 6, 2, 0, 6, 2, 5, 1, 0, 1, 6, 1, 2, 0, 3, 6, 1, 1, 6, 1, 3, 6, 6, 0, 5, 5, 2, 5, 4, 1, 0, 4, 4, 5, 4, 0, 1, 4, 0}; +const int MAT_INTERP[] = {4, 6, 6, 2, 6, 3, 5, 5, 3, 6, 5, 1, 0, 6, 6, 4, 6, 2, 5, 5, 0, 4, 2, 3, 3, 5, 6, 0, 3, 5, 5, 4, 6, 5, 3, 1, 5, 3, 0, 4, 4, 4, 0, 3, 0, 5, 0, 4, 6, 3, 3, 6, 3, 3, 1, 2, 3, 0, 3, 3, 5, 0, 2, 2, 5, 3, 4, 1, 1, 6, 1, 5, 3, 5, 2, 6, 2, 4, 2, 4, 4, 6, 1, 6, 2, 4, 6, 4, 5, 5, 3, 5, 0, 2, 3, 2, 4, 5, 6, 1, 3, 2, 5, 6, 4, 5, 4, 4, 4, 1, 6, 4, 5, 6, 2, 2, 4, 4, 6, 3, 1, 2, 2, 4, 3, 3, 0, 4, 4, 0, 3, 1, 4, 5, 4, 0, 0, 4, 6, 3, 1, 2, 1, 5, 4, 0, 3, 0, 6, 2, 1, 6, 6, 0, 1, 4, 1, 4, 4, 6, 4, 0, 3, 0, 5, 5, 3, 3, 3, 1, 6, 0, 0, 5, 6, 4, 1, 3, 1, 0, 6, 2, 5, 1, 4, 4, 4, 1, 0, 5, 1, 2, 5, 1, 6, 6, 4, 1, 1, 1, 5, 3, 4, 4, 0, 6, 2, 2, 2, 0, 1, 5, 3, 5, 4, 6, 3, 1, 0, 6, 0, 0, 0, 5, 1, 6, 3, 2, 4, 4}; +const int MAT_REEVAL[] = {0, 4, 2, 2, 4, 6, 5, 3, 6, 0, 6, 5, 0, 6, 3, 5, 2, 6, 4, 2, 2, 4, 1, 1, 2, 5, 3, 3, 2, 6, 2, 0, 0, 5, 6, 1, 6, 1, 5, 1, 6, 6, 1, 6, 1, 2, 6, 0, 5, 4, 3, 2, 5, 5, 0, 2, 2, 6, 4, 4, 5, 6, 6, 3, 2, 2, 4, 0, 2, 1, 5, 1, 3, 5, 6, 3, 1, 1, 1, 0, 3, 6, 2, 0, 3, 1, 0, 5, 3, 4, 3, 0, 2, 0, 5, 0, 0, 3, 0, 0, 6, 0, 0, 6, 0, 6, 3, 3, 1, 6, 2, 5, 2, 0, 0, 0, 1, 1, 6, 3, 5, 4, 6, 2, 4, 2, 0, 6, 4, 0, 5, 5, 2, 4, 0, 2, 5, 4, 6, 1, 3, 3, 0, 4, 3, 3, 1, 6, 2, 5, 6, 6, 2, 2, 0, 1, 5, 2, 2, 6, 2, 0, 5, 6, 5, 1, 1, 5, 4, 0, 6, 6, 3, 4, 6, 2, 1, 2, 2, 0, 4, 6, 4, 5, 0, 0, 4, 1, 3, 5, 0, 4, 1, 0, 2, 1, 4, 5, 5, 5, 4, 1, 1, 2, 5, 5, 6, 2, 1, 0, 3, 2, 3, 4, 6, 3, 6, 1, 6, 3, 5, 0, 2, 1, 3, 4, 4, 3, 3, 6, 3, 3, 6, 1, 1, 6, 6, 0, 5, 1, 3, 1, 6, 0, 0, 3, 0, 6, 6, 2, 5, 6, 1, 4, 1, 3, 3, 4, 5, 0, 1, 2, 6, 2, 5, 5, 0, 2, 6, 3, 4, 6, 3, 2, 6, 5, 0, 1, 1, 2, 5, 6, 2, 0, 6, 5, 3, 0, 3, 1, 1, 3, 4, 0, 0, 6, 1, 2, 5, 1, 0, 6, 6, 0, 0, 5, 4, 6, 3, 3, 6, 1, 0, 0, 2, 6, 4, 6, 1, 5, 3, 3, 1, 6, 3, 2, 0, 6, 2, 5, 4, 4, 6, 4, 4, 2, 6, 1, 3, 0, 1, 3, 3, 0, 5, 2, 1, 3, 4, 3, 6, 5, 6, 1, 0, 4, 6, 4, 4, 4, 6, 1, 1, 2, 2, 4, 4, 5, 5, 2, 1, 3, 2, 5, 4, 2, 5, 5, 5, 2, 0, 2, 1, 3, 1, 3, 2, 6, 5, 0, 0, 6, 0, 0, 6, 5, 4, 0, 1, 4, 0, 6, 4, 5, 1, 3, 2, 0, 2, 4, 0, 4, 1, 6, 0, 0, 4, 5, 5, 1, 6, 0, 2, 3, 4, 2, 1, 1, 3, 0, 2, 0, 3, 5, 2, 2, 6, 6, 1, 0, 2, 2, 6, 3, 2, 4, 2, 6, 2, 0, 4, 1, 4, 1, 6, 5, 1, 0, 3, 3, 1, 2, 4, 5, 6, 6, 2, 0, 3, 5, 5, 3, 0, 5, 5, 5, 3, 2, 5, 5, 0, 5, 1, 5, 2, 6, 3, 6, 0, 2, 1, 5, 1, 1, 4, 3, 0, 5, 3, 3, 4, 5, 4, 4, 2, 2, 3, 1, 6, 6, 5, 3, 2, 0, 5, 5, 3, 1, 2, 3, 1, 0, 0, 5, 2, 4, 0, 2, 5}; +#elif QRUOV_q == 127 && QRUOV_L == 10 +const int MAT_EVAL[] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 126, 1, 126, 1, 126, 1, 126, 1, 126, 1, 2, 4, 8, 16, 32, 64, 1, 2, 4, 1, 125, 4, 119, 16, 95, 64, 126, 2, 123, 1, 3, 9, 27, 81, 116, 94, 28, 84, 125, 1, 124, 9, 100, 81, 11, 94, 99, 84, 2, 1, 4, 16, 64, 2, 8, 32, 1, 4, 16, 1, 123, 16, 63, 2, 119, 32, 126, 4, 111, 1, 5, 25, 125, 117, 77, 4, 20, 100, 119, 1, 122, 25, 2, 117, 50, 4, 107, 100, 8, 1, 6, 36, 89, 26, 29, 47, 28, 41, 119, 1, 121, 36, 38, 26, 98, 47, 99, 41, 8, 1, 7, 49, 89, 115, 43, 47, 75, 17, 119, 1, 120, 49, 38, 115, 84, 47, 52, 17, 8, 1, 8, 64, 4, 32, 2, 16, 1, 8, 64, 1, 119, 64, 123, 32, 125, 16, 126, 8, 63, 1, 9, 81, 94, 84, 121, 73, 22, 71, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; +const int MAT_INTERP[] = {98, 124, 68, 76, 42, 85, 83, 97, 108, 35, 114, 29, 85, 21, 104, 66, 105, 58, 23, 85, 95, 6, 75, 94, 105, 61, 59, 50, 94, 112, 96, 120, 118, 32, 81, 118, 123, 12, 25, 53, 53, 67, 67, 111, 111, 18, 18, 94, 94, 113, 113, 22, 22, 81, 81, 0, 13, 36, 72, 63, 112, 28, 65, 73, 93, 86, 90, 100, 7, 72, 68, 75, 92, 31, 107, 5, 69, 108, 86, 67, 106, 17, 105, 25, 34, 37, 29, 42, 1, 39, 65, 46, 66, 74, 7, 103, 50, 62, 44, 50, 32, 100, 44, 82, 29, 86, 20, 120, 36, 30, 56, 0, 72, 24, 82, 26, 8, 57, 22, 42, 78, 31, 6, 27, 111, 89, 56, 34, 42, 111, 91, 103, 80, 120, 108, 28, 110, 93, 41, 24, 77, 72, 115, 88, 22, 112, 0, 108, 66, 64, 22, 23, 68, 101, 3, 7, 36, 111, 28, 78, 40, 44, 78, 41, 67, 19, 116, 28, 45, 106, 108, 82, 42, 95, 116, 124, 47, 28, 111, 116, 8, 108, 4, 91, 54, 70, 111, 17, 46, 112}; +const int MAT_REEVAL[] = {98, 124, 68, 76, 42, 85, 83, 97, 108, 35, 114, 29, 85, 21, 104, 66, 105, 58, 23, 6, 17, 91, 96, 27, 21, 56, 125, 104, 65, 31, 82, 75, 30, 29, 103, 110, 76, 26, 43, 45, 91, 71, 11, 76, 119, 119, 54, 28, 59, 38, 61, 113, 34, 53, 31, 98, 55, 93, 95, 2, 105, 118, 106, 121, 39, 56, 103, 64, 110, 5, 15, 68, 56, 14, 101, 95, 71, 18, 28, 18, 123, 77, 38, 45, 34, 74, 108, 36, 28, 37, 108, 6, 52, 116, 29, 16, 4, 113, 12, 22, 90, 113, 13, 15, 88, 122, 105, 11, 77, 58, 89, 0, 69, 100, 40, 37, 26, 89, 49, 7, 75, 119, 38, 70, 82, 26, 9, 7, 106, 108, 71, 58, 81, 50, 83, 90, 93, 88, 41, 70, 99, 87, 120, 33, 42, 14, 98, 27, 31, 51, 27, 24, 29, 66, 82, 79, 69, 86, 13, 77, 21, 106, 125, 45, 22, 84, 62, 45, 55, 78, 100, 44, 68, 9, 89, 79, 116, 81, 51, 97, 106, 8, 33, 77, 58, 71, 61, 5, 91, 33, 54, 123, 70, 119, 102, 114, 107, 8, 5, 113, 0, 31, 13, 58, 105, 37, 90, 122, 30, 43, 110, 111, 87, 122, 113, 117, 80, 123, 86, 44, 81, 95, 19, 86, 84, 107, 17, 43, 29, 103, 40, 81, 78, 12, 15, 82, 16, 90, 17, 54, 98, 7, 4, 47, 21, 96, 26, 106, 15, 31, 41, 123, 91, 122, 8, 20, 52, 61, 126, 124, 5, 11, 17, 63, 1, 53, 109, 77, 25, 124, 36, 110, 49, 58, 20, 57, 52, 73, 96, 19, 49, 47, 75, 68, 99, 95, 75, 69, 17, 83, 44, 83, 106, 119, 37, 19, 41, 76, 116, 109, 2, 7, 46, 37, 126, 61, 86, 76, 4, 0, 79, 9, 75, 126, 101, 99, 87, 26, 115, 43, 12, 19, 59, 86, 40, 59, 21, 125, 67, 7, 124, 10, 114, 124, 17, 56, 108, 14, 23, 68, 81, 50, 82, 42, 95, 116, 124, 47, 28, 111, 116, 8, 108, 4, 91, 54, 70, 111, 17, 46, 112}; +#endif diff --git a/src/sig/qruov/qruov_qruov_avx2/emi_transform.c b/src/sig/qruov/qruov_qruov_avx2/emi_transform.c new file mode 100644 index 0000000000..211e49e6df --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/emi_transform.c @@ -0,0 +1,271 @@ +#include +#include +#include "emi_transform.h" +#include "qruov_simd.h" + +extern const int MAT_EVAL[]; +extern const int MAT_INTERP[]; +extern const int MAT_REEVAL[]; + +#if QRUOV_q == 31 && QRUOV_L == 3 +void interpolate_q31_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_q31_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 127 && QRUOV_L == 3 +void interpolate_avx2_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_avx2_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 31 && QRUOV_L == 10 +void interpolate_q31_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_q31_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 7 && QRUOV_L == 10 +void evaluate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 127 && QRUOV_L == 10 +void interpolate_avx2_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_avx2_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#else +#error "Unsupported (q, L) for AVX2 EMI transform" +#endif + +#if QRUOV_L == 3 && (QRUOV_q == 31 || QRUOV_q == 127) +static void evaluate_specialized_L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + const __m256i q = _mm256_set1_epi8(QRUOV_q); + assert(size >= 32); + + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i a0 = _mm256_loadu_si256((const __m256i *)&input[0 * plane_in + offset]); + const __m256i a1 = _mm256_loadu_si256((const __m256i *)&input[1 * plane_in + offset]); + const __m256i a2 = _mm256_loadu_si256((const __m256i *)&input[2 * plane_in + offset]); + const __m256i a0a2 = ymm_subq_if_greater_epi8(_mm256_add_epi8(a0, a2)); + const __m256i a2d = ymm_subq_if_greater_epi8(_mm256_add_epi8(a2, a2)); + const __m256i a1a2d = ymm_subq_if_greater_epi8(_mm256_add_epi8(a1, a2d)); + const __m256i a1da2q = ymm_subq_if_greater_epi8(_mm256_add_epi8(a1a2d, a1a2d)); + + _mm256_storeu_si256((__m256i *)&output[0 * plane_out + offset], a0); + _mm256_storeu_si256((__m256i *)&output[1 * plane_out + offset], ymm_subq_if_greater_epi8(_mm256_add_epi8(a1, a0a2))); + _mm256_storeu_si256((__m256i *)&output[2 * plane_out + offset], + ymm_subq_if_greater_epi8(_mm256_add_epi8(_mm256_xor_si256(a1, q), a0a2))); + _mm256_storeu_si256((__m256i *)&output[3 * plane_out + offset], ymm_subq_if_greater_epi8(_mm256_add_epi8(a0, a1da2q))); + _mm256_storeu_si256((__m256i *)&output[4 * plane_out + offset], a2); + } +} +#endif + +#if QRUOV_q == 31 && QRUOV_L == 10 +static void evaluate_specialized_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + __m256i b09; + __m256i b24; + __m256i b68; + __m256i b13; + __m256i b57; + __m128i a9_saved; + + { + const __m128i a0 = _mm_loadu_si128((const __m128i *)&input[0 * plane_in + offset]); + const __m128i a1 = _mm_loadu_si128((const __m128i *)&input[1 * plane_in + offset]); + const __m128i a2 = _mm_loadu_si128((const __m128i *)&input[2 * plane_in + offset]); + const __m128i a3 = _mm_loadu_si128((const __m128i *)&input[3 * plane_in + offset]); + const __m128i a4 = _mm_loadu_si128((const __m128i *)&input[4 * plane_in + offset]); + const __m128i a5 = _mm_loadu_si128((const __m128i *)&input[5 * plane_in + offset]); + const __m128i a6 = _mm_loadu_si128((const __m128i *)&input[6 * plane_in + offset]); + const __m128i a7 = _mm_loadu_si128((const __m128i *)&input[7 * plane_in + offset]); + const __m128i a8 = _mm_loadu_si128((const __m128i *)&input[8 * plane_in + offset]); + const __m128i a9 = _mm_loadu_si128((const __m128i *)&input[9 * plane_in + offset]); + + a9_saved = a9; + _mm_storeu_si128((__m128i *)&output[offset], a0); + b09 = _mm256_setr_m128i(_mm_unpacklo_epi8(a0, a9), _mm_unpackhi_epi8(a0, a9)); + b24 = _mm256_setr_m128i(_mm_unpacklo_epi8(a2, a4), _mm_unpackhi_epi8(a2, a4)); + b68 = _mm256_setr_m128i(_mm_unpacklo_epi8(a6, a8), _mm_unpackhi_epi8(a6, a8)); + b13 = _mm256_setr_m128i(_mm_unpacklo_epi8(a1, a3), _mm_unpackhi_epi8(a1, a3)); + b57 = _mm256_setr_m128i(_mm_unpacklo_epi8(a5, a7), _mm_unpackhi_epi8(a5, a7)); + } + +#define OUTPUT_PAIR(x, idx_pos, idx_neg) do { \ + const __m256i even = _mm256_add_epi16(_mm256_maddubs_epi16(b24, _mm256_set1_epi16(QRUOV_POW2(x) + (QRUOV_POW4(x) << 8))), \ + _mm256_maddubs_epi16(b68, _mm256_set1_epi16(QRUOV_POW6(x) + (QRUOV_POW8(x) << 8)))); \ + const __m256i odd = _mm256_add_epi16(_mm256_maddubs_epi16(b13, _mm256_set1_epi16(QRUOV_POW1(x) + (QRUOV_POW3(x) << 8))), \ + _mm256_maddubs_epi16(b57, _mm256_set1_epi16(QRUOV_POW5(x) + (QRUOV_POW7(x) << 8)))); \ + __m256i fx = _mm256_add_epi16(_mm256_maddubs_epi16(b09, _mm256_set1_epi16(QRUOV_POW0(x) + (QRUOV_POW9(x) << 8))), even); \ + __m256i fmx = _mm256_add_epi16(_mm256_maddubs_epi16(b09, _mm256_set1_epi16(QRUOV_POW0(-(x)) + (QRUOV_POW9(-(x)) << 8))), even); \ + fx = _mm256_add_epi16(fx, odd); \ + fmx = _mm256_add_epi16(fmx, _mm256_sub_epi16(_mm256_set1_epi16(31 * 31 * 16), odd)); \ + _mm_storeu_si128((__m128i *)&output[(idx_pos) * plane_out + offset], ymm_cvtusepi16_epi8(ymm_modq_epi15(fx))); \ + _mm_storeu_si128((__m128i *)&output[(idx_neg) * plane_out + offset], ymm_cvtusepi16_epi8(ymm_modq_epi15(fmx))); \ + } while (0) + + OUTPUT_PAIR(1, 1, 2); + OUTPUT_PAIR(2, 3, 4); + OUTPUT_PAIR(3, 5, 6); + OUTPUT_PAIR(4, 7, 8); + OUTPUT_PAIR(5, 9, 10); + OUTPUT_PAIR(6, 11, 12); + OUTPUT_PAIR(7, 13, 14); + OUTPUT_PAIR(8, 15, 16); + { + __m256i fx = _mm256_setzero_si256(); + + fx = _mm256_add_epi16(fx, _mm256_maddubs_epi16(b09, _mm256_set1_epi16(QRUOV_POW0(9) + (QRUOV_POW9(9) << 8)))); + fx = _mm256_add_epi16(fx, _mm256_maddubs_epi16(b24, _mm256_set1_epi16(QRUOV_POW2(9) + (QRUOV_POW4(9) << 8)))); + fx = _mm256_add_epi16(fx, _mm256_maddubs_epi16(b68, _mm256_set1_epi16(QRUOV_POW6(9) + (QRUOV_POW8(9) << 8)))); + fx = _mm256_add_epi16(fx, _mm256_maddubs_epi16(b13, _mm256_set1_epi16(QRUOV_POW1(9) + (QRUOV_POW3(9) << 8)))); + fx = _mm256_add_epi16(fx, _mm256_maddubs_epi16(b57, _mm256_set1_epi16(QRUOV_POW5(9) + (QRUOV_POW7(9) << 8)))); + _mm_storeu_si128((__m128i *)&output[17 * plane_out + offset], ymm_cvtusepi16_epi8(ymm_modq_epi15(fx))); + } + _mm_storeu_si128((__m128i *)&output[18 * plane_out + offset], a9_saved); +#undef OUTPUT_PAIR + } +} +#endif + +#if QRUOV_q == 127 && QRUOV_L == 10 +static void evaluate_specialized_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + __m256i b09; + __m256i b24; + __m256i b68; + __m256i b13; + __m256i b57; + __m256i signed_lift; + __m128i a9_saved; + + { + const __m128i a0 = _mm_loadu_si128((const __m128i *)&input[0 * plane_in + offset]); + const __m128i a1 = _mm_loadu_si128((const __m128i *)&input[1 * plane_in + offset]); + const __m128i a2 = _mm_loadu_si128((const __m128i *)&input[2 * plane_in + offset]); + const __m128i a3 = _mm_loadu_si128((const __m128i *)&input[3 * plane_in + offset]); + const __m128i a4 = _mm_loadu_si128((const __m128i *)&input[4 * plane_in + offset]); + const __m128i a5 = _mm_loadu_si128((const __m128i *)&input[5 * plane_in + offset]); + const __m128i a6 = _mm_loadu_si128((const __m128i *)&input[6 * plane_in + offset]); + const __m128i a7 = _mm_loadu_si128((const __m128i *)&input[7 * plane_in + offset]); + const __m128i a8 = _mm_loadu_si128((const __m128i *)&input[8 * plane_in + offset]); + const __m128i a9 = _mm_loadu_si128((const __m128i *)&input[9 * plane_in + offset]); + + a9_saved = a9; + _mm_storeu_si128((__m128i *)&output[0 * plane_out + offset], a0); + b09 = _mm256_setr_m128i(_mm_unpacklo_epi8(a0, a9), _mm_unpackhi_epi8(a0, a9)); + b24 = _mm256_setr_m128i(_mm_unpacklo_epi8(a2, a4), _mm_unpackhi_epi8(a2, a4)); + b68 = _mm256_setr_m128i(_mm_unpacklo_epi8(a6, a8), _mm_unpackhi_epi8(a6, a8)); + b13 = _mm256_setr_m128i(_mm_unpacklo_epi8(a1, a3), _mm_unpackhi_epi8(a1, a3)); + b57 = _mm256_setr_m128i(_mm_unpacklo_epi8(a5, a7), _mm_unpackhi_epi8(a5, a7)); + signed_lift = _mm256_set1_epi16(127 * 258); + } + const __m256i zero = _mm256_setzero_si256(); + +#define Q127_SIGNED(c) ((c) > 63 ? (c) - 127 : (c)) +#define Q127_PACK(c0, c1) \ + ((int16_t)((uint16_t)(uint8_t)(c0) | ((uint16_t)(uint8_t)(c1) << 8))) +#define Q127_MADD(pair, c0, c1) \ + _mm256_maddubs_epi16((pair), _mm256_set1_epi16(Q127_PACK((c0), (c1)))) +#define Q127_SIGNED_MADD(pair, c0, c1) \ + Q127_MADD((pair), Q127_SIGNED(c0), Q127_SIGNED(c1)) +#define Q127_LIFT_NEG(x) \ + _mm256_add_epi16((x), _mm256_and_si256(_mm256_cmpgt_epi16(zero, (x)), signed_lift)) +#define OUTPUT_SIGNED_PAIR(x, idx_pos, idx_neg) do { \ + const __m256i even = _mm256_add_epi16(Q127_SIGNED_MADD(b24, QRUOV_POW2(x), QRUOV_POW4(x)), \ + Q127_SIGNED_MADD(b68, QRUOV_POW6(x), QRUOV_POW8(x))); \ + const __m256i odd = _mm256_add_epi16(Q127_SIGNED_MADD(b13, QRUOV_POW1(x), QRUOV_POW3(x)), \ + Q127_SIGNED_MADD(b57, QRUOV_POW5(x), QRUOV_POW7(x))); \ + __m256i fx = _mm256_add_epi16(Q127_SIGNED_MADD(b09, QRUOV_POW0(x), QRUOV_POW9(x)), even); \ + __m256i fmx = _mm256_add_epi16(Q127_SIGNED_MADD(b09, QRUOV_POW0(-(x)), QRUOV_POW9(-(x))), even); \ + fx = _mm256_add_epi16(fx, odd); \ + fmx = _mm256_sub_epi16(fmx, odd); \ + _mm_storeu_si128((__m128i *)&output[(idx_pos) * plane_out + offset], \ + ymm_cvtusepi16_epi8(ymm_mod127_epi15(Q127_LIFT_NEG(fx)))); \ + _mm_storeu_si128((__m128i *)&output[(idx_neg) * plane_out + offset], \ + ymm_cvtusepi16_epi8(ymm_mod127_epi15(Q127_LIFT_NEG(fmx)))); \ + } while (0) + + OUTPUT_SIGNED_PAIR(1, 1, 2); + OUTPUT_SIGNED_PAIR(2, 3, 4); + OUTPUT_SIGNED_PAIR(3, 5, 6); + OUTPUT_SIGNED_PAIR(4, 7, 8); + OUTPUT_SIGNED_PAIR(5, 9, 10); + OUTPUT_SIGNED_PAIR(6, 11, 12); + OUTPUT_SIGNED_PAIR(7, 13, 14); + OUTPUT_SIGNED_PAIR(8, 15, 16); + { + __m256i fx = Q127_SIGNED_MADD(b09, QRUOV_POW0(9), QRUOV_POW9(9)); + fx = _mm256_add_epi16(fx, Q127_SIGNED_MADD(b24, QRUOV_POW2(9), QRUOV_POW4(9))); + fx = _mm256_add_epi16(fx, Q127_SIGNED_MADD(b68, QRUOV_POW6(9), QRUOV_POW8(9))); + fx = _mm256_add_epi16(fx, Q127_SIGNED_MADD(b13, QRUOV_POW1(9), QRUOV_POW3(9))); + fx = _mm256_add_epi16(fx, Q127_SIGNED_MADD(b57, QRUOV_POW5(9), QRUOV_POW7(9))); + _mm_storeu_si128((__m128i *)&output[17 * plane_out + offset], + ymm_cvtusepi16_epi8(ymm_mod127_epi15(Q127_LIFT_NEG(fx)))); + } + _mm_storeu_si128((__m128i *)&output[18 * plane_out + offset], a9_saved); + +#undef OUTPUT_SIGNED_PAIR +#undef Q127_LIFT_NEG +#undef Q127_SIGNED_MADD +#undef Q127_MADD +#undef Q127_PACK +#undef Q127_SIGNED + } +} +#endif + +void evaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + if (size < 32) abort(); +#if QRUOV_q == 7 && QRUOV_L == 10 + evaluate_q7_q7L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 3 + evaluate_specialized_L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + evaluate_specialized_L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + evaluate_specialized_q31L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + evaluate_specialized_q127L10(output, plane_out, input, plane_in, size); +#else +#error "Unsupported (q, L) for AVX2 EMI evaluate" +#endif +} + +void reevaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + if (size < 32) abort(); +#if QRUOV_q == 7 && QRUOV_L == 10 + reevaluate_q7_q7L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 3 + reevaluate_q31_q31L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + reevaluate_avx2_q127L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + reevaluate_q31_q31L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + reevaluate_avx2_q127L10(output, plane_out, input, plane_in, size); +#else +#error "Unsupported (q, L) for AVX2 EMI reevaluate" +#endif +} + +void interpolate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + if (size < 32) abort(); +#if QRUOV_q == 7 && QRUOV_L == 10 + interpolate_q7_q7L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 3 + interpolate_q31_q31L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + interpolate_avx2_q127L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + interpolate_q31_q31L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + interpolate_avx2_q127L10(output, plane_out, input, plane_in, size); +#else +#error "Unsupported (q, L) for AVX2 EMI interpolate" +#endif +} diff --git a/src/sig/qruov/qruov_qruov_avx2/emi_transform.h b/src/sig/qruov/qruov_qruov_avx2/emi_transform.h new file mode 100644 index 0000000000..54a4d889e6 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/emi_transform.h @@ -0,0 +1,25 @@ +// auto generated by genmat.py +#ifndef EMI_TRANSFORM_H +#define EMI_TRANSFORM_H + +#include "qruov.h" + +#if QRUOV_q == 31 && QRUOV_L == 3 +#define QRUOV_LL 5 +#elif QRUOV_q == 127 && QRUOV_L == 3 +#define QRUOV_LL 5 +#elif QRUOV_q == 31 && QRUOV_L == 10 +#define QRUOV_LL 19 +#elif QRUOV_q == 7 && QRUOV_L == 10 +#define QRUOV_LL 23 +#elif QRUOV_q == 127 && QRUOV_L == 10 +#define QRUOV_LL 19 +#else +#error "Unsupported (q, L) for EMI tables" +#endif + +void evaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); + +#endif // EMI_TRANSFORM_H diff --git a/src/sig/qruov/qruov_qruov_avx2/emi_transform_gen.c b/src/sig/qruov/qruov_qruov_avx2/emi_transform_gen.c new file mode 100644 index 0000000000..d024dfc6a1 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/emi_transform_gen.c @@ -0,0 +1,4784 @@ +// auto generated by genmat.py +#include +#include +#include "emi_transform.h" +#include "qruov_simd.h" + +#if QRUOV_q == 7 +static inline __m256i ymm_fold126_epi8(__m256i x) +{ + return _mm256_min_epu8(x, _mm256_sub_epi8(x, _mm256_set1_epi8(126))); +} +static inline __m256i ymm_sub_bias126_epi8(__m256i a, __m256i b) +{ + return _mm256_add_epi8(a, _mm256_sub_epi8(_mm256_set1_epi8(126), b)); +} +#endif +#if QRUOV_q == 31 +static inline __m256i ymm_fold124_epi8(__m256i x) +{ + return _mm256_min_epu8(x, _mm256_sub_epi8(x, _mm256_set1_epi8(124))); +} +static inline __m256i ymm_approx_mul2_q31_epi8(__m256i x) +{ + const __m256i MASK_0F = _mm256_set1_epi8(0x0F); + const __m256i MASK_F0 = _mm256_set1_epi8((char)0xF0); + return _mm256_add_epi8(_mm256_slli_epi16(_mm256_and_si256(x, MASK_0F), 1), + _mm256_srli_epi16(_mm256_and_si256(x, MASK_F0), 4)); +} +#endif +#if QRUOV_q == 31 && QRUOV_L == 3 +void interpolate_q31_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_2); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_approx_mul2_q31_epi8(val); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val); + } + } +} +void reevaluate_q31_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, val); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_3); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_1); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, val); + val = _mm256_add_epi8(val, y_0); + val = ymm_approx_mul2_q31_epi8(val); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val); + } + } +} +#elif QRUOV_q == 127 && QRUOV_L == 3 +void interpolate_avx2_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 16); + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + const __m256i y_0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[0 * plane_in + offset])); + const __m256i y_1 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[1 * plane_in + offset])); + const __m256i y_2 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[2 * plane_in + offset])); + const __m256i y_3 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[3 * plane_in + offset])); + const __m256i y_4 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[4 * plane_in + offset])); + __m256i val_0 = _mm256_setzero_si256(); + __m256i val_1 = _mm256_setzero_si256(); + __m256i val_2 = _mm256_setzero_si256(); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(65), y_0)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_1)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_2)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_3)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(125), y_4)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_0)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_1)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_2)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_3)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(1), y_4)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_0)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_1)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_2)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_3)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_4)); + val_0 = ymm_modq_epi15(ymm_reduceq_epi16(val_0)); + _mm_storeu_si128((__m128i*)&output[0 * plane_out + offset], ymm_cvtusepi16_epi8(val_0)); + val_1 = ymm_modq_epi15(val_1); + _mm_storeu_si128((__m128i*)&output[1 * plane_out + offset], ymm_cvtusepi16_epi8(val_1)); + val_2 = ymm_modq_epi15(val_2); + _mm_storeu_si128((__m128i*)&output[2 * plane_out + offset], ymm_cvtusepi16_epi8(val_2)); + } +} +void reevaluate_avx2_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 16); + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + const __m256i y_0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[0 * plane_in + offset])); + const __m256i y_1 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[1 * plane_in + offset])); + const __m256i y_2 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[2 * plane_in + offset])); + const __m256i y_3 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[3 * plane_in + offset])); + const __m256i y_4 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[4 * plane_in + offset])); + __m256i val_0 = _mm256_setzero_si256(); + __m256i val_1 = _mm256_setzero_si256(); + __m256i val_2 = _mm256_setzero_si256(); + __m256i val_3 = _mm256_setzero_si256(); + __m256i val_4 = _mm256_setzero_si256(); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(65), y_0)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_1)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_2)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_3)); + val_0 = _mm256_add_epi16(val_0, _mm256_mullo_epi16(_mm256_set1_epi16(125), y_4)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_0)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_1)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_2)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_3)); + val_1 = _mm256_add_epi16(val_1, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_4)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_0)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_1)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_2)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_3)); + val_2 = _mm256_add_epi16(val_2, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_4)); + val_3 = _mm256_add_epi16(val_3, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_0)); + val_3 = _mm256_add_epi16(val_3, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_1)); + val_3 = _mm256_add_epi16(val_3, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_2)); + val_3 = _mm256_add_epi16(val_3, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_3)); + val_3 = _mm256_add_epi16(val_3, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_4)); + val_4 = _mm256_add_epi16(val_4, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_0)); + val_4 = _mm256_add_epi16(val_4, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_1)); + val_4 = _mm256_add_epi16(val_4, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_2)); + val_4 = _mm256_add_epi16(val_4, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_3)); + val_4 = _mm256_add_epi16(val_4, _mm256_mullo_epi16(_mm256_set1_epi16(0), y_4)); + val_0 = ymm_modq_epi15(ymm_reduceq_epi16(val_0)); + _mm_storeu_si128((__m128i*)&output[0 * plane_out + offset], ymm_cvtusepi16_epi8(val_0)); + val_1 = ymm_modq_epi15(ymm_reduceq_epi16(val_1)); + _mm_storeu_si128((__m128i*)&output[1 * plane_out + offset], ymm_cvtusepi16_epi8(val_1)); + val_2 = ymm_modq_epi15(ymm_reduceq_epi16(val_2)); + _mm_storeu_si128((__m128i*)&output[2 * plane_out + offset], ymm_cvtusepi16_epi8(val_2)); + val_3 = ymm_modq_epi15(val_3); + _mm_storeu_si128((__m128i*)&output[3 * plane_out + offset], ymm_cvtusepi16_epi8(val_3)); + val_4 = ymm_modq_epi15(val_4); + _mm_storeu_si128((__m128i*)&output[4 * plane_out + offset], ymm_cvtusepi16_epi8(val_4)); + } +} +#elif QRUOV_q == 31 && QRUOV_L == 10 +void interpolate_q31_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + const __m256i y_5 = _mm256_loadu_si256((__m256i*)&input[5 * plane_in + offset]); + const __m256i y_6 = _mm256_loadu_si256((__m256i*)&input[6 * plane_in + offset]); + const __m256i y_7 = _mm256_loadu_si256((__m256i*)&input[7 * plane_in + offset]); + const __m256i y_8 = _mm256_loadu_si256((__m256i*)&input[8 * plane_in + offset]); + const __m256i y_9 = _mm256_loadu_si256((__m256i*)&input[9 * plane_in + offset]); + const __m256i y_10 = _mm256_loadu_si256((__m256i*)&input[10 * plane_in + offset]); + const __m256i y_11 = _mm256_loadu_si256((__m256i*)&input[11 * plane_in + offset]); + const __m256i y_12 = _mm256_loadu_si256((__m256i*)&input[12 * plane_in + offset]); + const __m256i y_13 = _mm256_loadu_si256((__m256i*)&input[13 * plane_in + offset]); + const __m256i y_14 = _mm256_loadu_si256((__m256i*)&input[14 * plane_in + offset]); + const __m256i y_15 = _mm256_loadu_si256((__m256i*)&input[15 * plane_in + offset]); + const __m256i y_16 = _mm256_loadu_si256((__m256i*)&input[16 * plane_in + offset]); + const __m256i y_17 = _mm256_loadu_si256((__m256i*)&input[17 * plane_in + offset]); + const __m256i y_18 = _mm256_loadu_si256((__m256i*)&input[18 * plane_in + offset]); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[5 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[6 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[7 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[8 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[9 * plane_out + offset], val); + } + } +} +void reevaluate_q31_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + const __m256i y_5 = _mm256_loadu_si256((__m256i*)&input[5 * plane_in + offset]); + const __m256i y_6 = _mm256_loadu_si256((__m256i*)&input[6 * plane_in + offset]); + const __m256i y_7 = _mm256_loadu_si256((__m256i*)&input[7 * plane_in + offset]); + const __m256i y_8 = _mm256_loadu_si256((__m256i*)&input[8 * plane_in + offset]); + const __m256i y_9 = _mm256_loadu_si256((__m256i*)&input[9 * plane_in + offset]); + const __m256i y_10 = _mm256_loadu_si256((__m256i*)&input[10 * plane_in + offset]); + const __m256i y_11 = _mm256_loadu_si256((__m256i*)&input[11 * plane_in + offset]); + const __m256i y_12 = _mm256_loadu_si256((__m256i*)&input[12 * plane_in + offset]); + const __m256i y_13 = _mm256_loadu_si256((__m256i*)&input[13 * plane_in + offset]); + const __m256i y_14 = _mm256_loadu_si256((__m256i*)&input[14 * plane_in + offset]); + const __m256i y_15 = _mm256_loadu_si256((__m256i*)&input[15 * plane_in + offset]); + const __m256i y_16 = _mm256_loadu_si256((__m256i*)&input[16 * plane_in + offset]); + const __m256i y_17 = _mm256_loadu_si256((__m256i*)&input[17 * plane_in + offset]); + const __m256i y_18 = _mm256_loadu_si256((__m256i*)&input[18 * plane_in + offset]); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[5 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[6 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[7 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_11); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[8 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[9 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[10 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[11 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[12 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[13 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_17); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[14 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_14); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[15 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[16 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_11); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_17); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_8); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[17 * plane_out + offset], val); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_15); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_7); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_16); + val = _mm256_add_epi8(val, y_18); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_6); + val = _mm256_add_epi8(val, y_10); + val = _mm256_add_epi8(val, y_11); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_12); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_14); + val = _mm256_add_epi8(val, y_15); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_17); + val = ymm_approx_mul2_q31_epi8(val); + val = _mm256_add_epi8(val, y_0); + val = _mm256_add_epi8(val, y_1); + val = _mm256_add_epi8(val, y_2); + val = _mm256_add_epi8(val, y_3); + val = _mm256_add_epi8(val, y_4); + val = _mm256_add_epi8(val, y_5); + val = _mm256_add_epi8(val, y_7); + val = ymm_fold124_epi8(val); + val = _mm256_add_epi8(val, y_9); + val = _mm256_add_epi8(val, y_13); + val = _mm256_add_epi8(val, y_18); + val = ymm_mod31_epi8(val); + _mm256_storeu_si256((__m256i*)&output[18 * plane_out + offset], val); + } + } +} +#elif QRUOV_q == 7 && QRUOV_L == 10 +void evaluate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + const __m256i y_5 = _mm256_loadu_si256((__m256i*)&input[5 * plane_in + offset]); + const __m256i y_6 = _mm256_loadu_si256((__m256i*)&input[6 * plane_in + offset]); + const __m256i y_7 = _mm256_loadu_si256((__m256i*)&input[7 * plane_in + offset]); + const __m256i y_8 = _mm256_loadu_si256((__m256i*)&input[8 * plane_in + offset]); + const __m256i y_9 = _mm256_loadu_si256((__m256i*)&input[9 * plane_in + offset]); + { + __m256i val_0_1 = _mm256_setzero_si256(); + val_0_1 = _mm256_add_epi8(val_0_1, y_0); + val_0_1 = _mm256_add_epi8(val_0_1, y_8); + __m256i val_0_2 = _mm256_setzero_si256(); + val_0_2 = _mm256_add_epi8(val_0_2, y_1); + __m256i val_0_3 = _mm256_setzero_si256(); + val_0_3 = _mm256_add_epi8(val_0_3, y_7); + __m256i val_0_4 = _mm256_setzero_si256(); + __m256i val_0_5 = _mm256_setzero_si256(); + val_0_5 = _mm256_add_epi8(val_0_5, y_5); + val_0_5 = _mm256_add_epi8(val_0_5, y_9); + __m256i val_0_6 = _mm256_setzero_si256(); + val_0_6 = _mm256_add_epi8(val_0_6, y_2); + val_0_6 = _mm256_add_epi8(val_0_6, y_4); + val_0_6 = _mm256_add_epi8(val_0_6, y_6); + __m256i val_0_23 = _mm256_add_epi8(val_0_2, val_0_3); + __m256i val_0_45 = _mm256_add_epi8(val_0_4, val_0_5); + __m256i val_0 = _mm256_add_epi8(val_0_1, _mm256_add_epi8(val_0_23, _mm256_add_epi8(val_0_23, val_0_3))); + __m256i val_0_neg = _mm256_add_epi8(val_0_6, _mm256_add_epi8(val_0_45, _mm256_add_epi8(val_0_45, val_0_4))); + val_0 = ymm_sub_bias126_epi8(val_0, val_0_neg); + val_0 = ymm_mod7_epi8(val_0); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val_0); + } + { + __m256i val_1_1 = _mm256_setzero_si256(); + val_1_1 = _mm256_add_epi8(val_1_1, y_0); + __m256i val_1_2 = _mm256_setzero_si256(); + val_1_2 = _mm256_add_epi8(val_1_2, y_1); + val_1_2 = _mm256_add_epi8(val_1_2, y_4); + val_1_2 = _mm256_add_epi8(val_1_2, y_7); + __m256i val_1_3 = _mm256_setzero_si256(); + val_1_3 = _mm256_add_epi8(val_1_3, y_2); + val_1_3 = _mm256_add_epi8(val_1_3, y_8); + __m256i val_1_4 = _mm256_setzero_si256(); + val_1_4 = _mm256_add_epi8(val_1_4, y_6); + __m256i val_1_5 = _mm256_setzero_si256(); + __m256i val_1_6 = _mm256_setzero_si256(); + val_1_6 = _mm256_add_epi8(val_1_6, y_3); + val_1_6 = _mm256_add_epi8(val_1_6, y_5); + val_1_6 = _mm256_add_epi8(val_1_6, y_9); + __m256i val_1_23 = _mm256_add_epi8(val_1_2, val_1_3); + __m256i val_1_45 = _mm256_add_epi8(val_1_4, val_1_5); + __m256i val_1 = _mm256_add_epi8(val_1_1, _mm256_add_epi8(val_1_23, _mm256_add_epi8(val_1_23, val_1_3))); + __m256i val_1_neg = _mm256_add_epi8(val_1_6, _mm256_add_epi8(val_1_45, _mm256_add_epi8(val_1_45, val_1_4))); + val_1 = ymm_sub_bias126_epi8(val_1, val_1_neg); + val_1 = ymm_mod7_epi8(val_1); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val_1); + } + { + __m256i val_2_1 = _mm256_setzero_si256(); + val_2_1 = _mm256_add_epi8(val_2_1, y_0); + val_2_1 = _mm256_add_epi8(val_2_1, y_6); + __m256i val_2_2 = _mm256_setzero_si256(); + val_2_2 = _mm256_add_epi8(val_2_2, y_7); + val_2_2 = _mm256_add_epi8(val_2_2, y_8); + __m256i val_2_3 = _mm256_setzero_si256(); + __m256i val_2_4 = _mm256_setzero_si256(); + val_2_4 = _mm256_add_epi8(val_2_4, y_1); + val_2_4 = _mm256_add_epi8(val_2_4, y_2); + val_2_4 = _mm256_add_epi8(val_2_4, y_5); + __m256i val_2_5 = _mm256_setzero_si256(); + val_2_5 = _mm256_add_epi8(val_2_5, y_9); + __m256i val_2_6 = _mm256_setzero_si256(); + __m256i val_2_23 = _mm256_add_epi8(val_2_2, val_2_3); + __m256i val_2_45 = _mm256_add_epi8(val_2_4, val_2_5); + __m256i val_2 = _mm256_add_epi8(val_2_1, _mm256_add_epi8(val_2_23, _mm256_add_epi8(val_2_23, val_2_3))); + __m256i val_2_neg = _mm256_add_epi8(val_2_6, _mm256_add_epi8(val_2_45, _mm256_add_epi8(val_2_45, val_2_4))); + val_2 = ymm_sub_bias126_epi8(val_2, val_2_neg); + val_2 = ymm_mod7_epi8(val_2); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val_2); + } + { + __m256i val_3_1 = _mm256_setzero_si256(); + val_3_1 = _mm256_add_epi8(val_3_1, y_0); + val_3_1 = _mm256_add_epi8(val_3_1, y_8); + __m256i val_3_2 = _mm256_setzero_si256(); + val_3_2 = _mm256_add_epi8(val_3_2, y_3); + val_3_2 = _mm256_add_epi8(val_3_2, y_4); + __m256i val_3_3 = _mm256_setzero_si256(); + val_3_3 = _mm256_add_epi8(val_3_3, y_5); + __m256i val_3_4 = _mm256_setzero_si256(); + val_3_4 = _mm256_add_epi8(val_3_4, y_2); + __m256i val_3_5 = _mm256_setzero_si256(); + val_3_5 = _mm256_add_epi8(val_3_5, y_1); + val_3_5 = _mm256_add_epi8(val_3_5, y_6); + val_3_5 = _mm256_add_epi8(val_3_5, y_7); + __m256i val_3_6 = _mm256_setzero_si256(); + __m256i val_3_23 = _mm256_add_epi8(val_3_2, val_3_3); + __m256i val_3_45 = _mm256_add_epi8(val_3_4, val_3_5); + __m256i val_3 = _mm256_add_epi8(val_3_1, _mm256_add_epi8(val_3_23, _mm256_add_epi8(val_3_23, val_3_3))); + __m256i val_3_neg = _mm256_add_epi8(val_3_6, _mm256_add_epi8(val_3_45, _mm256_add_epi8(val_3_45, val_3_4))); + val_3 = ymm_sub_bias126_epi8(val_3, val_3_neg); + val_3 = ymm_mod7_epi8(val_3); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val_3); + } + { + __m256i val_4_1 = _mm256_setzero_si256(); + val_4_1 = _mm256_add_epi8(val_4_1, y_0); + val_4_1 = _mm256_add_epi8(val_4_1, y_3); + __m256i val_4_2 = _mm256_setzero_si256(); + val_4_2 = _mm256_add_epi8(val_4_2, y_7); + __m256i val_4_3 = _mm256_setzero_si256(); + val_4_3 = _mm256_add_epi8(val_4_3, y_5); + val_4_3 = _mm256_add_epi8(val_4_3, y_9); + __m256i val_4_4 = _mm256_setzero_si256(); + val_4_4 = _mm256_add_epi8(val_4_4, y_4); + __m256i val_4_5 = _mm256_setzero_si256(); + val_4_5 = _mm256_add_epi8(val_4_5, y_6); + val_4_5 = _mm256_add_epi8(val_4_5, y_8); + __m256i val_4_6 = _mm256_setzero_si256(); + val_4_6 = _mm256_add_epi8(val_4_6, y_2); + __m256i val_4_23 = _mm256_add_epi8(val_4_2, val_4_3); + __m256i val_4_45 = _mm256_add_epi8(val_4_4, val_4_5); + __m256i val_4 = _mm256_add_epi8(val_4_1, _mm256_add_epi8(val_4_23, _mm256_add_epi8(val_4_23, val_4_3))); + __m256i val_4_neg = _mm256_add_epi8(val_4_6, _mm256_add_epi8(val_4_45, _mm256_add_epi8(val_4_45, val_4_4))); + val_4 = ymm_sub_bias126_epi8(val_4, val_4_neg); + val_4 = ymm_mod7_epi8(val_4); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val_4); + } + { + __m256i val_5_1 = _mm256_setzero_si256(); + val_5_1 = _mm256_add_epi8(val_5_1, y_0); + val_5_1 = _mm256_add_epi8(val_5_1, y_2); + val_5_1 = _mm256_add_epi8(val_5_1, y_4); + val_5_1 = _mm256_add_epi8(val_5_1, y_5); + __m256i val_5_2 = _mm256_setzero_si256(); + val_5_2 = _mm256_add_epi8(val_5_2, y_1); + val_5_2 = _mm256_add_epi8(val_5_2, y_3); + val_5_2 = _mm256_add_epi8(val_5_2, y_6); + val_5_2 = _mm256_add_epi8(val_5_2, y_9); + __m256i val_5_3 = _mm256_setzero_si256(); + __m256i val_5_4 = _mm256_setzero_si256(); + val_5_4 = _mm256_add_epi8(val_5_4, y_8); + __m256i val_5_5 = _mm256_setzero_si256(); + __m256i val_5_6 = _mm256_setzero_si256(); + __m256i val_5_23 = _mm256_add_epi8(val_5_2, val_5_3); + __m256i val_5_45 = _mm256_add_epi8(val_5_4, val_5_5); + __m256i val_5 = _mm256_add_epi8(val_5_1, _mm256_add_epi8(val_5_23, _mm256_add_epi8(val_5_23, val_5_3))); + __m256i val_5_neg = _mm256_add_epi8(val_5_6, _mm256_add_epi8(val_5_45, _mm256_add_epi8(val_5_45, val_5_4))); + val_5 = ymm_sub_bias126_epi8(val_5, val_5_neg); + val_5 = ymm_mod7_epi8(val_5); + _mm256_storeu_si256((__m256i*)&output[5 * plane_out + offset], val_5); + } + { + __m256i val_6_1 = _mm256_setzero_si256(); + val_6_1 = _mm256_add_epi8(val_6_1, y_0); + val_6_1 = _mm256_add_epi8(val_6_1, y_6); + __m256i val_6_2 = _mm256_setzero_si256(); + __m256i val_6_3 = _mm256_setzero_si256(); + __m256i val_6_4 = _mm256_setzero_si256(); + val_6_4 = _mm256_add_epi8(val_6_4, y_1); + val_6_4 = _mm256_add_epi8(val_6_4, y_2); + val_6_4 = _mm256_add_epi8(val_6_4, y_5); + __m256i val_6_5 = _mm256_setzero_si256(); + val_6_5 = _mm256_add_epi8(val_6_5, y_9); + __m256i val_6_6 = _mm256_setzero_si256(); + val_6_6 = _mm256_add_epi8(val_6_6, y_3); + val_6_6 = _mm256_add_epi8(val_6_6, y_4); + val_6_6 = _mm256_add_epi8(val_6_6, y_7); + __m256i val_6_23 = _mm256_add_epi8(val_6_2, val_6_3); + __m256i val_6_45 = _mm256_add_epi8(val_6_4, val_6_5); + __m256i val_6 = _mm256_add_epi8(val_6_1, _mm256_add_epi8(val_6_23, _mm256_add_epi8(val_6_23, val_6_3))); + __m256i val_6_neg = _mm256_add_epi8(val_6_6, _mm256_add_epi8(val_6_45, _mm256_add_epi8(val_6_45, val_6_4))); + val_6 = ymm_sub_bias126_epi8(val_6, val_6_neg); + val_6 = ymm_mod7_epi8(val_6); + _mm256_storeu_si256((__m256i*)&output[6 * plane_out + offset], val_6); + } + { + __m256i val_7_1 = _mm256_setzero_si256(); + val_7_1 = _mm256_add_epi8(val_7_1, y_0); + val_7_1 = _mm256_add_epi8(val_7_1, y_7); + __m256i val_7_2 = _mm256_setzero_si256(); + val_7_2 = _mm256_add_epi8(val_7_2, y_2); + val_7_2 = _mm256_add_epi8(val_7_2, y_6); + val_7_2 = _mm256_add_epi8(val_7_2, y_9); + __m256i val_7_3 = _mm256_setzero_si256(); + val_7_3 = _mm256_add_epi8(val_7_3, y_4); + val_7_3 = _mm256_add_epi8(val_7_3, y_5); + val_7_3 = _mm256_add_epi8(val_7_3, y_8); + __m256i val_7_4 = _mm256_setzero_si256(); + __m256i val_7_5 = _mm256_setzero_si256(); + __m256i val_7_6 = _mm256_setzero_si256(); + val_7_6 = _mm256_add_epi8(val_7_6, y_1); + __m256i val_7_23 = _mm256_add_epi8(val_7_2, val_7_3); + __m256i val_7_45 = _mm256_add_epi8(val_7_4, val_7_5); + __m256i val_7 = _mm256_add_epi8(val_7_1, _mm256_add_epi8(val_7_23, _mm256_add_epi8(val_7_23, val_7_3))); + __m256i val_7_neg = _mm256_add_epi8(val_7_6, _mm256_add_epi8(val_7_45, _mm256_add_epi8(val_7_45, val_7_4))); + val_7 = ymm_sub_bias126_epi8(val_7, val_7_neg); + val_7 = ymm_mod7_epi8(val_7); + _mm256_storeu_si256((__m256i*)&output[7 * plane_out + offset], val_7); + } + { + __m256i val_8_1 = _mm256_setzero_si256(); + val_8_1 = _mm256_add_epi8(val_8_1, y_0); + val_8_1 = _mm256_add_epi8(val_8_1, y_1); + val_8_1 = _mm256_add_epi8(val_8_1, y_3); + val_8_1 = _mm256_add_epi8(val_8_1, y_8); + __m256i val_8_2 = _mm256_setzero_si256(); + val_8_2 = _mm256_add_epi8(val_8_2, y_4); + val_8_2 = _mm256_add_epi8(val_8_2, y_7); + __m256i val_8_3 = _mm256_setzero_si256(); + val_8_3 = _mm256_add_epi8(val_8_3, y_5); + __m256i val_8_4 = _mm256_setzero_si256(); + val_8_4 = _mm256_add_epi8(val_8_4, y_2); + __m256i val_8_5 = _mm256_setzero_si256(); + val_8_5 = _mm256_add_epi8(val_8_5, y_6); + val_8_5 = _mm256_add_epi8(val_8_5, y_9); + __m256i val_8_6 = _mm256_setzero_si256(); + __m256i val_8_23 = _mm256_add_epi8(val_8_2, val_8_3); + __m256i val_8_45 = _mm256_add_epi8(val_8_4, val_8_5); + __m256i val_8 = _mm256_add_epi8(val_8_1, _mm256_add_epi8(val_8_23, _mm256_add_epi8(val_8_23, val_8_3))); + __m256i val_8_neg = _mm256_add_epi8(val_8_6, _mm256_add_epi8(val_8_45, _mm256_add_epi8(val_8_45, val_8_4))); + val_8 = ymm_sub_bias126_epi8(val_8, val_8_neg); + val_8 = ymm_mod7_epi8(val_8); + _mm256_storeu_si256((__m256i*)&output[8 * plane_out + offset], val_8); + } + { + __m256i val_9_1 = _mm256_setzero_si256(); + val_9_1 = _mm256_add_epi8(val_9_1, y_0); + val_9_1 = _mm256_add_epi8(val_9_1, y_7); + __m256i val_9_2 = _mm256_setzero_si256(); + val_9_2 = _mm256_add_epi8(val_9_2, y_1); + __m256i val_9_3 = _mm256_setzero_si256(); + val_9_3 = _mm256_add_epi8(val_9_3, y_3); + __m256i val_9_4 = _mm256_setzero_si256(); + __m256i val_9_5 = _mm256_setzero_si256(); + val_9_5 = _mm256_add_epi8(val_9_5, y_4); + __m256i val_9_6 = _mm256_setzero_si256(); + val_9_6 = _mm256_add_epi8(val_9_6, y_2); + val_9_6 = _mm256_add_epi8(val_9_6, y_6); + val_9_6 = _mm256_add_epi8(val_9_6, y_8); + val_9_6 = _mm256_add_epi8(val_9_6, y_9); + __m256i val_9_23 = _mm256_add_epi8(val_9_2, val_9_3); + __m256i val_9_45 = _mm256_add_epi8(val_9_4, val_9_5); + __m256i val_9 = _mm256_add_epi8(val_9_1, _mm256_add_epi8(val_9_23, _mm256_add_epi8(val_9_23, val_9_3))); + __m256i val_9_neg = _mm256_add_epi8(val_9_6, _mm256_add_epi8(val_9_45, _mm256_add_epi8(val_9_45, val_9_4))); + val_9 = ymm_sub_bias126_epi8(val_9, val_9_neg); + val_9 = ymm_mod7_epi8(val_9); + _mm256_storeu_si256((__m256i*)&output[9 * plane_out + offset], val_9); + } + { + __m256i val_10_1 = _mm256_setzero_si256(); + val_10_1 = _mm256_add_epi8(val_10_1, y_0); + val_10_1 = _mm256_add_epi8(val_10_1, y_3); + val_10_1 = _mm256_add_epi8(val_10_1, y_6); + val_10_1 = _mm256_add_epi8(val_10_1, y_8); + __m256i val_10_2 = _mm256_setzero_si256(); + val_10_2 = _mm256_add_epi8(val_10_2, y_4); + __m256i val_10_3 = _mm256_setzero_si256(); + val_10_3 = _mm256_add_epi8(val_10_3, y_9); + __m256i val_10_4 = _mm256_setzero_si256(); + val_10_4 = _mm256_add_epi8(val_10_4, y_5); + val_10_4 = _mm256_add_epi8(val_10_4, y_7); + __m256i val_10_5 = _mm256_setzero_si256(); + __m256i val_10_6 = _mm256_setzero_si256(); + val_10_6 = _mm256_add_epi8(val_10_6, y_1); + val_10_6 = _mm256_add_epi8(val_10_6, y_2); + __m256i val_10_23 = _mm256_add_epi8(val_10_2, val_10_3); + __m256i val_10_45 = _mm256_add_epi8(val_10_4, val_10_5); + __m256i val_10 = _mm256_add_epi8(val_10_1, _mm256_add_epi8(val_10_23, _mm256_add_epi8(val_10_23, val_10_3))); + __m256i val_10_neg = _mm256_add_epi8(val_10_6, _mm256_add_epi8(val_10_45, _mm256_add_epi8(val_10_45, val_10_4))); + val_10 = ymm_sub_bias126_epi8(val_10, val_10_neg); + val_10 = ymm_mod7_epi8(val_10); + _mm256_storeu_si256((__m256i*)&output[10 * plane_out + offset], val_10); + } + { + __m256i val_11_1 = _mm256_setzero_si256(); + val_11_1 = _mm256_add_epi8(val_11_1, y_0); + val_11_1 = _mm256_add_epi8(val_11_1, y_6); + __m256i val_11_2 = _mm256_setzero_si256(); + val_11_2 = _mm256_add_epi8(val_11_2, y_2); + val_11_2 = _mm256_add_epi8(val_11_2, y_4); + __m256i val_11_3 = _mm256_setzero_si256(); + val_11_3 = _mm256_add_epi8(val_11_3, y_7); + val_11_3 = _mm256_add_epi8(val_11_3, y_9); + __m256i val_11_4 = _mm256_setzero_si256(); + __m256i val_11_5 = _mm256_setzero_si256(); + val_11_5 = _mm256_add_epi8(val_11_5, y_1); + __m256i val_11_6 = _mm256_setzero_si256(); + val_11_6 = _mm256_add_epi8(val_11_6, y_3); + __m256i val_11_23 = _mm256_add_epi8(val_11_2, val_11_3); + __m256i val_11_45 = _mm256_add_epi8(val_11_4, val_11_5); + __m256i val_11 = _mm256_add_epi8(val_11_1, _mm256_add_epi8(val_11_23, _mm256_add_epi8(val_11_23, val_11_3))); + __m256i val_11_neg = _mm256_add_epi8(val_11_6, _mm256_add_epi8(val_11_45, _mm256_add_epi8(val_11_45, val_11_4))); + val_11 = ymm_sub_bias126_epi8(val_11, val_11_neg); + val_11 = ymm_mod7_epi8(val_11); + _mm256_storeu_si256((__m256i*)&output[11 * plane_out + offset], val_11); + } + { + __m256i val_12_1 = _mm256_setzero_si256(); + val_12_1 = _mm256_add_epi8(val_12_1, y_0); + val_12_1 = _mm256_add_epi8(val_12_1, y_5); + __m256i val_12_2 = _mm256_setzero_si256(); + __m256i val_12_3 = _mm256_setzero_si256(); + val_12_3 = _mm256_add_epi8(val_12_3, y_3); + __m256i val_12_4 = _mm256_setzero_si256(); + val_12_4 = _mm256_add_epi8(val_12_4, y_2); + val_12_4 = _mm256_add_epi8(val_12_4, y_7); + val_12_4 = _mm256_add_epi8(val_12_4, y_8); + __m256i val_12_5 = _mm256_setzero_si256(); + __m256i val_12_6 = _mm256_setzero_si256(); + val_12_6 = _mm256_add_epi8(val_12_6, y_1); + val_12_6 = _mm256_add_epi8(val_12_6, y_4); + val_12_6 = _mm256_add_epi8(val_12_6, y_9); + __m256i val_12_23 = _mm256_add_epi8(val_12_2, val_12_3); + __m256i val_12_45 = _mm256_add_epi8(val_12_4, val_12_5); + __m256i val_12 = _mm256_add_epi8(val_12_1, _mm256_add_epi8(val_12_23, _mm256_add_epi8(val_12_23, val_12_3))); + __m256i val_12_neg = _mm256_add_epi8(val_12_6, _mm256_add_epi8(val_12_45, _mm256_add_epi8(val_12_45, val_12_4))); + val_12 = ymm_sub_bias126_epi8(val_12, val_12_neg); + val_12 = ymm_mod7_epi8(val_12); + _mm256_storeu_si256((__m256i*)&output[12 * plane_out + offset], val_12); + } + { + __m256i val_13_1 = _mm256_setzero_si256(); + val_13_1 = _mm256_add_epi8(val_13_1, y_0); + __m256i val_13_2 = _mm256_setzero_si256(); + val_13_2 = _mm256_add_epi8(val_13_2, y_2); + val_13_2 = _mm256_add_epi8(val_13_2, y_6); + __m256i val_13_3 = _mm256_setzero_si256(); + val_13_3 = _mm256_add_epi8(val_13_3, y_5); + val_13_3 = _mm256_add_epi8(val_13_3, y_9); + __m256i val_13_4 = _mm256_setzero_si256(); + val_13_4 = _mm256_add_epi8(val_13_4, y_1); + val_13_4 = _mm256_add_epi8(val_13_4, y_3); + __m256i val_13_5 = _mm256_setzero_si256(); + __m256i val_13_6 = _mm256_setzero_si256(); + val_13_6 = _mm256_add_epi8(val_13_6, y_4); + val_13_6 = _mm256_add_epi8(val_13_6, y_7); + __m256i val_13_23 = _mm256_add_epi8(val_13_2, val_13_3); + __m256i val_13_45 = _mm256_add_epi8(val_13_4, val_13_5); + __m256i val_13 = _mm256_add_epi8(val_13_1, _mm256_add_epi8(val_13_23, _mm256_add_epi8(val_13_23, val_13_3))); + __m256i val_13_neg = _mm256_add_epi8(val_13_6, _mm256_add_epi8(val_13_45, _mm256_add_epi8(val_13_45, val_13_4))); + val_13 = ymm_sub_bias126_epi8(val_13, val_13_neg); + val_13 = ymm_mod7_epi8(val_13); + _mm256_storeu_si256((__m256i*)&output[13 * plane_out + offset], val_13); + } + { + __m256i val_14_1 = _mm256_setzero_si256(); + val_14_1 = _mm256_add_epi8(val_14_1, y_0); + val_14_1 = _mm256_add_epi8(val_14_1, y_9); + __m256i val_14_2 = _mm256_setzero_si256(); + val_14_2 = _mm256_add_epi8(val_14_2, y_2); + val_14_2 = _mm256_add_epi8(val_14_2, y_4); + __m256i val_14_3 = _mm256_setzero_si256(); + val_14_3 = _mm256_add_epi8(val_14_3, y_6); + __m256i val_14_4 = _mm256_setzero_si256(); + val_14_4 = _mm256_add_epi8(val_14_4, y_3); + __m256i val_14_5 = _mm256_setzero_si256(); + val_14_5 = _mm256_add_epi8(val_14_5, y_7); + __m256i val_14_6 = _mm256_setzero_si256(); + val_14_6 = _mm256_add_epi8(val_14_6, y_1); + val_14_6 = _mm256_add_epi8(val_14_6, y_5); + __m256i val_14_23 = _mm256_add_epi8(val_14_2, val_14_3); + __m256i val_14_45 = _mm256_add_epi8(val_14_4, val_14_5); + __m256i val_14 = _mm256_add_epi8(val_14_1, _mm256_add_epi8(val_14_23, _mm256_add_epi8(val_14_23, val_14_3))); + __m256i val_14_neg = _mm256_add_epi8(val_14_6, _mm256_add_epi8(val_14_45, _mm256_add_epi8(val_14_45, val_14_4))); + val_14 = ymm_sub_bias126_epi8(val_14, val_14_neg); + val_14 = ymm_mod7_epi8(val_14); + _mm256_storeu_si256((__m256i*)&output[14 * plane_out + offset], val_14); + } + { + __m256i val_15_1 = _mm256_setzero_si256(); + val_15_1 = _mm256_add_epi8(val_15_1, y_0); + val_15_1 = _mm256_add_epi8(val_15_1, y_3); + val_15_1 = _mm256_add_epi8(val_15_1, y_7); + __m256i val_15_2 = _mm256_setzero_si256(); + val_15_2 = _mm256_add_epi8(val_15_2, y_2); + __m256i val_15_3 = _mm256_setzero_si256(); + __m256i val_15_4 = _mm256_setzero_si256(); + val_15_4 = _mm256_add_epi8(val_15_4, y_1); + val_15_4 = _mm256_add_epi8(val_15_4, y_6); + __m256i val_15_5 = _mm256_setzero_si256(); + val_15_5 = _mm256_add_epi8(val_15_5, y_5); + val_15_5 = _mm256_add_epi8(val_15_5, y_8); + val_15_5 = _mm256_add_epi8(val_15_5, y_9); + __m256i val_15_6 = _mm256_setzero_si256(); + __m256i val_15_23 = _mm256_add_epi8(val_15_2, val_15_3); + __m256i val_15_45 = _mm256_add_epi8(val_15_4, val_15_5); + __m256i val_15 = _mm256_add_epi8(val_15_1, _mm256_add_epi8(val_15_23, _mm256_add_epi8(val_15_23, val_15_3))); + __m256i val_15_neg = _mm256_add_epi8(val_15_6, _mm256_add_epi8(val_15_45, _mm256_add_epi8(val_15_45, val_15_4))); + val_15 = ymm_sub_bias126_epi8(val_15, val_15_neg); + val_15 = ymm_mod7_epi8(val_15); + _mm256_storeu_si256((__m256i*)&output[15 * plane_out + offset], val_15); + } + { + __m256i val_16_1 = _mm256_setzero_si256(); + val_16_1 = _mm256_add_epi8(val_16_1, y_0); + __m256i val_16_2 = _mm256_setzero_si256(); + val_16_2 = _mm256_add_epi8(val_16_2, y_4); + __m256i val_16_3 = _mm256_setzero_si256(); + val_16_3 = _mm256_add_epi8(val_16_3, y_5); + __m256i val_16_4 = _mm256_setzero_si256(); + val_16_4 = _mm256_add_epi8(val_16_4, y_1); + __m256i val_16_5 = _mm256_setzero_si256(); + val_16_5 = _mm256_add_epi8(val_16_5, y_2); + val_16_5 = _mm256_add_epi8(val_16_5, y_6); + val_16_5 = _mm256_add_epi8(val_16_5, y_7); + val_16_5 = _mm256_add_epi8(val_16_5, y_8); + val_16_5 = _mm256_add_epi8(val_16_5, y_9); + __m256i val_16_6 = _mm256_setzero_si256(); + __m256i val_16_23 = _mm256_add_epi8(val_16_2, val_16_3); + __m256i val_16_45 = _mm256_add_epi8(val_16_4, val_16_5); + __m256i val_16 = _mm256_add_epi8(val_16_1, _mm256_add_epi8(val_16_23, _mm256_add_epi8(val_16_23, val_16_3))); + __m256i val_16_neg = _mm256_add_epi8(val_16_6, _mm256_add_epi8(val_16_45, _mm256_add_epi8(val_16_45, val_16_4))); + val_16 = ymm_sub_bias126_epi8(val_16, val_16_neg); + val_16 = ymm_mod7_epi8(val_16); + _mm256_storeu_si256((__m256i*)&output[16 * plane_out + offset], val_16); + } + { + __m256i val_17_1 = _mm256_setzero_si256(); + val_17_1 = _mm256_add_epi8(val_17_1, y_0); + val_17_1 = _mm256_add_epi8(val_17_1, y_1); + val_17_1 = _mm256_add_epi8(val_17_1, y_8); + __m256i val_17_2 = _mm256_setzero_si256(); + __m256i val_17_3 = _mm256_setzero_si256(); + val_17_3 = _mm256_add_epi8(val_17_3, y_2); + val_17_3 = _mm256_add_epi8(val_17_3, y_5); + __m256i val_17_4 = _mm256_setzero_si256(); + __m256i val_17_5 = _mm256_setzero_si256(); + val_17_5 = _mm256_add_epi8(val_17_5, y_9); + __m256i val_17_6 = _mm256_setzero_si256(); + val_17_6 = _mm256_add_epi8(val_17_6, y_4); + val_17_6 = _mm256_add_epi8(val_17_6, y_7); + __m256i val_17_23 = _mm256_add_epi8(val_17_2, val_17_3); + __m256i val_17_45 = _mm256_add_epi8(val_17_4, val_17_5); + __m256i val_17 = _mm256_add_epi8(val_17_1, _mm256_add_epi8(val_17_23, _mm256_add_epi8(val_17_23, val_17_3))); + __m256i val_17_neg = _mm256_add_epi8(val_17_6, _mm256_add_epi8(val_17_45, _mm256_add_epi8(val_17_45, val_17_4))); + val_17 = ymm_sub_bias126_epi8(val_17, val_17_neg); + val_17 = ymm_mod7_epi8(val_17); + _mm256_storeu_si256((__m256i*)&output[17 * plane_out + offset], val_17); + } + { + __m256i val_18_1 = _mm256_setzero_si256(); + val_18_1 = _mm256_add_epi8(val_18_1, y_0); + val_18_1 = _mm256_add_epi8(val_18_1, y_7); + __m256i val_18_2 = _mm256_setzero_si256(); + val_18_2 = _mm256_add_epi8(val_18_2, y_4); + __m256i val_18_3 = _mm256_setzero_si256(); + val_18_3 = _mm256_add_epi8(val_18_3, y_9); + __m256i val_18_4 = _mm256_setzero_si256(); + __m256i val_18_5 = _mm256_setzero_si256(); + val_18_5 = _mm256_add_epi8(val_18_5, y_1); + val_18_5 = _mm256_add_epi8(val_18_5, y_2); + __m256i val_18_6 = _mm256_setzero_si256(); + val_18_6 = _mm256_add_epi8(val_18_6, y_3); + val_18_6 = _mm256_add_epi8(val_18_6, y_5); + val_18_6 = _mm256_add_epi8(val_18_6, y_6); + val_18_6 = _mm256_add_epi8(val_18_6, y_8); + __m256i val_18_23 = _mm256_add_epi8(val_18_2, val_18_3); + __m256i val_18_45 = _mm256_add_epi8(val_18_4, val_18_5); + __m256i val_18 = _mm256_add_epi8(val_18_1, _mm256_add_epi8(val_18_23, _mm256_add_epi8(val_18_23, val_18_3))); + __m256i val_18_neg = _mm256_add_epi8(val_18_6, _mm256_add_epi8(val_18_45, _mm256_add_epi8(val_18_45, val_18_4))); + val_18 = ymm_sub_bias126_epi8(val_18, val_18_neg); + val_18 = ymm_mod7_epi8(val_18); + _mm256_storeu_si256((__m256i*)&output[18 * plane_out + offset], val_18); + } + { + __m256i val_19_1 = _mm256_setzero_si256(); + val_19_1 = _mm256_add_epi8(val_19_1, y_0); + val_19_1 = _mm256_add_epi8(val_19_1, y_8); + __m256i val_19_2 = _mm256_setzero_si256(); + val_19_2 = _mm256_add_epi8(val_19_2, y_3); + val_19_2 = _mm256_add_epi8(val_19_2, y_6); + __m256i val_19_3 = _mm256_setzero_si256(); + __m256i val_19_4 = _mm256_setzero_si256(); + __m256i val_19_5 = _mm256_setzero_si256(); + val_19_5 = _mm256_add_epi8(val_19_5, y_7); + __m256i val_19_6 = _mm256_setzero_si256(); + val_19_6 = _mm256_add_epi8(val_19_6, y_1); + val_19_6 = _mm256_add_epi8(val_19_6, y_2); + val_19_6 = _mm256_add_epi8(val_19_6, y_5); + __m256i val_19_23 = _mm256_add_epi8(val_19_2, val_19_3); + __m256i val_19_45 = _mm256_add_epi8(val_19_4, val_19_5); + __m256i val_19 = _mm256_add_epi8(val_19_1, _mm256_add_epi8(val_19_23, _mm256_add_epi8(val_19_23, val_19_3))); + __m256i val_19_neg = _mm256_add_epi8(val_19_6, _mm256_add_epi8(val_19_45, _mm256_add_epi8(val_19_45, val_19_4))); + val_19 = ymm_sub_bias126_epi8(val_19, val_19_neg); + val_19 = ymm_mod7_epi8(val_19); + _mm256_storeu_si256((__m256i*)&output[19 * plane_out + offset], val_19); + } + { + __m256i val_20_1 = _mm256_setzero_si256(); + val_20_1 = _mm256_add_epi8(val_20_1, y_0); + val_20_1 = _mm256_add_epi8(val_20_1, y_2); + val_20_1 = _mm256_add_epi8(val_20_1, y_7); + val_20_1 = _mm256_add_epi8(val_20_1, y_8); + __m256i val_20_2 = _mm256_setzero_si256(); + val_20_2 = _mm256_add_epi8(val_20_2, y_3); + __m256i val_20_3 = _mm256_setzero_si256(); + val_20_3 = _mm256_add_epi8(val_20_3, y_5); + __m256i val_20_4 = _mm256_setzero_si256(); + __m256i val_20_5 = _mm256_setzero_si256(); + __m256i val_20_6 = _mm256_setzero_si256(); + val_20_6 = _mm256_add_epi8(val_20_6, y_1); + val_20_6 = _mm256_add_epi8(val_20_6, y_6); + val_20_6 = _mm256_add_epi8(val_20_6, y_9); + __m256i val_20_23 = _mm256_add_epi8(val_20_2, val_20_3); + __m256i val_20_45 = _mm256_add_epi8(val_20_4, val_20_5); + __m256i val_20 = _mm256_add_epi8(val_20_1, _mm256_add_epi8(val_20_23, _mm256_add_epi8(val_20_23, val_20_3))); + __m256i val_20_neg = _mm256_add_epi8(val_20_6, _mm256_add_epi8(val_20_45, _mm256_add_epi8(val_20_45, val_20_4))); + val_20 = ymm_sub_bias126_epi8(val_20, val_20_neg); + val_20 = ymm_mod7_epi8(val_20); + _mm256_storeu_si256((__m256i*)&output[20 * plane_out + offset], val_20); + } + { + __m256i val_21_1 = _mm256_setzero_si256(); + val_21_1 = _mm256_add_epi8(val_21_1, y_0); + __m256i val_21_2 = _mm256_setzero_si256(); + val_21_2 = _mm256_add_epi8(val_21_2, y_7); + __m256i val_21_3 = _mm256_setzero_si256(); + val_21_3 = _mm256_add_epi8(val_21_3, y_1); + __m256i val_21_4 = _mm256_setzero_si256(); + val_21_4 = _mm256_add_epi8(val_21_4, y_9); + __m256i val_21_5 = _mm256_setzero_si256(); + val_21_5 = _mm256_add_epi8(val_21_5, y_5); + val_21_5 = _mm256_add_epi8(val_21_5, y_6); + val_21_5 = _mm256_add_epi8(val_21_5, y_8); + __m256i val_21_6 = _mm256_setzero_si256(); + val_21_6 = _mm256_add_epi8(val_21_6, y_2); + val_21_6 = _mm256_add_epi8(val_21_6, y_3); + __m256i val_21_23 = _mm256_add_epi8(val_21_2, val_21_3); + __m256i val_21_45 = _mm256_add_epi8(val_21_4, val_21_5); + __m256i val_21 = _mm256_add_epi8(val_21_1, _mm256_add_epi8(val_21_23, _mm256_add_epi8(val_21_23, val_21_3))); + __m256i val_21_neg = _mm256_add_epi8(val_21_6, _mm256_add_epi8(val_21_45, _mm256_add_epi8(val_21_45, val_21_4))); + val_21 = ymm_sub_bias126_epi8(val_21, val_21_neg); + val_21 = ymm_mod7_epi8(val_21); + _mm256_storeu_si256((__m256i*)&output[21 * plane_out + offset], val_21); + } + { + __m256i val_22_1 = _mm256_setzero_si256(); + val_22_1 = _mm256_add_epi8(val_22_1, y_0); + val_22_1 = _mm256_add_epi8(val_22_1, y_7); + __m256i val_22_2 = _mm256_setzero_si256(); + __m256i val_22_3 = _mm256_setzero_si256(); + __m256i val_22_4 = _mm256_setzero_si256(); + val_22_4 = _mm256_add_epi8(val_22_4, y_2); + val_22_4 = _mm256_add_epi8(val_22_4, y_3); + val_22_4 = _mm256_add_epi8(val_22_4, y_5); + val_22_4 = _mm256_add_epi8(val_22_4, y_8); + __m256i val_22_5 = _mm256_setzero_si256(); + val_22_5 = _mm256_add_epi8(val_22_5, y_4); + __m256i val_22_6 = _mm256_setzero_si256(); + __m256i val_22_23 = _mm256_add_epi8(val_22_2, val_22_3); + __m256i val_22_45 = _mm256_add_epi8(val_22_4, val_22_5); + __m256i val_22 = _mm256_add_epi8(val_22_1, _mm256_add_epi8(val_22_23, _mm256_add_epi8(val_22_23, val_22_3))); + __m256i val_22_neg = _mm256_add_epi8(val_22_6, _mm256_add_epi8(val_22_45, _mm256_add_epi8(val_22_45, val_22_4))); + val_22 = ymm_sub_bias126_epi8(val_22, val_22_neg); + val_22 = ymm_mod7_epi8(val_22); + _mm256_storeu_si256((__m256i*)&output[22 * plane_out + offset], val_22); + } + } +} +void interpolate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + const __m256i y_5 = _mm256_loadu_si256((__m256i*)&input[5 * plane_in + offset]); + const __m256i y_6 = _mm256_loadu_si256((__m256i*)&input[6 * plane_in + offset]); + const __m256i y_7 = _mm256_loadu_si256((__m256i*)&input[7 * plane_in + offset]); + const __m256i y_8 = _mm256_loadu_si256((__m256i*)&input[8 * plane_in + offset]); + const __m256i y_9 = _mm256_loadu_si256((__m256i*)&input[9 * plane_in + offset]); + const __m256i y_10 = _mm256_loadu_si256((__m256i*)&input[10 * plane_in + offset]); + const __m256i y_11 = _mm256_loadu_si256((__m256i*)&input[11 * plane_in + offset]); + const __m256i y_12 = _mm256_loadu_si256((__m256i*)&input[12 * plane_in + offset]); + const __m256i y_13 = _mm256_loadu_si256((__m256i*)&input[13 * plane_in + offset]); + const __m256i y_14 = _mm256_loadu_si256((__m256i*)&input[14 * plane_in + offset]); + const __m256i y_15 = _mm256_loadu_si256((__m256i*)&input[15 * plane_in + offset]); + const __m256i y_16 = _mm256_loadu_si256((__m256i*)&input[16 * plane_in + offset]); + const __m256i y_17 = _mm256_loadu_si256((__m256i*)&input[17 * plane_in + offset]); + const __m256i y_18 = _mm256_loadu_si256((__m256i*)&input[18 * plane_in + offset]); + const __m256i y_19 = _mm256_loadu_si256((__m256i*)&input[19 * plane_in + offset]); + const __m256i y_20 = _mm256_loadu_si256((__m256i*)&input[20 * plane_in + offset]); + const __m256i y_21 = _mm256_loadu_si256((__m256i*)&input[21 * plane_in + offset]); + const __m256i y_22 = _mm256_loadu_si256((__m256i*)&input[22 * plane_in + offset]); + { + __m256i val_0_1 = _mm256_setzero_si256(); + val_0_1 = _mm256_add_epi8(val_0_1, y_11); + __m256i val_0_2 = _mm256_setzero_si256(); + val_0_2 = _mm256_add_epi8(val_0_2, y_3); + val_0_2 = _mm256_add_epi8(val_0_2, y_17); + val_0_2 = _mm256_add_epi8(val_0_2, y_22); + __m256i val_0_3 = _mm256_setzero_si256(); + val_0_3 = _mm256_add_epi8(val_0_3, y_5); + val_0_3 = _mm256_add_epi8(val_0_3, y_8); + __m256i val_0_4 = _mm256_setzero_si256(); + val_0_4 = _mm256_add_epi8(val_0_4, y_0); + val_0_4 = _mm256_add_epi8(val_0_4, y_15); + val_0_4 = _mm256_add_epi8(val_0_4, y_21); + __m256i val_0_5 = _mm256_setzero_si256(); + val_0_5 = _mm256_add_epi8(val_0_5, y_6); + val_0_5 = _mm256_add_epi8(val_0_5, y_7); + val_0_5 = _mm256_add_epi8(val_0_5, y_10); + val_0_5 = _mm256_add_epi8(val_0_5, y_18); + val_0_5 = _mm256_add_epi8(val_0_5, y_19); + __m256i val_0_6 = _mm256_setzero_si256(); + val_0_6 = _mm256_add_epi8(val_0_6, y_1); + val_0_6 = _mm256_add_epi8(val_0_6, y_2); + val_0_6 = _mm256_add_epi8(val_0_6, y_4); + val_0_6 = _mm256_add_epi8(val_0_6, y_9); + val_0_6 = _mm256_add_epi8(val_0_6, y_13); + val_0_6 = _mm256_add_epi8(val_0_6, y_14); + val_0_6 = _mm256_add_epi8(val_0_6, y_16); + __m256i val_0_23 = _mm256_add_epi8(val_0_2, val_0_3); + __m256i val_0_45 = _mm256_add_epi8(val_0_4, val_0_5); + __m256i val_0 = _mm256_add_epi8(val_0_1, _mm256_add_epi8(val_0_23, _mm256_add_epi8(val_0_23, val_0_3))); + __m256i val_0_neg = _mm256_add_epi8(val_0_6, _mm256_add_epi8(val_0_45, _mm256_add_epi8(val_0_45, val_0_4))); + val_0_neg = ymm_fold126_epi8(val_0_neg); + val_0 = ymm_sub_bias126_epi8(val_0, val_0_neg); + val_0 = ymm_mod7_epi8(val_0); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val_0); + } + { + __m256i val_1_1 = _mm256_setzero_si256(); + val_1_1 = _mm256_add_epi8(val_1_1, y_12); + __m256i val_1_2 = _mm256_setzero_si256(); + __m256i val_1_3 = _mm256_setzero_si256(); + val_1_3 = _mm256_add_epi8(val_1_3, y_0); + val_1_3 = _mm256_add_epi8(val_1_3, y_1); + val_1_3 = _mm256_add_epi8(val_1_3, y_5); + val_1_3 = _mm256_add_epi8(val_1_3, y_11); + val_1_3 = _mm256_add_epi8(val_1_3, y_14); + val_1_3 = _mm256_add_epi8(val_1_3, y_20); + __m256i val_1_4 = _mm256_setzero_si256(); + val_1_4 = _mm256_add_epi8(val_1_4, y_8); + val_1_4 = _mm256_add_epi8(val_1_4, y_16); + val_1_4 = _mm256_add_epi8(val_1_4, y_17); + val_1_4 = _mm256_add_epi8(val_1_4, y_18); + __m256i val_1_5 = _mm256_setzero_si256(); + val_1_5 = _mm256_add_epi8(val_1_5, y_2); + val_1_5 = _mm256_add_epi8(val_1_5, y_6); + val_1_5 = _mm256_add_epi8(val_1_5, y_7); + val_1_5 = _mm256_add_epi8(val_1_5, y_10); + val_1_5 = _mm256_add_epi8(val_1_5, y_13); + val_1_5 = _mm256_add_epi8(val_1_5, y_22); + __m256i val_1_6 = _mm256_setzero_si256(); + val_1_6 = _mm256_add_epi8(val_1_6, y_3); + val_1_6 = _mm256_add_epi8(val_1_6, y_9); + __m256i val_1_23 = _mm256_add_epi8(val_1_2, val_1_3); + __m256i val_1_45 = _mm256_add_epi8(val_1_4, val_1_5); + __m256i val_1 = _mm256_add_epi8(val_1_1, _mm256_add_epi8(val_1_23, _mm256_add_epi8(val_1_23, val_1_3))); + __m256i val_1_neg = _mm256_add_epi8(val_1_6, _mm256_add_epi8(val_1_45, _mm256_add_epi8(val_1_45, val_1_4))); + val_1_neg = ymm_fold126_epi8(val_1_neg); + val_1 = ymm_sub_bias126_epi8(val_1, val_1_neg); + val_1 = ymm_mod7_epi8(val_1); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val_1); + } + { + __m256i val_2_1 = _mm256_setzero_si256(); + val_2_1 = _mm256_add_epi8(val_2_1, y_8); + val_2_1 = _mm256_add_epi8(val_2_1, y_21); + val_2_1 = _mm256_add_epi8(val_2_1, y_22); + __m256i val_2_2 = _mm256_setzero_si256(); + val_2_2 = _mm256_add_epi8(val_2_2, y_9); + val_2_2 = _mm256_add_epi8(val_2_2, y_16); + val_2_2 = _mm256_add_epi8(val_2_2, y_17); + __m256i val_2_3 = _mm256_setzero_si256(); + val_2_3 = _mm256_add_epi8(val_2_3, y_3); + val_2_3 = _mm256_add_epi8(val_2_3, y_4); + val_2_3 = _mm256_add_epi8(val_2_3, y_6); + val_2_3 = _mm256_add_epi8(val_2_3, y_7); + val_2_3 = _mm256_add_epi8(val_2_3, y_10); + val_2_3 = _mm256_add_epi8(val_2_3, y_12); + val_2_3 = _mm256_add_epi8(val_2_3, y_13); + val_2_3 = _mm256_add_epi8(val_2_3, y_19); + __m256i val_2_4 = _mm256_setzero_si256(); + val_2_4 = _mm256_add_epi8(val_2_4, y_1); + val_2_4 = _mm256_add_epi8(val_2_4, y_20); + __m256i val_2_5 = _mm256_setzero_si256(); + val_2_5 = _mm256_add_epi8(val_2_5, y_14); + val_2_5 = _mm256_add_epi8(val_2_5, y_18); + __m256i val_2_6 = _mm256_setzero_si256(); + val_2_6 = _mm256_add_epi8(val_2_6, y_2); + val_2_6 = _mm256_add_epi8(val_2_6, y_5); + __m256i val_2_23 = _mm256_add_epi8(val_2_2, val_2_3); + __m256i val_2_45 = _mm256_add_epi8(val_2_4, val_2_5); + __m256i val_2 = _mm256_add_epi8(val_2_1, _mm256_add_epi8(val_2_23, _mm256_add_epi8(val_2_23, val_2_3))); + val_2 = ymm_fold126_epi8(val_2); + __m256i val_2_neg = _mm256_add_epi8(val_2_6, _mm256_add_epi8(val_2_45, _mm256_add_epi8(val_2_45, val_2_4))); + val_2 = ymm_sub_bias126_epi8(val_2, val_2_neg); + val_2 = ymm_mod7_epi8(val_2); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val_2); + } + { + __m256i val_3_1 = _mm256_setzero_si256(); + val_3_1 = _mm256_add_epi8(val_3_1, y_1); + val_3_1 = _mm256_add_epi8(val_3_1, y_13); + __m256i val_3_2 = _mm256_setzero_si256(); + val_3_2 = _mm256_add_epi8(val_3_2, y_5); + val_3_2 = _mm256_add_epi8(val_3_2, y_7); + val_3_2 = _mm256_add_epi8(val_3_2, y_9); + val_3_2 = _mm256_add_epi8(val_3_2, y_15); + __m256i val_3_3 = _mm256_setzero_si256(); + val_3_3 = _mm256_add_epi8(val_3_3, y_3); + val_3_3 = _mm256_add_epi8(val_3_3, y_21); + __m256i val_3_4 = _mm256_setzero_si256(); + val_3_4 = _mm256_add_epi8(val_3_4, y_8); + val_3_4 = _mm256_add_epi8(val_3_4, y_10); + val_3_4 = _mm256_add_epi8(val_3_4, y_11); + val_3_4 = _mm256_add_epi8(val_3_4, y_16); + val_3_4 = _mm256_add_epi8(val_3_4, y_18); + __m256i val_3_5 = _mm256_setzero_si256(); + val_3_5 = _mm256_add_epi8(val_3_5, y_2); + val_3_5 = _mm256_add_epi8(val_3_5, y_4); + val_3_5 = _mm256_add_epi8(val_3_5, y_19); + val_3_5 = _mm256_add_epi8(val_3_5, y_20); + val_3_5 = _mm256_add_epi8(val_3_5, y_22); + __m256i val_3_6 = _mm256_setzero_si256(); + val_3_6 = _mm256_add_epi8(val_3_6, y_0); + val_3_6 = _mm256_add_epi8(val_3_6, y_6); + val_3_6 = _mm256_add_epi8(val_3_6, y_12); + val_3_6 = _mm256_add_epi8(val_3_6, y_14); + val_3_6 = _mm256_add_epi8(val_3_6, y_17); + __m256i val_3_23 = _mm256_add_epi8(val_3_2, val_3_3); + __m256i val_3_45 = _mm256_add_epi8(val_3_4, val_3_5); + __m256i val_3 = _mm256_add_epi8(val_3_1, _mm256_add_epi8(val_3_23, _mm256_add_epi8(val_3_23, val_3_3))); + __m256i val_3_neg = _mm256_add_epi8(val_3_6, _mm256_add_epi8(val_3_45, _mm256_add_epi8(val_3_45, val_3_4))); + val_3_neg = ymm_fold126_epi8(val_3_neg); + val_3 = ymm_sub_bias126_epi8(val_3, val_3_neg); + val_3 = ymm_mod7_epi8(val_3); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val_3); + } + { + __m256i val_4_1 = _mm256_setzero_si256(); + val_4_1 = _mm256_add_epi8(val_4_1, y_7); + val_4_1 = _mm256_add_epi8(val_4_1, y_17); + __m256i val_4_2 = _mm256_setzero_si256(); + val_4_2 = _mm256_add_epi8(val_4_2, y_1); + val_4_2 = _mm256_add_epi8(val_4_2, y_3); + val_4_2 = _mm256_add_epi8(val_4_2, y_9); + val_4_2 = _mm256_add_epi8(val_4_2, y_22); + __m256i val_4_3 = _mm256_setzero_si256(); + val_4_3 = _mm256_add_epi8(val_4_3, y_2); + val_4_3 = _mm256_add_epi8(val_4_3, y_8); + __m256i val_4_4 = _mm256_setzero_si256(); + val_4_4 = _mm256_add_epi8(val_4_4, y_4); + val_4_4 = _mm256_add_epi8(val_4_4, y_12); + val_4_4 = _mm256_add_epi8(val_4_4, y_14); + val_4_4 = _mm256_add_epi8(val_4_4, y_15); + val_4_4 = _mm256_add_epi8(val_4_4, y_16); + val_4_4 = _mm256_add_epi8(val_4_4, y_19); + __m256i val_4_5 = _mm256_setzero_si256(); + val_4_5 = _mm256_add_epi8(val_4_5, y_5); + val_4_5 = _mm256_add_epi8(val_4_5, y_10); + val_4_5 = _mm256_add_epi8(val_4_5, y_13); + val_4_5 = _mm256_add_epi8(val_4_5, y_20); + __m256i val_4_6 = _mm256_setzero_si256(); + val_4_6 = _mm256_add_epi8(val_4_6, y_6); + val_4_6 = _mm256_add_epi8(val_4_6, y_11); + val_4_6 = _mm256_add_epi8(val_4_6, y_18); + val_4_6 = _mm256_add_epi8(val_4_6, y_21); + __m256i val_4_23 = _mm256_add_epi8(val_4_2, val_4_3); + __m256i val_4_45 = _mm256_add_epi8(val_4_4, val_4_5); + __m256i val_4 = _mm256_add_epi8(val_4_1, _mm256_add_epi8(val_4_23, _mm256_add_epi8(val_4_23, val_4_3))); + __m256i val_4_neg = _mm256_add_epi8(val_4_6, _mm256_add_epi8(val_4_45, _mm256_add_epi8(val_4_45, val_4_4))); + val_4_neg = ymm_fold126_epi8(val_4_neg); + val_4 = ymm_sub_bias126_epi8(val_4, val_4_neg); + val_4 = ymm_mod7_epi8(val_4); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val_4); + } + { + __m256i val_5_1 = _mm256_setzero_si256(); + val_5_1 = _mm256_add_epi8(val_5_1, y_5); + val_5_1 = _mm256_add_epi8(val_5_1, y_16); + __m256i val_5_2 = _mm256_setzero_si256(); + val_5_2 = _mm256_add_epi8(val_5_2, y_0); + val_5_2 = _mm256_add_epi8(val_5_2, y_6); + val_5_2 = _mm256_add_epi8(val_5_2, y_7); + __m256i val_5_3 = _mm256_setzero_si256(); + val_5_3 = _mm256_add_epi8(val_5_3, y_4); + val_5_3 = _mm256_add_epi8(val_5_3, y_9); + val_5_3 = _mm256_add_epi8(val_5_3, y_10); + val_5_3 = _mm256_add_epi8(val_5_3, y_15); + __m256i val_5_4 = _mm256_setzero_si256(); + val_5_4 = _mm256_add_epi8(val_5_4, y_1); + val_5_4 = _mm256_add_epi8(val_5_4, y_2); + val_5_4 = _mm256_add_epi8(val_5_4, y_8); + val_5_4 = _mm256_add_epi8(val_5_4, y_12); + val_5_4 = _mm256_add_epi8(val_5_4, y_13); + val_5_4 = _mm256_add_epi8(val_5_4, y_17); + val_5_4 = _mm256_add_epi8(val_5_4, y_19); + val_5_4 = _mm256_add_epi8(val_5_4, y_22); + __m256i val_5_5 = _mm256_setzero_si256(); + val_5_5 = _mm256_add_epi8(val_5_5, y_18); + __m256i val_5_6 = _mm256_setzero_si256(); + val_5_6 = _mm256_add_epi8(val_5_6, y_3); + __m256i val_5_23 = _mm256_add_epi8(val_5_2, val_5_3); + __m256i val_5_45 = _mm256_add_epi8(val_5_4, val_5_5); + __m256i val_5 = _mm256_add_epi8(val_5_1, _mm256_add_epi8(val_5_23, _mm256_add_epi8(val_5_23, val_5_3))); + __m256i val_5_neg = _mm256_add_epi8(val_5_6, _mm256_add_epi8(val_5_45, _mm256_add_epi8(val_5_45, val_5_4))); + val_5_neg = ymm_fold126_epi8(val_5_neg); + val_5 = ymm_sub_bias126_epi8(val_5, val_5_neg); + val_5 = ymm_mod7_epi8(val_5); + _mm256_storeu_si256((__m256i*)&output[5 * plane_out + offset], val_5); + } + { + __m256i val_6_1 = _mm256_setzero_si256(); + val_6_1 = _mm256_add_epi8(val_6_1, y_2); + val_6_1 = _mm256_add_epi8(val_6_1, y_4); + val_6_1 = _mm256_add_epi8(val_6_1, y_12); + val_6_1 = _mm256_add_epi8(val_6_1, y_16); + val_6_1 = _mm256_add_epi8(val_6_1, y_18); + __m256i val_6_2 = _mm256_setzero_si256(); + val_6_2 = _mm256_add_epi8(val_6_2, y_3); + val_6_2 = _mm256_add_epi8(val_6_2, y_11); + __m256i val_6_3 = _mm256_setzero_si256(); + val_6_3 = _mm256_add_epi8(val_6_3, y_1); + val_6_3 = _mm256_add_epi8(val_6_3, y_8); + __m256i val_6_4 = _mm256_setzero_si256(); + val_6_4 = _mm256_add_epi8(val_6_4, y_6); + val_6_4 = _mm256_add_epi8(val_6_4, y_17); + val_6_4 = _mm256_add_epi8(val_6_4, y_19); + val_6_4 = _mm256_add_epi8(val_6_4, y_20); + val_6_4 = _mm256_add_epi8(val_6_4, y_22); + __m256i val_6_5 = _mm256_setzero_si256(); + val_6_5 = _mm256_add_epi8(val_6_5, y_5); + __m256i val_6_6 = _mm256_setzero_si256(); + val_6_6 = _mm256_add_epi8(val_6_6, y_0); + val_6_6 = _mm256_add_epi8(val_6_6, y_10); + val_6_6 = _mm256_add_epi8(val_6_6, y_13); + val_6_6 = _mm256_add_epi8(val_6_6, y_14); + val_6_6 = _mm256_add_epi8(val_6_6, y_21); + __m256i val_6_23 = _mm256_add_epi8(val_6_2, val_6_3); + __m256i val_6_45 = _mm256_add_epi8(val_6_4, val_6_5); + __m256i val_6 = _mm256_add_epi8(val_6_1, _mm256_add_epi8(val_6_23, _mm256_add_epi8(val_6_23, val_6_3))); + __m256i val_6_neg = _mm256_add_epi8(val_6_6, _mm256_add_epi8(val_6_45, _mm256_add_epi8(val_6_45, val_6_4))); + val_6_neg = ymm_fold126_epi8(val_6_neg); + val_6 = ymm_sub_bias126_epi8(val_6, val_6_neg); + val_6 = ymm_mod7_epi8(val_6); + _mm256_storeu_si256((__m256i*)&output[6 * plane_out + offset], val_6); + } + { + __m256i val_7_1 = _mm256_setzero_si256(); + val_7_1 = _mm256_add_epi8(val_7_1, y_8); + val_7_1 = _mm256_add_epi8(val_7_1, y_15); + val_7_1 = _mm256_add_epi8(val_7_1, y_17); + val_7_1 = _mm256_add_epi8(val_7_1, y_22); + __m256i val_7_2 = _mm256_setzero_si256(); + val_7_2 = _mm256_add_epi8(val_7_2, y_20); + __m256i val_7_3 = _mm256_setzero_si256(); + val_7_3 = _mm256_add_epi8(val_7_3, y_1); + val_7_3 = _mm256_add_epi8(val_7_3, y_5); + val_7_3 = _mm256_add_epi8(val_7_3, y_6); + val_7_3 = _mm256_add_epi8(val_7_3, y_7); + val_7_3 = _mm256_add_epi8(val_7_3, y_16); + __m256i val_7_4 = _mm256_setzero_si256(); + val_7_4 = _mm256_add_epi8(val_7_4, y_14); + __m256i val_7_5 = _mm256_setzero_si256(); + val_7_5 = _mm256_add_epi8(val_7_5, y_3); + val_7_5 = _mm256_add_epi8(val_7_5, y_4); + val_7_5 = _mm256_add_epi8(val_7_5, y_12); + val_7_5 = _mm256_add_epi8(val_7_5, y_21); + __m256i val_7_6 = _mm256_setzero_si256(); + val_7_6 = _mm256_add_epi8(val_7_6, y_9); + val_7_6 = _mm256_add_epi8(val_7_6, y_13); + val_7_6 = _mm256_add_epi8(val_7_6, y_19); + __m256i val_7_23 = _mm256_add_epi8(val_7_2, val_7_3); + __m256i val_7_45 = _mm256_add_epi8(val_7_4, val_7_5); + __m256i val_7 = _mm256_add_epi8(val_7_1, _mm256_add_epi8(val_7_23, _mm256_add_epi8(val_7_23, val_7_3))); + __m256i val_7_neg = _mm256_add_epi8(val_7_6, _mm256_add_epi8(val_7_45, _mm256_add_epi8(val_7_45, val_7_4))); + val_7 = ymm_sub_bias126_epi8(val_7, val_7_neg); + val_7 = ymm_mod7_epi8(val_7); + _mm256_storeu_si256((__m256i*)&output[7 * plane_out + offset], val_7); + } + { + __m256i val_8_1 = _mm256_setzero_si256(); + val_8_1 = _mm256_add_epi8(val_8_1, y_3); + val_8_1 = _mm256_add_epi8(val_8_1, y_6); + val_8_1 = _mm256_add_epi8(val_8_1, y_9); + val_8_1 = _mm256_add_epi8(val_8_1, y_13); + val_8_1 = _mm256_add_epi8(val_8_1, y_14); + val_8_1 = _mm256_add_epi8(val_8_1, y_15); + __m256i val_8_2 = _mm256_setzero_si256(); + val_8_2 = _mm256_add_epi8(val_8_2, y_7); + val_8_2 = _mm256_add_epi8(val_8_2, y_22); + __m256i val_8_3 = _mm256_setzero_si256(); + val_8_3 = _mm256_add_epi8(val_8_3, y_17); + __m256i val_8_4 = _mm256_setzero_si256(); + val_8_4 = _mm256_add_epi8(val_8_4, y_0); + val_8_4 = _mm256_add_epi8(val_8_4, y_1); + val_8_4 = _mm256_add_epi8(val_8_4, y_2); + val_8_4 = _mm256_add_epi8(val_8_4, y_12); + val_8_4 = _mm256_add_epi8(val_8_4, y_18); + val_8_4 = _mm256_add_epi8(val_8_4, y_19); + __m256i val_8_5 = _mm256_setzero_si256(); + val_8_5 = _mm256_add_epi8(val_8_5, y_5); + val_8_5 = _mm256_add_epi8(val_8_5, y_8); + val_8_5 = _mm256_add_epi8(val_8_5, y_16); + __m256i val_8_6 = _mm256_setzero_si256(); + val_8_6 = _mm256_add_epi8(val_8_6, y_10); + val_8_6 = _mm256_add_epi8(val_8_6, y_11); + val_8_6 = _mm256_add_epi8(val_8_6, y_21); + __m256i val_8_23 = _mm256_add_epi8(val_8_2, val_8_3); + __m256i val_8_45 = _mm256_add_epi8(val_8_4, val_8_5); + __m256i val_8 = _mm256_add_epi8(val_8_1, _mm256_add_epi8(val_8_23, _mm256_add_epi8(val_8_23, val_8_3))); + __m256i val_8_neg = _mm256_add_epi8(val_8_6, _mm256_add_epi8(val_8_45, _mm256_add_epi8(val_8_45, val_8_4))); + val_8_neg = ymm_fold126_epi8(val_8_neg); + val_8 = ymm_sub_bias126_epi8(val_8, val_8_neg); + val_8 = ymm_mod7_epi8(val_8); + _mm256_storeu_si256((__m256i*)&output[8 * plane_out + offset], val_8); + } + { + __m256i val_9_1 = _mm256_setzero_si256(); + val_9_1 = _mm256_add_epi8(val_9_1, y_3); + val_9_1 = _mm256_add_epi8(val_9_1, y_10); + val_9_1 = _mm256_add_epi8(val_9_1, y_17); + __m256i val_9_2 = _mm256_setzero_si256(); + val_9_2 = _mm256_add_epi8(val_9_2, y_0); + val_9_2 = _mm256_add_epi8(val_9_2, y_1); + val_9_2 = _mm256_add_epi8(val_9_2, y_20); + __m256i val_9_3 = _mm256_setzero_si256(); + val_9_3 = _mm256_add_epi8(val_9_3, y_5); + val_9_3 = _mm256_add_epi8(val_9_3, y_9); + val_9_3 = _mm256_add_epi8(val_9_3, y_19); + __m256i val_9_4 = _mm256_setzero_si256(); + val_9_4 = _mm256_add_epi8(val_9_4, y_7); + val_9_4 = _mm256_add_epi8(val_9_4, y_21); + val_9_4 = _mm256_add_epi8(val_9_4, y_22); + __m256i val_9_5 = _mm256_setzero_si256(); + val_9_5 = _mm256_add_epi8(val_9_5, y_4); + val_9_5 = _mm256_add_epi8(val_9_5, y_6); + val_9_5 = _mm256_add_epi8(val_9_5, y_16); + __m256i val_9_6 = _mm256_setzero_si256(); + val_9_6 = _mm256_add_epi8(val_9_6, y_8); + val_9_6 = _mm256_add_epi8(val_9_6, y_12); + val_9_6 = _mm256_add_epi8(val_9_6, y_18); + __m256i val_9_23 = _mm256_add_epi8(val_9_2, val_9_3); + __m256i val_9_45 = _mm256_add_epi8(val_9_4, val_9_5); + __m256i val_9 = _mm256_add_epi8(val_9_1, _mm256_add_epi8(val_9_23, _mm256_add_epi8(val_9_23, val_9_3))); + __m256i val_9_neg = _mm256_add_epi8(val_9_6, _mm256_add_epi8(val_9_45, _mm256_add_epi8(val_9_45, val_9_4))); + val_9 = ymm_sub_bias126_epi8(val_9, val_9_neg); + val_9 = ymm_mod7_epi8(val_9); + _mm256_storeu_si256((__m256i*)&output[9 * plane_out + offset], val_9); + } + } +} +void reevaluate_q7_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 32); + for (int i = 0; i < size; i += 32) { + const int offset = (i + 31) < size ? i : (size - 32); + const __m256i y_0 = _mm256_loadu_si256((__m256i*)&input[0 * plane_in + offset]); + const __m256i y_1 = _mm256_loadu_si256((__m256i*)&input[1 * plane_in + offset]); + const __m256i y_2 = _mm256_loadu_si256((__m256i*)&input[2 * plane_in + offset]); + const __m256i y_3 = _mm256_loadu_si256((__m256i*)&input[3 * plane_in + offset]); + const __m256i y_4 = _mm256_loadu_si256((__m256i*)&input[4 * plane_in + offset]); + const __m256i y_5 = _mm256_loadu_si256((__m256i*)&input[5 * plane_in + offset]); + const __m256i y_6 = _mm256_loadu_si256((__m256i*)&input[6 * plane_in + offset]); + const __m256i y_7 = _mm256_loadu_si256((__m256i*)&input[7 * plane_in + offset]); + const __m256i y_8 = _mm256_loadu_si256((__m256i*)&input[8 * plane_in + offset]); + const __m256i y_9 = _mm256_loadu_si256((__m256i*)&input[9 * plane_in + offset]); + const __m256i y_10 = _mm256_loadu_si256((__m256i*)&input[10 * plane_in + offset]); + const __m256i y_11 = _mm256_loadu_si256((__m256i*)&input[11 * plane_in + offset]); + const __m256i y_12 = _mm256_loadu_si256((__m256i*)&input[12 * plane_in + offset]); + const __m256i y_13 = _mm256_loadu_si256((__m256i*)&input[13 * plane_in + offset]); + const __m256i y_14 = _mm256_loadu_si256((__m256i*)&input[14 * plane_in + offset]); + const __m256i y_15 = _mm256_loadu_si256((__m256i*)&input[15 * plane_in + offset]); + const __m256i y_16 = _mm256_loadu_si256((__m256i*)&input[16 * plane_in + offset]); + const __m256i y_17 = _mm256_loadu_si256((__m256i*)&input[17 * plane_in + offset]); + const __m256i y_18 = _mm256_loadu_si256((__m256i*)&input[18 * plane_in + offset]); + const __m256i y_19 = _mm256_loadu_si256((__m256i*)&input[19 * plane_in + offset]); + const __m256i y_20 = _mm256_loadu_si256((__m256i*)&input[20 * plane_in + offset]); + const __m256i y_21 = _mm256_loadu_si256((__m256i*)&input[21 * plane_in + offset]); + const __m256i y_22 = _mm256_loadu_si256((__m256i*)&input[22 * plane_in + offset]); + { + __m256i val_0_1 = _mm256_setzero_si256(); + val_0_1 = _mm256_add_epi8(val_0_1, y_22); + __m256i val_0_2 = _mm256_setzero_si256(); + val_0_2 = _mm256_add_epi8(val_0_2, y_2); + val_0_2 = _mm256_add_epi8(val_0_2, y_3); + val_0_2 = _mm256_add_epi8(val_0_2, y_16); + val_0_2 = _mm256_add_epi8(val_0_2, y_19); + val_0_2 = _mm256_add_epi8(val_0_2, y_20); + __m256i val_0_3 = _mm256_setzero_si256(); + val_0_3 = _mm256_add_epi8(val_0_3, y_7); + val_0_3 = _mm256_add_epi8(val_0_3, y_14); + __m256i val_0_4 = _mm256_setzero_si256(); + val_0_4 = _mm256_add_epi8(val_0_4, y_1); + val_0_4 = _mm256_add_epi8(val_0_4, y_4); + val_0_4 = _mm256_add_epi8(val_0_4, y_18); + val_0_4 = _mm256_add_epi8(val_0_4, y_21); + __m256i val_0_5 = _mm256_setzero_si256(); + val_0_5 = _mm256_add_epi8(val_0_5, y_6); + val_0_5 = _mm256_add_epi8(val_0_5, y_11); + val_0_5 = _mm256_add_epi8(val_0_5, y_15); + __m256i val_0_6 = _mm256_setzero_si256(); + val_0_6 = _mm256_add_epi8(val_0_6, y_5); + val_0_6 = _mm256_add_epi8(val_0_6, y_8); + val_0_6 = _mm256_add_epi8(val_0_6, y_10); + val_0_6 = _mm256_add_epi8(val_0_6, y_13); + val_0_6 = _mm256_add_epi8(val_0_6, y_17); + __m256i val_0_23 = _mm256_add_epi8(val_0_2, val_0_3); + __m256i val_0_45 = _mm256_add_epi8(val_0_4, val_0_5); + __m256i val_0 = _mm256_add_epi8(val_0_1, _mm256_add_epi8(val_0_23, _mm256_add_epi8(val_0_23, val_0_3))); + __m256i val_0_neg = _mm256_add_epi8(val_0_6, _mm256_add_epi8(val_0_45, _mm256_add_epi8(val_0_45, val_0_4))); + val_0_neg = ymm_fold126_epi8(val_0_neg); + val_0 = ymm_sub_bias126_epi8(val_0, val_0_neg); + val_0 = ymm_mod7_epi8(val_0); + _mm256_storeu_si256((__m256i*)&output[0 * plane_out + offset], val_0); + } + { + __m256i val_1_1 = _mm256_setzero_si256(); + val_1_1 = _mm256_add_epi8(val_1_1, y_0); + val_1_1 = _mm256_add_epi8(val_1_1, y_12); + val_1_1 = _mm256_add_epi8(val_1_1, y_14); + val_1_1 = _mm256_add_epi8(val_1_1, y_16); + val_1_1 = _mm256_add_epi8(val_1_1, y_19); + val_1_1 = _mm256_add_epi8(val_1_1, y_21); + __m256i val_1_2 = _mm256_setzero_si256(); + val_1_2 = _mm256_add_epi8(val_1_2, y_1); + val_1_2 = _mm256_add_epi8(val_1_2, y_5); + val_1_2 = _mm256_add_epi8(val_1_2, y_7); + val_1_2 = _mm256_add_epi8(val_1_2, y_22); + __m256i val_1_3 = _mm256_setzero_si256(); + val_1_3 = _mm256_add_epi8(val_1_3, y_3); + val_1_3 = _mm256_add_epi8(val_1_3, y_4); + __m256i val_1_4 = _mm256_setzero_si256(); + __m256i val_1_5 = _mm256_setzero_si256(); + val_1_5 = _mm256_add_epi8(val_1_5, y_2); + val_1_5 = _mm256_add_epi8(val_1_5, y_10); + val_1_5 = _mm256_add_epi8(val_1_5, y_15); + __m256i val_1_6 = _mm256_setzero_si256(); + val_1_6 = _mm256_add_epi8(val_1_6, y_6); + val_1_6 = _mm256_add_epi8(val_1_6, y_11); + val_1_6 = _mm256_add_epi8(val_1_6, y_13); + val_1_6 = _mm256_add_epi8(val_1_6, y_17); + val_1_6 = _mm256_add_epi8(val_1_6, y_18); + val_1_6 = _mm256_add_epi8(val_1_6, y_20); + __m256i val_1_23 = _mm256_add_epi8(val_1_2, val_1_3); + __m256i val_1_45 = _mm256_add_epi8(val_1_4, val_1_5); + __m256i val_1 = _mm256_add_epi8(val_1_1, _mm256_add_epi8(val_1_23, _mm256_add_epi8(val_1_23, val_1_3))); + __m256i val_1_neg = _mm256_add_epi8(val_1_6, _mm256_add_epi8(val_1_45, _mm256_add_epi8(val_1_45, val_1_4))); + val_1 = ymm_sub_bias126_epi8(val_1, val_1_neg); + val_1 = ymm_mod7_epi8(val_1); + _mm256_storeu_si256((__m256i*)&output[1 * plane_out + offset], val_1); + } + { + __m256i val_2_1 = _mm256_setzero_si256(); + __m256i val_2_2 = _mm256_setzero_si256(); + val_2_2 = _mm256_add_epi8(val_2_2, y_5); + val_2_2 = _mm256_add_epi8(val_2_2, y_9); + val_2_2 = _mm256_add_epi8(val_2_2, y_10); + val_2_2 = _mm256_add_epi8(val_2_2, y_18); + val_2_2 = _mm256_add_epi8(val_2_2, y_19); + val_2_2 = _mm256_add_epi8(val_2_2, y_22); + __m256i val_2_3 = _mm256_setzero_si256(); + val_2_3 = _mm256_add_epi8(val_2_3, y_4); + val_2_3 = _mm256_add_epi8(val_2_3, y_17); + __m256i val_2_4 = _mm256_setzero_si256(); + val_2_4 = _mm256_add_epi8(val_2_4, y_3); + val_2_4 = _mm256_add_epi8(val_2_4, y_12); + val_2_4 = _mm256_add_epi8(val_2_4, y_13); + val_2_4 = _mm256_add_epi8(val_2_4, y_20); + __m256i val_2_5 = _mm256_setzero_si256(); + val_2_5 = _mm256_add_epi8(val_2_5, y_2); + val_2_5 = _mm256_add_epi8(val_2_5, y_6); + val_2_5 = _mm256_add_epi8(val_2_5, y_7); + val_2_5 = _mm256_add_epi8(val_2_5, y_14); + __m256i val_2_6 = _mm256_setzero_si256(); + val_2_6 = _mm256_add_epi8(val_2_6, y_0); + val_2_6 = _mm256_add_epi8(val_2_6, y_11); + val_2_6 = _mm256_add_epi8(val_2_6, y_15); + val_2_6 = _mm256_add_epi8(val_2_6, y_16); + __m256i val_2_23 = _mm256_add_epi8(val_2_2, val_2_3); + __m256i val_2_45 = _mm256_add_epi8(val_2_4, val_2_5); + __m256i val_2 = _mm256_add_epi8(val_2_1, _mm256_add_epi8(val_2_23, _mm256_add_epi8(val_2_23, val_2_3))); + __m256i val_2_neg = _mm256_add_epi8(val_2_6, _mm256_add_epi8(val_2_45, _mm256_add_epi8(val_2_45, val_2_4))); + val_2_neg = ymm_fold126_epi8(val_2_neg); + val_2 = ymm_sub_bias126_epi8(val_2, val_2_neg); + val_2 = ymm_mod7_epi8(val_2); + _mm256_storeu_si256((__m256i*)&output[2 * plane_out + offset], val_2); + } + { + __m256i val_3_1 = _mm256_setzero_si256(); + val_3_1 = _mm256_add_epi8(val_3_1, y_0); + val_3_1 = _mm256_add_epi8(val_3_1, y_2); + val_3_1 = _mm256_add_epi8(val_3_1, y_7); + val_3_1 = _mm256_add_epi8(val_3_1, y_8); + val_3_1 = _mm256_add_epi8(val_3_1, y_9); + val_3_1 = _mm256_add_epi8(val_3_1, y_16); + __m256i val_3_2 = _mm256_setzero_si256(); + val_3_2 = _mm256_add_epi8(val_3_2, y_13); + __m256i val_3_3 = _mm256_setzero_si256(); + val_3_3 = _mm256_add_epi8(val_3_3, y_3); + val_3_3 = _mm256_add_epi8(val_3_3, y_6); + val_3_3 = _mm256_add_epi8(val_3_3, y_11); + val_3_3 = _mm256_add_epi8(val_3_3, y_15); + val_3_3 = _mm256_add_epi8(val_3_3, y_19); + val_3_3 = _mm256_add_epi8(val_3_3, y_21); + __m256i val_3_4 = _mm256_setzero_si256(); + val_3_4 = _mm256_add_epi8(val_3_4, y_20); + __m256i val_3_5 = _mm256_setzero_si256(); + val_3_5 = _mm256_add_epi8(val_3_5, y_1); + val_3_5 = _mm256_add_epi8(val_3_5, y_4); + val_3_5 = _mm256_add_epi8(val_3_5, y_18); + __m256i val_3_6 = _mm256_setzero_si256(); + val_3_6 = _mm256_add_epi8(val_3_6, y_5); + val_3_6 = _mm256_add_epi8(val_3_6, y_12); + __m256i val_3_23 = _mm256_add_epi8(val_3_2, val_3_3); + __m256i val_3_45 = _mm256_add_epi8(val_3_4, val_3_5); + __m256i val_3 = _mm256_add_epi8(val_3_1, _mm256_add_epi8(val_3_23, _mm256_add_epi8(val_3_23, val_3_3))); + val_3 = ymm_fold126_epi8(val_3); + __m256i val_3_neg = _mm256_add_epi8(val_3_6, _mm256_add_epi8(val_3_45, _mm256_add_epi8(val_3_45, val_3_4))); + val_3 = ymm_sub_bias126_epi8(val_3, val_3_neg); + val_3 = ymm_mod7_epi8(val_3); + _mm256_storeu_si256((__m256i*)&output[3 * plane_out + offset], val_3); + } + { + __m256i val_4_1 = _mm256_setzero_si256(); + val_4_1 = _mm256_add_epi8(val_4_1, y_16); + __m256i val_4_2 = _mm256_setzero_si256(); + val_4_2 = _mm256_add_epi8(val_4_2, y_0); + val_4_2 = _mm256_add_epi8(val_4_2, y_18); + val_4_2 = _mm256_add_epi8(val_4_2, y_20); + __m256i val_4_3 = _mm256_setzero_si256(); + val_4_3 = _mm256_add_epi8(val_4_3, y_5); + val_4_3 = _mm256_add_epi8(val_4_3, y_14); + val_4_3 = _mm256_add_epi8(val_4_3, y_15); + __m256i val_4_4 = _mm256_setzero_si256(); + __m256i val_4_5 = _mm256_setzero_si256(); + val_4_5 = _mm256_add_epi8(val_4_5, y_2); + val_4_5 = _mm256_add_epi8(val_4_5, y_19); + __m256i val_4_6 = _mm256_setzero_si256(); + val_4_6 = _mm256_add_epi8(val_4_6, y_8); + val_4_6 = _mm256_add_epi8(val_4_6, y_11); + val_4_6 = _mm256_add_epi8(val_4_6, y_13); + val_4_6 = _mm256_add_epi8(val_4_6, y_17); + __m256i val_4_23 = _mm256_add_epi8(val_4_2, val_4_3); + __m256i val_4_45 = _mm256_add_epi8(val_4_4, val_4_5); + __m256i val_4 = _mm256_add_epi8(val_4_1, _mm256_add_epi8(val_4_23, _mm256_add_epi8(val_4_23, val_4_3))); + __m256i val_4_neg = _mm256_add_epi8(val_4_6, _mm256_add_epi8(val_4_45, _mm256_add_epi8(val_4_45, val_4_4))); + val_4 = ymm_sub_bias126_epi8(val_4, val_4_neg); + val_4 = ymm_mod7_epi8(val_4); + _mm256_storeu_si256((__m256i*)&output[4 * plane_out + offset], val_4); + } + { + __m256i val_5_1 = _mm256_setzero_si256(); + val_5_1 = _mm256_add_epi8(val_5_1, y_1); + val_5_1 = _mm256_add_epi8(val_5_1, y_2); + __m256i val_5_2 = _mm256_setzero_si256(); + val_5_2 = _mm256_add_epi8(val_5_2, y_8); + val_5_2 = _mm256_add_epi8(val_5_2, y_10); + val_5_2 = _mm256_add_epi8(val_5_2, y_17); + val_5_2 = _mm256_add_epi8(val_5_2, y_20); + __m256i val_5_3 = _mm256_setzero_si256(); + val_5_3 = _mm256_add_epi8(val_5_3, y_4); + __m256i val_5_4 = _mm256_setzero_si256(); + val_5_4 = _mm256_add_epi8(val_5_4, y_6); + val_5_4 = _mm256_add_epi8(val_5_4, y_9); + val_5_4 = _mm256_add_epi8(val_5_4, y_13); + val_5_4 = _mm256_add_epi8(val_5_4, y_18); + val_5_4 = _mm256_add_epi8(val_5_4, y_22); + __m256i val_5_5 = _mm256_setzero_si256(); + val_5_5 = _mm256_add_epi8(val_5_5, y_5); + val_5_5 = _mm256_add_epi8(val_5_5, y_15); + val_5_5 = _mm256_add_epi8(val_5_5, y_16); + val_5_5 = _mm256_add_epi8(val_5_5, y_21); + __m256i val_5_6 = _mm256_setzero_si256(); + val_5_6 = _mm256_add_epi8(val_5_6, y_3); + val_5_6 = _mm256_add_epi8(val_5_6, y_7); + val_5_6 = _mm256_add_epi8(val_5_6, y_12); + __m256i val_5_23 = _mm256_add_epi8(val_5_2, val_5_3); + __m256i val_5_45 = _mm256_add_epi8(val_5_4, val_5_5); + __m256i val_5 = _mm256_add_epi8(val_5_1, _mm256_add_epi8(val_5_23, _mm256_add_epi8(val_5_23, val_5_3))); + __m256i val_5_neg = _mm256_add_epi8(val_5_6, _mm256_add_epi8(val_5_45, _mm256_add_epi8(val_5_45, val_5_4))); + val_5_neg = ymm_fold126_epi8(val_5_neg); + val_5 = ymm_sub_bias126_epi8(val_5, val_5_neg); + val_5 = ymm_mod7_epi8(val_5); + _mm256_storeu_si256((__m256i*)&output[5 * plane_out + offset], val_5); + } + { + __m256i val_6_1 = _mm256_setzero_si256(); + val_6_1 = _mm256_add_epi8(val_6_1, y_1); + val_6_1 = _mm256_add_epi8(val_6_1, y_8); + val_6_1 = _mm256_add_epi8(val_6_1, y_17); + __m256i val_6_2 = _mm256_setzero_si256(); + val_6_2 = _mm256_add_epi8(val_6_2, y_10); + val_6_2 = _mm256_add_epi8(val_6_2, y_14); + val_6_2 = _mm256_add_epi8(val_6_2, y_15); + val_6_2 = _mm256_add_epi8(val_6_2, y_19); + val_6_2 = _mm256_add_epi8(val_6_2, y_20); + val_6_2 = _mm256_add_epi8(val_6_2, y_22); + __m256i val_6_3 = _mm256_setzero_si256(); + val_6_3 = _mm256_add_epi8(val_6_3, y_2); + val_6_3 = _mm256_add_epi8(val_6_3, y_3); + val_6_3 = _mm256_add_epi8(val_6_3, y_6); + val_6_3 = _mm256_add_epi8(val_6_3, y_7); + __m256i val_6_4 = _mm256_setzero_si256(); + val_6_4 = _mm256_add_epi8(val_6_4, y_5); + __m256i val_6_5 = _mm256_setzero_si256(); + val_6_5 = _mm256_add_epi8(val_6_5, y_11); + val_6_5 = _mm256_add_epi8(val_6_5, y_18); + __m256i val_6_6 = _mm256_setzero_si256(); + val_6_6 = _mm256_add_epi8(val_6_6, y_0); + val_6_6 = _mm256_add_epi8(val_6_6, y_9); + val_6_6 = _mm256_add_epi8(val_6_6, y_12); + val_6_6 = _mm256_add_epi8(val_6_6, y_13); + val_6_6 = _mm256_add_epi8(val_6_6, y_21); + __m256i val_6_23 = _mm256_add_epi8(val_6_2, val_6_3); + __m256i val_6_45 = _mm256_add_epi8(val_6_4, val_6_5); + __m256i val_6 = _mm256_add_epi8(val_6_1, _mm256_add_epi8(val_6_23, _mm256_add_epi8(val_6_23, val_6_3))); + val_6 = ymm_fold126_epi8(val_6); + __m256i val_6_neg = _mm256_add_epi8(val_6_6, _mm256_add_epi8(val_6_45, _mm256_add_epi8(val_6_45, val_6_4))); + val_6 = ymm_sub_bias126_epi8(val_6, val_6_neg); + val_6 = ymm_mod7_epi8(val_6); + _mm256_storeu_si256((__m256i*)&output[6 * plane_out + offset], val_6); + } + { + __m256i val_7_1 = _mm256_setzero_si256(); + val_7_1 = _mm256_add_epi8(val_7_1, y_4); + val_7_1 = _mm256_add_epi8(val_7_1, y_5); + val_7_1 = _mm256_add_epi8(val_7_1, y_15); + __m256i val_7_2 = _mm256_setzero_si256(); + val_7_2 = _mm256_add_epi8(val_7_2, y_14); + val_7_2 = _mm256_add_epi8(val_7_2, y_16); + val_7_2 = _mm256_add_epi8(val_7_2, y_17); + __m256i val_7_3 = _mm256_setzero_si256(); + val_7_3 = _mm256_add_epi8(val_7_3, y_11); + __m256i val_7_4 = _mm256_setzero_si256(); + val_7_4 = _mm256_add_epi8(val_7_4, y_7); + val_7_4 = _mm256_add_epi8(val_7_4, y_12); + val_7_4 = _mm256_add_epi8(val_7_4, y_19); + val_7_4 = _mm256_add_epi8(val_7_4, y_21); + __m256i val_7_5 = _mm256_setzero_si256(); + val_7_5 = _mm256_add_epi8(val_7_5, y_1); + val_7_5 = _mm256_add_epi8(val_7_5, y_3); + val_7_5 = _mm256_add_epi8(val_7_5, y_6); + val_7_5 = _mm256_add_epi8(val_7_5, y_22); + __m256i val_7_6 = _mm256_setzero_si256(); + val_7_6 = _mm256_add_epi8(val_7_6, y_2); + val_7_6 = _mm256_add_epi8(val_7_6, y_9); + val_7_6 = _mm256_add_epi8(val_7_6, y_10); + val_7_6 = _mm256_add_epi8(val_7_6, y_13); + val_7_6 = _mm256_add_epi8(val_7_6, y_20); + __m256i val_7_23 = _mm256_add_epi8(val_7_2, val_7_3); + __m256i val_7_45 = _mm256_add_epi8(val_7_4, val_7_5); + __m256i val_7 = _mm256_add_epi8(val_7_1, _mm256_add_epi8(val_7_23, _mm256_add_epi8(val_7_23, val_7_3))); + __m256i val_7_neg = _mm256_add_epi8(val_7_6, _mm256_add_epi8(val_7_45, _mm256_add_epi8(val_7_45, val_7_4))); + val_7_neg = ymm_fold126_epi8(val_7_neg); + val_7 = ymm_sub_bias126_epi8(val_7, val_7_neg); + val_7 = ymm_mod7_epi8(val_7); + _mm256_storeu_si256((__m256i*)&output[7 * plane_out + offset], val_7); + } + { + __m256i val_8_1 = _mm256_setzero_si256(); + val_8_1 = _mm256_add_epi8(val_8_1, y_3); + val_8_1 = _mm256_add_epi8(val_8_1, y_8); + val_8_1 = _mm256_add_epi8(val_8_1, y_11); + val_8_1 = _mm256_add_epi8(val_8_1, y_17); + val_8_1 = _mm256_add_epi8(val_8_1, y_18); + __m256i val_8_2 = _mm256_setzero_si256(); + val_8_2 = _mm256_add_epi8(val_8_2, y_10); + val_8_2 = _mm256_add_epi8(val_8_2, y_19); + __m256i val_8_3 = _mm256_setzero_si256(); + val_8_3 = _mm256_add_epi8(val_8_3, y_4); + __m256i val_8_4 = _mm256_setzero_si256(); + val_8_4 = _mm256_add_epi8(val_8_4, y_2); + val_8_4 = _mm256_add_epi8(val_8_4, y_7); + val_8_4 = _mm256_add_epi8(val_8_4, y_12); + val_8_4 = _mm256_add_epi8(val_8_4, y_16); + __m256i val_8_5 = _mm256_setzero_si256(); + val_8_5 = _mm256_add_epi8(val_8_5, y_5); + val_8_5 = _mm256_add_epi8(val_8_5, y_13); + val_8_5 = _mm256_add_epi8(val_8_5, y_14); + val_8_5 = _mm256_add_epi8(val_8_5, y_15); + val_8_5 = _mm256_add_epi8(val_8_5, y_20); + val_8_5 = _mm256_add_epi8(val_8_5, y_21); + __m256i val_8_6 = _mm256_setzero_si256(); + val_8_6 = _mm256_add_epi8(val_8_6, y_22); + __m256i val_8_23 = _mm256_add_epi8(val_8_2, val_8_3); + __m256i val_8_45 = _mm256_add_epi8(val_8_4, val_8_5); + __m256i val_8 = _mm256_add_epi8(val_8_1, _mm256_add_epi8(val_8_23, _mm256_add_epi8(val_8_23, val_8_3))); + __m256i val_8_neg = _mm256_add_epi8(val_8_6, _mm256_add_epi8(val_8_45, _mm256_add_epi8(val_8_45, val_8_4))); + val_8_neg = ymm_fold126_epi8(val_8_neg); + val_8 = ymm_sub_bias126_epi8(val_8, val_8_neg); + val_8 = ymm_mod7_epi8(val_8); + _mm256_storeu_si256((__m256i*)&output[8 * plane_out + offset], val_8); + } + { + __m256i val_9_1 = _mm256_setzero_si256(); + val_9_1 = _mm256_add_epi8(val_9_1, y_1); + val_9_1 = _mm256_add_epi8(val_9_1, y_10); + val_9_1 = _mm256_add_epi8(val_9_1, y_16); + __m256i val_9_2 = _mm256_setzero_si256(); + val_9_2 = _mm256_add_epi8(val_9_2, y_0); + val_9_2 = _mm256_add_epi8(val_9_2, y_4); + val_9_2 = _mm256_add_epi8(val_9_2, y_15); + __m256i val_9_3 = _mm256_setzero_si256(); + val_9_3 = _mm256_add_epi8(val_9_3, y_3); + val_9_3 = _mm256_add_epi8(val_9_3, y_5); + val_9_3 = _mm256_add_epi8(val_9_3, y_8); + val_9_3 = _mm256_add_epi8(val_9_3, y_12); + val_9_3 = _mm256_add_epi8(val_9_3, y_17); + val_9_3 = _mm256_add_epi8(val_9_3, y_20); + val_9_3 = _mm256_add_epi8(val_9_3, y_21); + __m256i val_9_4 = _mm256_setzero_si256(); + val_9_4 = _mm256_add_epi8(val_9_4, y_6); + val_9_4 = _mm256_add_epi8(val_9_4, y_18); + val_9_4 = _mm256_add_epi8(val_9_4, y_19); + __m256i val_9_5 = _mm256_setzero_si256(); + val_9_5 = _mm256_add_epi8(val_9_5, y_13); + __m256i val_9_6 = _mm256_setzero_si256(); + val_9_6 = _mm256_add_epi8(val_9_6, y_7); + val_9_6 = _mm256_add_epi8(val_9_6, y_9); + val_9_6 = _mm256_add_epi8(val_9_6, y_11); + val_9_6 = _mm256_add_epi8(val_9_6, y_22); + __m256i val_9_23 = _mm256_add_epi8(val_9_2, val_9_3); + __m256i val_9_45 = _mm256_add_epi8(val_9_4, val_9_5); + __m256i val_9 = _mm256_add_epi8(val_9_1, _mm256_add_epi8(val_9_23, _mm256_add_epi8(val_9_23, val_9_3))); + val_9 = ymm_fold126_epi8(val_9); + __m256i val_9_neg = _mm256_add_epi8(val_9_6, _mm256_add_epi8(val_9_45, _mm256_add_epi8(val_9_45, val_9_4))); + val_9 = ymm_sub_bias126_epi8(val_9, val_9_neg); + val_9 = ymm_mod7_epi8(val_9); + _mm256_storeu_si256((__m256i*)&output[9 * plane_out + offset], val_9); + } + { + __m256i val_10_1 = _mm256_setzero_si256(); + val_10_1 = _mm256_add_epi8(val_10_1, y_3); + val_10_1 = _mm256_add_epi8(val_10_1, y_4); + val_10_1 = _mm256_add_epi8(val_10_1, y_9); + val_10_1 = _mm256_add_epi8(val_10_1, y_11); + val_10_1 = _mm256_add_epi8(val_10_1, y_22); + __m256i val_10_2 = _mm256_setzero_si256(); + val_10_2 = _mm256_add_epi8(val_10_2, y_19); + __m256i val_10_3 = _mm256_setzero_si256(); + val_10_3 = _mm256_add_epi8(val_10_3, y_0); + val_10_3 = _mm256_add_epi8(val_10_3, y_1); + val_10_3 = _mm256_add_epi8(val_10_3, y_10); + val_10_3 = _mm256_add_epi8(val_10_3, y_15); + __m256i val_10_4 = _mm256_setzero_si256(); + __m256i val_10_5 = _mm256_setzero_si256(); + val_10_5 = _mm256_add_epi8(val_10_5, y_8); + val_10_5 = _mm256_add_epi8(val_10_5, y_20); + __m256i val_10_6 = _mm256_setzero_si256(); + val_10_6 = _mm256_add_epi8(val_10_6, y_2); + val_10_6 = _mm256_add_epi8(val_10_6, y_5); + val_10_6 = _mm256_add_epi8(val_10_6, y_6); + val_10_6 = _mm256_add_epi8(val_10_6, y_12); + val_10_6 = _mm256_add_epi8(val_10_6, y_17); + val_10_6 = _mm256_add_epi8(val_10_6, y_18); + val_10_6 = _mm256_add_epi8(val_10_6, y_21); + __m256i val_10_23 = _mm256_add_epi8(val_10_2, val_10_3); + __m256i val_10_45 = _mm256_add_epi8(val_10_4, val_10_5); + __m256i val_10 = _mm256_add_epi8(val_10_1, _mm256_add_epi8(val_10_23, _mm256_add_epi8(val_10_23, val_10_3))); + __m256i val_10_neg = _mm256_add_epi8(val_10_6, _mm256_add_epi8(val_10_45, _mm256_add_epi8(val_10_45, val_10_4))); + val_10 = ymm_sub_bias126_epi8(val_10, val_10_neg); + val_10 = ymm_mod7_epi8(val_10); + _mm256_storeu_si256((__m256i*)&output[10 * plane_out + offset], val_10); + } + { + __m256i val_11_1 = _mm256_setzero_si256(); + val_11_1 = _mm256_add_epi8(val_11_1, y_1); + val_11_1 = _mm256_add_epi8(val_11_1, y_7); + __m256i val_11_2 = _mm256_setzero_si256(); + val_11_2 = _mm256_add_epi8(val_11_2, y_8); + val_11_2 = _mm256_add_epi8(val_11_2, y_10); + val_11_2 = _mm256_add_epi8(val_11_2, y_14); + val_11_2 = _mm256_add_epi8(val_11_2, y_20); + __m256i val_11_3 = _mm256_setzero_si256(); + val_11_3 = _mm256_add_epi8(val_11_3, y_2); + val_11_3 = _mm256_add_epi8(val_11_3, y_3); + val_11_3 = _mm256_add_epi8(val_11_3, y_16); + val_11_3 = _mm256_add_epi8(val_11_3, y_19); + __m256i val_11_4 = _mm256_setzero_si256(); + val_11_4 = _mm256_add_epi8(val_11_4, y_0); + val_11_4 = _mm256_add_epi8(val_11_4, y_4); + val_11_4 = _mm256_add_epi8(val_11_4, y_17); + __m256i val_11_5 = _mm256_setzero_si256(); + val_11_5 = _mm256_add_epi8(val_11_5, y_5); + val_11_5 = _mm256_add_epi8(val_11_5, y_11); + val_11_5 = _mm256_add_epi8(val_11_5, y_12); + val_11_5 = _mm256_add_epi8(val_11_5, y_22); + __m256i val_11_6 = _mm256_setzero_si256(); + val_11_6 = _mm256_add_epi8(val_11_6, y_9); + val_11_6 = _mm256_add_epi8(val_11_6, y_15); + val_11_6 = _mm256_add_epi8(val_11_6, y_18); + val_11_6 = _mm256_add_epi8(val_11_6, y_21); + __m256i val_11_23 = _mm256_add_epi8(val_11_2, val_11_3); + __m256i val_11_45 = _mm256_add_epi8(val_11_4, val_11_5); + __m256i val_11 = _mm256_add_epi8(val_11_1, _mm256_add_epi8(val_11_23, _mm256_add_epi8(val_11_23, val_11_3))); + val_11 = ymm_fold126_epi8(val_11); + __m256i val_11_neg = _mm256_add_epi8(val_11_6, _mm256_add_epi8(val_11_45, _mm256_add_epi8(val_11_45, val_11_4))); + val_11 = ymm_sub_bias126_epi8(val_11, val_11_neg); + val_11 = ymm_mod7_epi8(val_11); + _mm256_storeu_si256((__m256i*)&output[11 * plane_out + offset], val_11); + } + { + __m256i val_12_1 = _mm256_setzero_si256(); + val_12_1 = _mm256_add_epi8(val_12_1, y_1); + val_12_1 = _mm256_add_epi8(val_12_1, y_2); + val_12_1 = _mm256_add_epi8(val_12_1, y_13); + val_12_1 = _mm256_add_epi8(val_12_1, y_14); + val_12_1 = _mm256_add_epi8(val_12_1, y_20); + __m256i val_12_2 = _mm256_setzero_si256(); + val_12_2 = _mm256_add_epi8(val_12_2, y_3); + val_12_2 = _mm256_add_epi8(val_12_2, y_6); + val_12_2 = _mm256_add_epi8(val_12_2, y_21); + __m256i val_12_3 = _mm256_setzero_si256(); + val_12_3 = _mm256_add_epi8(val_12_3, y_10); + val_12_3 = _mm256_add_epi8(val_12_3, y_12); + val_12_3 = _mm256_add_epi8(val_12_3, y_15); + __m256i val_12_4 = _mm256_setzero_si256(); + val_12_4 = _mm256_add_epi8(val_12_4, y_16); + __m256i val_12_5 = _mm256_setzero_si256(); + val_12_5 = _mm256_add_epi8(val_12_5, y_4); + val_12_5 = _mm256_add_epi8(val_12_5, y_9); + val_12_5 = _mm256_add_epi8(val_12_5, y_22); + __m256i val_12_6 = _mm256_setzero_si256(); + val_12_6 = _mm256_add_epi8(val_12_6, y_5); + val_12_6 = _mm256_add_epi8(val_12_6, y_8); + val_12_6 = _mm256_add_epi8(val_12_6, y_19); + __m256i val_12_23 = _mm256_add_epi8(val_12_2, val_12_3); + __m256i val_12_45 = _mm256_add_epi8(val_12_4, val_12_5); + __m256i val_12 = _mm256_add_epi8(val_12_1, _mm256_add_epi8(val_12_23, _mm256_add_epi8(val_12_23, val_12_3))); + __m256i val_12_neg = _mm256_add_epi8(val_12_6, _mm256_add_epi8(val_12_45, _mm256_add_epi8(val_12_45, val_12_4))); + val_12 = ymm_sub_bias126_epi8(val_12, val_12_neg); + val_12 = ymm_mod7_epi8(val_12); + _mm256_storeu_si256((__m256i*)&output[12 * plane_out + offset], val_12); + } + { + __m256i val_13_1 = _mm256_setzero_si256(); + val_13_1 = _mm256_add_epi8(val_13_1, y_0); + val_13_1 = _mm256_add_epi8(val_13_1, y_12); + val_13_1 = _mm256_add_epi8(val_13_1, y_19); + __m256i val_13_2 = _mm256_setzero_si256(); + val_13_2 = _mm256_add_epi8(val_13_2, y_15); + __m256i val_13_3 = _mm256_setzero_si256(); + val_13_3 = _mm256_add_epi8(val_13_3, y_9); + val_13_3 = _mm256_add_epi8(val_13_3, y_10); + val_13_3 = _mm256_add_epi8(val_13_3, y_21); + val_13_3 = _mm256_add_epi8(val_13_3, y_22); + __m256i val_13_4 = _mm256_setzero_si256(); + val_13_4 = _mm256_add_epi8(val_13_4, y_7); + val_13_4 = _mm256_add_epi8(val_13_4, y_17); + __m256i val_13_5 = _mm256_setzero_si256(); + val_13_5 = _mm256_add_epi8(val_13_5, y_6); + val_13_5 = _mm256_add_epi8(val_13_5, y_20); + __m256i val_13_6 = _mm256_setzero_si256(); + val_13_6 = _mm256_add_epi8(val_13_6, y_2); + val_13_6 = _mm256_add_epi8(val_13_6, y_3); + val_13_6 = _mm256_add_epi8(val_13_6, y_8); + val_13_6 = _mm256_add_epi8(val_13_6, y_11); + val_13_6 = _mm256_add_epi8(val_13_6, y_16); + val_13_6 = _mm256_add_epi8(val_13_6, y_18); + __m256i val_13_23 = _mm256_add_epi8(val_13_2, val_13_3); + __m256i val_13_45 = _mm256_add_epi8(val_13_4, val_13_5); + __m256i val_13 = _mm256_add_epi8(val_13_1, _mm256_add_epi8(val_13_23, _mm256_add_epi8(val_13_23, val_13_3))); + __m256i val_13_neg = _mm256_add_epi8(val_13_6, _mm256_add_epi8(val_13_45, _mm256_add_epi8(val_13_45, val_13_4))); + val_13 = ymm_sub_bias126_epi8(val_13, val_13_neg); + val_13 = ymm_mod7_epi8(val_13); + _mm256_storeu_si256((__m256i*)&output[13 * plane_out + offset], val_13); + } + { + __m256i val_14_1 = _mm256_setzero_si256(); + val_14_1 = _mm256_add_epi8(val_14_1, y_0); + val_14_1 = _mm256_add_epi8(val_14_1, y_15); + val_14_1 = _mm256_add_epi8(val_14_1, y_18); + __m256i val_14_2 = _mm256_setzero_si256(); + val_14_2 = _mm256_add_epi8(val_14_2, y_3); + val_14_2 = _mm256_add_epi8(val_14_2, y_6); + val_14_2 = _mm256_add_epi8(val_14_2, y_13); + __m256i val_14_3 = _mm256_setzero_si256(); + val_14_3 = _mm256_add_epi8(val_14_3, y_2); + val_14_3 = _mm256_add_epi8(val_14_3, y_16); + val_14_3 = _mm256_add_epi8(val_14_3, y_19); + val_14_3 = _mm256_add_epi8(val_14_3, y_20); + __m256i val_14_4 = _mm256_setzero_si256(); + val_14_4 = _mm256_add_epi8(val_14_4, y_8); + val_14_4 = _mm256_add_epi8(val_14_4, y_9); + val_14_4 = _mm256_add_epi8(val_14_4, y_11); + val_14_4 = _mm256_add_epi8(val_14_4, y_12); + __m256i val_14_5 = _mm256_setzero_si256(); + val_14_5 = _mm256_add_epi8(val_14_5, y_7); + val_14_5 = _mm256_add_epi8(val_14_5, y_22); + __m256i val_14_6 = _mm256_setzero_si256(); + val_14_6 = _mm256_add_epi8(val_14_6, y_1); + val_14_6 = _mm256_add_epi8(val_14_6, y_5); + val_14_6 = _mm256_add_epi8(val_14_6, y_10); + val_14_6 = _mm256_add_epi8(val_14_6, y_14); + __m256i val_14_23 = _mm256_add_epi8(val_14_2, val_14_3); + __m256i val_14_45 = _mm256_add_epi8(val_14_4, val_14_5); + __m256i val_14 = _mm256_add_epi8(val_14_1, _mm256_add_epi8(val_14_23, _mm256_add_epi8(val_14_23, val_14_3))); + __m256i val_14_neg = _mm256_add_epi8(val_14_6, _mm256_add_epi8(val_14_45, _mm256_add_epi8(val_14_45, val_14_4))); + val_14 = ymm_sub_bias126_epi8(val_14, val_14_neg); + val_14 = ymm_mod7_epi8(val_14); + _mm256_storeu_si256((__m256i*)&output[14 * plane_out + offset], val_14); + } + { + __m256i val_15_1 = _mm256_setzero_si256(); + val_15_1 = _mm256_add_epi8(val_15_1, y_1); + val_15_1 = _mm256_add_epi8(val_15_1, y_8); + val_15_1 = _mm256_add_epi8(val_15_1, y_16); + val_15_1 = _mm256_add_epi8(val_15_1, y_17); + __m256i val_15_2 = _mm256_setzero_si256(); + val_15_2 = _mm256_add_epi8(val_15_2, y_0); + val_15_2 = _mm256_add_epi8(val_15_2, y_18); + val_15_2 = _mm256_add_epi8(val_15_2, y_19); + __m256i val_15_3 = _mm256_setzero_si256(); + val_15_3 = _mm256_add_epi8(val_15_3, y_2); + val_15_3 = _mm256_add_epi8(val_15_3, y_4); + __m256i val_15_4 = _mm256_setzero_si256(); + val_15_4 = _mm256_add_epi8(val_15_4, y_3); + val_15_4 = _mm256_add_epi8(val_15_4, y_10); + val_15_4 = _mm256_add_epi8(val_15_4, y_12); + val_15_4 = _mm256_add_epi8(val_15_4, y_13); + val_15_4 = _mm256_add_epi8(val_15_4, y_14); + val_15_4 = _mm256_add_epi8(val_15_4, y_20); + val_15_4 = _mm256_add_epi8(val_15_4, y_21); + __m256i val_15_5 = _mm256_setzero_si256(); + val_15_5 = _mm256_add_epi8(val_15_5, y_6); + val_15_5 = _mm256_add_epi8(val_15_5, y_22); + __m256i val_15_6 = _mm256_setzero_si256(); + val_15_6 = _mm256_add_epi8(val_15_6, y_5); + val_15_6 = _mm256_add_epi8(val_15_6, y_7); + val_15_6 = _mm256_add_epi8(val_15_6, y_11); + val_15_6 = _mm256_add_epi8(val_15_6, y_15); + __m256i val_15_23 = _mm256_add_epi8(val_15_2, val_15_3); + __m256i val_15_45 = _mm256_add_epi8(val_15_4, val_15_5); + __m256i val_15 = _mm256_add_epi8(val_15_1, _mm256_add_epi8(val_15_23, _mm256_add_epi8(val_15_23, val_15_3))); + __m256i val_15_neg = _mm256_add_epi8(val_15_6, _mm256_add_epi8(val_15_45, _mm256_add_epi8(val_15_45, val_15_4))); + val_15_neg = ymm_fold126_epi8(val_15_neg); + val_15 = ymm_sub_bias126_epi8(val_15, val_15_neg); + val_15 = ymm_mod7_epi8(val_15); + _mm256_storeu_si256((__m256i*)&output[15 * plane_out + offset], val_15); + } + { + __m256i val_16_1 = _mm256_setzero_si256(); + val_16_1 = _mm256_add_epi8(val_16_1, y_2); + val_16_1 = _mm256_add_epi8(val_16_1, y_14); + val_16_1 = _mm256_add_epi8(val_16_1, y_16); + __m256i val_16_2 = _mm256_setzero_si256(); + val_16_2 = _mm256_add_epi8(val_16_2, y_1); + val_16_2 = _mm256_add_epi8(val_16_2, y_4); + val_16_2 = _mm256_add_epi8(val_16_2, y_7); + val_16_2 = _mm256_add_epi8(val_16_2, y_11); + val_16_2 = _mm256_add_epi8(val_16_2, y_13); + val_16_2 = _mm256_add_epi8(val_16_2, y_18); + __m256i val_16_3 = _mm256_setzero_si256(); + val_16_3 = _mm256_add_epi8(val_16_3, y_3); + val_16_3 = _mm256_add_epi8(val_16_3, y_15); + val_16_3 = _mm256_add_epi8(val_16_3, y_17); + __m256i val_16_4 = _mm256_setzero_si256(); + val_16_4 = _mm256_add_epi8(val_16_4, y_6); + __m256i val_16_5 = _mm256_setzero_si256(); + val_16_5 = _mm256_add_epi8(val_16_5, y_0); + val_16_5 = _mm256_add_epi8(val_16_5, y_5); + val_16_5 = _mm256_add_epi8(val_16_5, y_8); + val_16_5 = _mm256_add_epi8(val_16_5, y_9); + val_16_5 = _mm256_add_epi8(val_16_5, y_10); + val_16_5 = _mm256_add_epi8(val_16_5, y_20); + __m256i val_16_6 = _mm256_setzero_si256(); + val_16_6 = _mm256_add_epi8(val_16_6, y_19); + __m256i val_16_23 = _mm256_add_epi8(val_16_2, val_16_3); + __m256i val_16_45 = _mm256_add_epi8(val_16_4, val_16_5); + __m256i val_16 = _mm256_add_epi8(val_16_1, _mm256_add_epi8(val_16_23, _mm256_add_epi8(val_16_23, val_16_3))); + val_16 = ymm_fold126_epi8(val_16); + __m256i val_16_neg = _mm256_add_epi8(val_16_6, _mm256_add_epi8(val_16_45, _mm256_add_epi8(val_16_45, val_16_4))); + val_16 = ymm_sub_bias126_epi8(val_16, val_16_neg); + val_16 = ymm_mod7_epi8(val_16); + _mm256_storeu_si256((__m256i*)&output[16 * plane_out + offset], val_16); + } + { + __m256i val_17_1 = _mm256_setzero_si256(); + val_17_1 = _mm256_add_epi8(val_17_1, y_7); + val_17_1 = _mm256_add_epi8(val_17_1, y_13); + val_17_1 = _mm256_add_epi8(val_17_1, y_21); + __m256i val_17_2 = _mm256_setzero_si256(); + val_17_2 = _mm256_add_epi8(val_17_2, y_15); + val_17_2 = _mm256_add_epi8(val_17_2, y_17); + __m256i val_17_3 = _mm256_setzero_si256(); + val_17_3 = _mm256_add_epi8(val_17_3, y_14); + __m256i val_17_4 = _mm256_setzero_si256(); + val_17_4 = _mm256_add_epi8(val_17_4, y_5); + val_17_4 = _mm256_add_epi8(val_17_4, y_8); + val_17_4 = _mm256_add_epi8(val_17_4, y_11); + val_17_4 = _mm256_add_epi8(val_17_4, y_18); + val_17_4 = _mm256_add_epi8(val_17_4, y_20); + __m256i val_17_5 = _mm256_setzero_si256(); + val_17_5 = _mm256_add_epi8(val_17_5, y_4); + val_17_5 = _mm256_add_epi8(val_17_5, y_12); + __m256i val_17_6 = _mm256_setzero_si256(); + val_17_6 = _mm256_add_epi8(val_17_6, y_0); + val_17_6 = _mm256_add_epi8(val_17_6, y_3); + val_17_6 = _mm256_add_epi8(val_17_6, y_10); + val_17_6 = _mm256_add_epi8(val_17_6, y_22); + __m256i val_17_23 = _mm256_add_epi8(val_17_2, val_17_3); + __m256i val_17_45 = _mm256_add_epi8(val_17_4, val_17_5); + __m256i val_17 = _mm256_add_epi8(val_17_1, _mm256_add_epi8(val_17_23, _mm256_add_epi8(val_17_23, val_17_3))); + __m256i val_17_neg = _mm256_add_epi8(val_17_6, _mm256_add_epi8(val_17_45, _mm256_add_epi8(val_17_45, val_17_4))); + val_17_neg = ymm_fold126_epi8(val_17_neg); + val_17 = ymm_sub_bias126_epi8(val_17, val_17_neg); + val_17 = ymm_mod7_epi8(val_17); + _mm256_storeu_si256((__m256i*)&output[17 * plane_out + offset], val_17); + } + { + __m256i val_18_1 = _mm256_setzero_si256(); + val_18_1 = _mm256_add_epi8(val_18_1, y_5); + val_18_1 = _mm256_add_epi8(val_18_1, y_12); + val_18_1 = _mm256_add_epi8(val_18_1, y_13); + __m256i val_18_2 = _mm256_setzero_si256(); + val_18_2 = _mm256_add_epi8(val_18_2, y_8); + val_18_2 = _mm256_add_epi8(val_18_2, y_11); + val_18_2 = _mm256_add_epi8(val_18_2, y_16); + val_18_2 = _mm256_add_epi8(val_18_2, y_20); + val_18_2 = _mm256_add_epi8(val_18_2, y_21); + __m256i val_18_3 = _mm256_setzero_si256(); + val_18_3 = _mm256_add_epi8(val_18_3, y_9); + val_18_3 = _mm256_add_epi8(val_18_3, y_14); + val_18_3 = _mm256_add_epi8(val_18_3, y_18); + __m256i val_18_4 = _mm256_setzero_si256(); + val_18_4 = _mm256_add_epi8(val_18_4, y_2); + val_18_4 = _mm256_add_epi8(val_18_4, y_10); + __m256i val_18_5 = _mm256_setzero_si256(); + val_18_5 = _mm256_add_epi8(val_18_5, y_3); + val_18_5 = _mm256_add_epi8(val_18_5, y_4); + val_18_5 = _mm256_add_epi8(val_18_5, y_19); + __m256i val_18_6 = _mm256_setzero_si256(); + val_18_6 = _mm256_add_epi8(val_18_6, y_6); + val_18_6 = _mm256_add_epi8(val_18_6, y_22); + __m256i val_18_23 = _mm256_add_epi8(val_18_2, val_18_3); + __m256i val_18_45 = _mm256_add_epi8(val_18_4, val_18_5); + __m256i val_18 = _mm256_add_epi8(val_18_1, _mm256_add_epi8(val_18_23, _mm256_add_epi8(val_18_23, val_18_3))); + val_18 = ymm_fold126_epi8(val_18); + __m256i val_18_neg = _mm256_add_epi8(val_18_6, _mm256_add_epi8(val_18_45, _mm256_add_epi8(val_18_45, val_18_4))); + val_18 = ymm_sub_bias126_epi8(val_18, val_18_neg); + val_18 = ymm_mod7_epi8(val_18); + _mm256_storeu_si256((__m256i*)&output[18 * plane_out + offset], val_18); + } + { + __m256i val_19_1 = _mm256_setzero_si256(); + val_19_1 = _mm256_add_epi8(val_19_1, y_1); + val_19_1 = _mm256_add_epi8(val_19_1, y_14); + val_19_1 = _mm256_add_epi8(val_19_1, y_16); + val_19_1 = _mm256_add_epi8(val_19_1, y_19); + __m256i val_19_2 = _mm256_setzero_si256(); + val_19_2 = _mm256_add_epi8(val_19_2, y_3); + val_19_2 = _mm256_add_epi8(val_19_2, y_4); + val_19_2 = _mm256_add_epi8(val_19_2, y_7); + val_19_2 = _mm256_add_epi8(val_19_2, y_9); + val_19_2 = _mm256_add_epi8(val_19_2, y_11); + __m256i val_19_3 = _mm256_setzero_si256(); + val_19_3 = _mm256_add_epi8(val_19_3, y_6); + val_19_3 = _mm256_add_epi8(val_19_3, y_21); + val_19_3 = _mm256_add_epi8(val_19_3, y_22); + __m256i val_19_4 = _mm256_setzero_si256(); + val_19_4 = _mm256_add_epi8(val_19_4, y_8); + val_19_4 = _mm256_add_epi8(val_19_4, y_13); + val_19_4 = _mm256_add_epi8(val_19_4, y_15); + __m256i val_19_5 = _mm256_setzero_si256(); + val_19_5 = _mm256_add_epi8(val_19_5, y_18); + __m256i val_19_6 = _mm256_setzero_si256(); + val_19_6 = _mm256_add_epi8(val_19_6, y_0); + val_19_6 = _mm256_add_epi8(val_19_6, y_5); + val_19_6 = _mm256_add_epi8(val_19_6, y_10); + val_19_6 = _mm256_add_epi8(val_19_6, y_17); + __m256i val_19_23 = _mm256_add_epi8(val_19_2, val_19_3); + __m256i val_19_45 = _mm256_add_epi8(val_19_4, val_19_5); + __m256i val_19 = _mm256_add_epi8(val_19_1, _mm256_add_epi8(val_19_23, _mm256_add_epi8(val_19_23, val_19_3))); + val_19 = ymm_fold126_epi8(val_19); + __m256i val_19_neg = _mm256_add_epi8(val_19_6, _mm256_add_epi8(val_19_45, _mm256_add_epi8(val_19_45, val_19_4))); + val_19 = ymm_sub_bias126_epi8(val_19, val_19_neg); + val_19 = ymm_mod7_epi8(val_19); + _mm256_storeu_si256((__m256i*)&output[19 * plane_out + offset], val_19); + } + { + __m256i val_20_1 = _mm256_setzero_si256(); + val_20_1 = _mm256_add_epi8(val_20_1, y_0); + val_20_1 = _mm256_add_epi8(val_20_1, y_22); + __m256i val_20_2 = _mm256_setzero_si256(); + val_20_2 = _mm256_add_epi8(val_20_2, y_1); + val_20_2 = _mm256_add_epi8(val_20_2, y_6); + val_20_2 = _mm256_add_epi8(val_20_2, y_17); + __m256i val_20_3 = _mm256_setzero_si256(); + val_20_3 = _mm256_add_epi8(val_20_3, y_8); + val_20_3 = _mm256_add_epi8(val_20_3, y_11); + val_20_3 = _mm256_add_epi8(val_20_3, y_16); + __m256i val_20_4 = _mm256_setzero_si256(); + val_20_4 = _mm256_add_epi8(val_20_4, y_2); + __m256i val_20_5 = _mm256_setzero_si256(); + val_20_5 = _mm256_add_epi8(val_20_5, y_3); + val_20_5 = _mm256_add_epi8(val_20_5, y_9); + val_20_5 = _mm256_add_epi8(val_20_5, y_10); + val_20_5 = _mm256_add_epi8(val_20_5, y_13); + val_20_5 = _mm256_add_epi8(val_20_5, y_14); + val_20_5 = _mm256_add_epi8(val_20_5, y_15); + val_20_5 = _mm256_add_epi8(val_20_5, y_18); + val_20_5 = _mm256_add_epi8(val_20_5, y_19); + val_20_5 = _mm256_add_epi8(val_20_5, y_21); + __m256i val_20_6 = _mm256_setzero_si256(); + val_20_6 = _mm256_add_epi8(val_20_6, y_4); + val_20_6 = _mm256_add_epi8(val_20_6, y_5); + __m256i val_20_23 = _mm256_add_epi8(val_20_2, val_20_3); + __m256i val_20_45 = _mm256_add_epi8(val_20_4, val_20_5); + __m256i val_20 = _mm256_add_epi8(val_20_1, _mm256_add_epi8(val_20_23, _mm256_add_epi8(val_20_23, val_20_3))); + __m256i val_20_neg = _mm256_add_epi8(val_20_6, _mm256_add_epi8(val_20_45, _mm256_add_epi8(val_20_45, val_20_4))); + val_20_neg = ymm_fold126_epi8(val_20_neg); + val_20 = ymm_sub_bias126_epi8(val_20, val_20_neg); + val_20 = ymm_mod7_epi8(val_20); + _mm256_storeu_si256((__m256i*)&output[20 * plane_out + offset], val_20); + } + { + __m256i val_21_1 = _mm256_setzero_si256(); + val_21_1 = _mm256_add_epi8(val_21_1, y_7); + val_21_1 = _mm256_add_epi8(val_21_1, y_9); + val_21_1 = _mm256_add_epi8(val_21_1, y_10); + __m256i val_21_2 = _mm256_setzero_si256(); + val_21_2 = _mm256_add_epi8(val_21_2, y_1); + val_21_2 = _mm256_add_epi8(val_21_2, y_6); + val_21_2 = _mm256_add_epi8(val_21_2, y_21); + val_21_2 = _mm256_add_epi8(val_21_2, y_22); + __m256i val_21_3 = _mm256_setzero_si256(); + val_21_3 = _mm256_add_epi8(val_21_3, y_3); + val_21_3 = _mm256_add_epi8(val_21_3, y_12); + val_21_3 = _mm256_add_epi8(val_21_3, y_15); + val_21_3 = _mm256_add_epi8(val_21_3, y_16); + __m256i val_21_4 = _mm256_setzero_si256(); + val_21_4 = _mm256_add_epi8(val_21_4, y_11); + val_21_4 = _mm256_add_epi8(val_21_4, y_17); + val_21_4 = _mm256_add_epi8(val_21_4, y_19); + val_21_4 = _mm256_add_epi8(val_21_4, y_20); + __m256i val_21_5 = _mm256_setzero_si256(); + val_21_5 = _mm256_add_epi8(val_21_5, y_0); + val_21_5 = _mm256_add_epi8(val_21_5, y_8); + val_21_5 = _mm256_add_epi8(val_21_5, y_14); + val_21_5 = _mm256_add_epi8(val_21_5, y_18); + __m256i val_21_6 = _mm256_setzero_si256(); + val_21_6 = _mm256_add_epi8(val_21_6, y_2); + val_21_6 = _mm256_add_epi8(val_21_6, y_4); + __m256i val_21_23 = _mm256_add_epi8(val_21_2, val_21_3); + __m256i val_21_45 = _mm256_add_epi8(val_21_4, val_21_5); + __m256i val_21 = _mm256_add_epi8(val_21_1, _mm256_add_epi8(val_21_23, _mm256_add_epi8(val_21_23, val_21_3))); + val_21 = ymm_fold126_epi8(val_21); + __m256i val_21_neg = _mm256_add_epi8(val_21_6, _mm256_add_epi8(val_21_45, _mm256_add_epi8(val_21_45, val_21_4))); + val_21_neg = ymm_fold126_epi8(val_21_neg); + val_21 = ymm_sub_bias126_epi8(val_21, val_21_neg); + val_21 = ymm_mod7_epi8(val_21); + _mm256_storeu_si256((__m256i*)&output[21 * plane_out + offset], val_21); + } + { + __m256i val_22_1 = _mm256_setzero_si256(); + val_22_1 = _mm256_add_epi8(val_22_1, y_1); + val_22_1 = _mm256_add_epi8(val_22_1, y_11); + val_22_1 = _mm256_add_epi8(val_22_1, y_14); + __m256i val_22_2 = _mm256_setzero_si256(); + val_22_2 = _mm256_add_epi8(val_22_2, y_6); + val_22_2 = _mm256_add_epi8(val_22_2, y_12); + val_22_2 = _mm256_add_epi8(val_22_2, y_18); + val_22_2 = _mm256_add_epi8(val_22_2, y_21); + __m256i val_22_3 = _mm256_setzero_si256(); + val_22_3 = _mm256_add_epi8(val_22_3, y_0); + val_22_3 = _mm256_add_epi8(val_22_3, y_5); + val_22_3 = _mm256_add_epi8(val_22_3, y_10); + val_22_3 = _mm256_add_epi8(val_22_3, y_13); + __m256i val_22_4 = _mm256_setzero_si256(); + val_22_4 = _mm256_add_epi8(val_22_4, y_19); + __m256i val_22_5 = _mm256_setzero_si256(); + val_22_5 = _mm256_add_epi8(val_22_5, y_4); + val_22_5 = _mm256_add_epi8(val_22_5, y_8); + val_22_5 = _mm256_add_epi8(val_22_5, y_9); + val_22_5 = _mm256_add_epi8(val_22_5, y_17); + val_22_5 = _mm256_add_epi8(val_22_5, y_22); + __m256i val_22_6 = _mm256_setzero_si256(); + val_22_6 = _mm256_add_epi8(val_22_6, y_2); + val_22_6 = _mm256_add_epi8(val_22_6, y_3); + __m256i val_22_23 = _mm256_add_epi8(val_22_2, val_22_3); + __m256i val_22_45 = _mm256_add_epi8(val_22_4, val_22_5); + __m256i val_22 = _mm256_add_epi8(val_22_1, _mm256_add_epi8(val_22_23, _mm256_add_epi8(val_22_23, val_22_3))); + val_22 = ymm_fold126_epi8(val_22); + __m256i val_22_neg = _mm256_add_epi8(val_22_6, _mm256_add_epi8(val_22_45, _mm256_add_epi8(val_22_45, val_22_4))); + val_22 = ymm_sub_bias126_epi8(val_22, val_22_neg); + val_22 = ymm_mod7_epi8(val_22); + _mm256_storeu_si256((__m256i*)&output[22 * plane_out + offset], val_22); + } + } +} +#elif QRUOV_q == 127 && QRUOV_L == 10 +void interpolate_avx2_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 16); + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + const __m256i y_0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[0 * plane_in + offset])); + const __m256i y_1 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[1 * plane_in + offset])); + const __m256i y_2 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[2 * plane_in + offset])); + const __m256i y_3 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[3 * plane_in + offset])); + const __m256i y_4 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[4 * plane_in + offset])); + const __m256i y_5 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[5 * plane_in + offset])); + const __m256i y_6 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[6 * plane_in + offset])); + const __m256i y_7 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[7 * plane_in + offset])); + const __m256i y_8 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[8 * plane_in + offset])); + const __m256i y_9 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[9 * plane_in + offset])); + const __m256i y_10 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[10 * plane_in + offset])); + const __m256i y_11 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[11 * plane_in + offset])); + const __m256i y_12 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[12 * plane_in + offset])); + const __m256i y_13 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[13 * plane_in + offset])); + const __m256i y_14 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[14 * plane_in + offset])); + const __m256i y_15 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[15 * plane_in + offset])); + const __m256i y_16 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[16 * plane_in + offset])); + const __m256i y_17 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[17 * plane_in + offset])); + const __m256i y_18 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[18 * plane_in + offset])); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(98), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_1)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(85), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(83), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(97), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(35), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(114), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(85), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(104), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(23), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[0 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(85), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(6), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(94), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(59), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(50), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(94), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(112), y_10)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(96), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(120), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(118), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(32), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(118), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(123), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(12), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[1 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(25), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(53), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(53), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(67), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(67), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(18), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(18), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(94), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(94), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(13), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[2 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(36), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(72), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(112), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(65), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(73), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(93), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(90), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(100), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(72), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(92), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(107), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(5), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[3 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(69), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_1)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(67), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(25), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(34), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_11)); + val = _mm256_add_epi16(val, y_12); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(39), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(65), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(46), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(74), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[4 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(103), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(50), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(62), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(50), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(32), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(100), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(20), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(120), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(36), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(30), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(72), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(24), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[5 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(57), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(78), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(6), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(27), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_10)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(89), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(34), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(103), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(80), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[6 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(120), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(110), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(93), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(41), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(24), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(72), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(115), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(88), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(112), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(23), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[7 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(101), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(3), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(36), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(78), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(40), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(78), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(41), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(67), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(19), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(45), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[8 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(47), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(4), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(54), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(70), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(46), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(112), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[9 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + } +} +void reevaluate_avx2_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + assert(size >= 16); + for (int i = 0; i < size; i += 16) { + const int offset = (i + 15) < size ? i : (size - 16); + const __m256i y_0 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[0 * plane_in + offset])); + const __m256i y_1 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[1 * plane_in + offset])); + const __m256i y_2 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[2 * plane_in + offset])); + const __m256i y_3 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[3 * plane_in + offset])); + const __m256i y_4 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[4 * plane_in + offset])); + const __m256i y_5 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[5 * plane_in + offset])); + const __m256i y_6 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[6 * plane_in + offset])); + const __m256i y_7 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[7 * plane_in + offset])); + const __m256i y_8 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[8 * plane_in + offset])); + const __m256i y_9 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[9 * plane_in + offset])); + const __m256i y_10 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[10 * plane_in + offset])); + const __m256i y_11 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[11 * plane_in + offset])); + const __m256i y_12 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[12 * plane_in + offset])); + const __m256i y_13 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[13 * plane_in + offset])); + const __m256i y_14 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[14 * plane_in + offset])); + const __m256i y_15 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[15 * plane_in + offset])); + const __m256i y_16 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[16 * plane_in + offset])); + const __m256i y_17 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[17 * plane_in + offset])); + const __m256i y_18 = _mm256_cvtepu8_epi16(_mm_loadu_si128((__m128i*)&input[18 * plane_in + offset])); + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(98), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_1)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(85), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(83), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(97), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(35), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(114), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(85), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(104), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(23), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[0 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(6), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(96), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(27), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(125), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(104), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(65), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_10)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(30), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(103), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(110), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[1 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(43), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(45), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(71), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(11), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(119), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(119), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(54), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(59), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(38), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(34), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(53), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(98), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(55), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[2 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(93), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(2), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(118), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(121), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(39), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(103), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(64), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(110), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(5), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(15), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(14), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(101), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[3 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(71), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(18), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(18), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(123), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(38), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(45), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(34), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(74), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(36), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(6), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(52), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[4 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(16), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(4), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(12), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(90), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(13), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(15), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(88), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(122), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(11), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(89), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(69), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(100), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[5 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(40), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(89), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(49), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(119), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(38), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(70), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(9), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(71), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[6 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(50), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(83), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(90), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(93), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(88), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(41), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(70), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(99), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(87), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(120), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(33), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(14), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(98), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(27), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(51), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(27), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(24), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[7 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(66), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(79), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(69), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(13), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(125), y_10)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(45), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(22), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(84), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(62), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(45), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(55), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(78), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(100), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[8 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(9), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(89), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(79), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(51), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(97), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(33), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(71), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(5), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(33), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[9 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(54), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(123), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(70), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(119), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(102), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(114), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(107), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(5), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(13), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(105), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(90), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(122), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(30), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[10 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(43), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(110), y_1)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(87), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(122), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(113), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(117), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(80), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(123), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_10)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(19), y_13)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(84), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(107), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(43), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[11 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(29), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(103), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(40), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(78), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(12), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(15), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(16), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(90), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(54), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(98), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(4), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(47), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(96), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[12 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(15), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(31), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(41), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(123), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_5)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(122), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(20), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(52), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(5), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(11), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(63), y_16)); + val = _mm256_add_epi16(val, y_17); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(53), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[13 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(109), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(77), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(25), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(36), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(110), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(49), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(58), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(20), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(57), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(52), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(73), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(96), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(19), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(49), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(47), y_15)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(99), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[14 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(69), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(83), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(44), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(83), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(106), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(119), y_8)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(19), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(41), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(109), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(2), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(46), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(37), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[15 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(61), y_1)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(76), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(4), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(79), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(9), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(75), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(126), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(101), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(99), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(87), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(26), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(115), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(43), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(12), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(19), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(59), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[16 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(86), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(40), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(59), y_2)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(21), y_3)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(125), y_4)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(67), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(7), y_6)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_7)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(10), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(114), y_9)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_11)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(56), y_12)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(14), y_14)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(23), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(68), y_16)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(81), y_17)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(50), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[17 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + { + __m256i val = _mm256_setzero_si256(); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(82), y_0)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(42), y_1)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(95), y_2)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_3)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(124), y_4)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(47), y_5)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(28), y_6)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_7)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(116), y_8)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(8), y_9)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(108), y_10)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(4), y_11)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(91), y_12)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(54), y_13)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(70), y_14)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(111), y_15)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(17), y_16)); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(46), y_17)); + val = ymm_reduce127_epi16(val); + val = _mm256_add_epi16(val, _mm256_mullo_epi16(_mm256_set1_epi16(112), y_18)); + val = ymm_mod127_epi15(val); + _mm_storeu_si128((__m128i*)&output[18 * plane_out + offset], ymm_cvtusepi16_epi8(val)); + } + } +} +#endif diff --git a/src/sig/qruov/qruov_qruov_avx2/fastop.h b/src/sig/qruov/qruov_qruov_avx2/fastop.h new file mode 100644 index 0000000000..18102a381d --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/fastop.h @@ -0,0 +1,233 @@ +#ifndef FASTOP_H +#define FASTOP_H + +#include +#include +#include +#include +#include "qruov.h" +#include "qruov_simd.h" + +extern uint8_t qruov_avx2_bextmask[1u << 16][16]; +extern uint8_t qruov_avx2_bdepmask[1u << 16][16]; + +static inline size_t fastop_rejsamp_prep(unsigned int length, const uint8_t *src, uint8_t *dst, + const uint8_t bextmask[][16]) +{ + uint8_t *dst0 = dst; + int i = 0; + for (; i + 15 < (int)length; i += 16) { + __m128i buf = _mm_loadu_si128((const __m128i *)src); + buf = _mm_and_si128(buf, _mm_set1_epi8(QRUOV_q)); + int mask = 0xFFFF ^ _mm_movemask_epi8(_mm_cmpeq_epi8(buf, _mm_set1_epi8(QRUOV_q))); + buf = _mm_shuffle_epi8(buf, _mm_load_si128((const __m128i *)bextmask[mask])); + _mm_storeu_si128((__m128i *)dst, buf); + src += 16; + dst += __builtin_popcount((unsigned int)mask); + } + for (; i < (int)length; i++) { + uint8_t v = (uint8_t)(*src & QRUOV_q); + if (v != QRUOV_q) *dst++ = v; + src++; + } + return (size_t)(dst - dst0); +} + +static inline void fastop_rejection_sample(uint8_t *dst, int tau, int length) +{ + const int tail_len = tau - length; + uint8_t tmp[tail_len + 16]; + size_t written = fastop_rejsamp_prep((unsigned int)tail_len, dst + length, tmp, + (const uint8_t (*)[16])qruov_avx2_bextmask); + memset(tmp + written, 0, 16); + + uint8_t *ptmp = tmp; + uint8_t *tmp_end = tmp + written; + int i = 0; + for (; i + 15 < length && ptmp <= tmp_end; i += 16) { + __m128i inp = _mm_loadu_si128((__m128i *)&dst[i]); + __m128i mux = _mm_loadu_si128((__m128i *)ptmp); + inp = _mm_and_si128(inp, _mm_set1_epi8(QRUOV_q)); + __m128i q = _mm_cmpeq_epi8(inp, _mm_set1_epi8(QRUOV_q)); + int mask = _mm_movemask_epi8(q); + __m128i ans = _mm_or_si128(_mm_andnot_si128(q, inp), + _mm_shuffle_epi8(mux, _mm_load_si128((__m128i *)qruov_avx2_bdepmask[mask]))); + _mm_storeu_si128((__m128i *)&dst[i], ans); + ptmp += __builtin_popcount((unsigned int)mask); + } + for (; i < length; i++) { + int val = dst[i] & QRUOV_q; + if (val == QRUOV_q) { + dst[i] = (ptmp < tmp_end) ? *ptmp++ : 0; + } else { + dst[i] = (uint8_t)val; + } + } +} + +static inline uint8_t fastop_rejection_dotprod(unsigned int length, unsigned int tau, + uint8_t *src, const uint8_t *vec) +{ + const unsigned int tail_len = tau - length; + uint8_t tmp[tail_len + 32]; + size_t written = fastop_rejsamp_prep(tail_len, src + length, tmp, + (const uint8_t (*)[16])qruov_avx2_bextmask); + memset(tmp + written, 0, 32); + + enum { FASTPATH = QRUOV_q == 127 }; + const uint8_t *ptmp = tmp; + const uint8_t *tmp_end = tmp + written; + int i = 0; + __m256i acc = _mm256_setzero_si256(); + for (; i + 31 < (int)length && ptmp <= tmp_end; i += 32) { + __m256i inp = _mm256_loadu_si256((const __m256i *)&src[i]); + inp = _mm256_and_si256(inp, _mm256_set1_epi8(QRUOV_q)); + __m256i q = _mm256_cmpeq_epi8(inp, _mm256_set1_epi8(QRUOV_q)); + __m256i v = _mm256_loadu_si256((const __m256i *)&vec[i]); + uint32_t mask = (uint32_t)_mm256_movemask_epi8(q); + if (FASTPATH && mask == 0) { + acc = ymm_dot_u8s8(acc, inp, v); + continue; + } + int c0 = __builtin_popcount(mask & 0xFFFFu); + __m128i mux0 = _mm_loadu_si128((const __m128i *)ptmp); + __m128i mux1 = _mm_loadu_si128((const __m128i *)(ptmp + c0)); + __m128i msk0 = _mm_load_si128((const __m128i *)qruov_avx2_bdepmask[mask & 0xFFFFu]); + __m128i msk1 = _mm_load_si128((const __m128i *)qruov_avx2_bdepmask[mask >> 16]); + __m256i mux = _mm256_set_m128i(mux1, mux0); + __m256i msk = _mm256_set_m128i(msk1, msk0); + __m256i ans = _mm256_or_si256(_mm256_andnot_si256(q, inp), _mm256_shuffle_epi8(mux, msk)); + acc = ymm_dot_u8s8(acc, ans, v); + ptmp += __builtin_popcount(mask); + } + if (i + 15 < (int)length && ptmp <= tmp_end) { + __m128i inp = _mm_loadu_si128((const __m128i *)&src[i]); + inp = _mm_and_si128(inp, _mm_set1_epi8(QRUOV_q)); + __m128i q = _mm_cmpeq_epi8(inp, _mm_set1_epi8(QRUOV_q)); + uint16_t mask = _mm_movemask_epi8(q); + __m128i mux = _mm_loadu_si128((const __m128i *)ptmp); + __m128i msk = _mm_load_si128((const __m128i *)qruov_avx2_bdepmask[mask & 0xFFFFu]); + __m128i ans = _mm_or_si128(_mm_andnot_si128(q, inp), _mm_shuffle_epi8(mux, msk)); + __m128i v = _mm_loadu_si128((const __m128i *)&vec[i]); + __m128i pair16 = _mm_maddubs_epi16(ans, v); + __m128i part32 = _mm_madd_epi16(_mm_set1_epi16(1), pair16); + acc = _mm256_add_epi32(acc, _mm256_set_m128i(_mm_setzero_si128(), part32)); + ptmp += __builtin_popcount(mask); + i += 16; + } + int sum = ymm_reduce_add_epi32(acc); + for (; i < (int)length; i++) { + int val = src[i] & QRUOV_q; + if (val == QRUOV_q) { + sum += ((ptmp < tmp_end) ? *ptmp++ : 0) * vec[i]; + } else { + sum += val * vec[i]; + } + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline uint8_t fastop_dotprod(unsigned int length, const uint8_t *a, const uint8_t *b) +{ + unsigned int i = 0; + __m256i acc = _mm256_setzero_si256(); + + for (; i + 31 < length; i += 32) { + __m256i av = _mm256_loadu_si256((const __m256i *)&a[i]); + __m256i bv = _mm256_loadu_si256((const __m256i *)&b[i]); + acc = ymm_dot_u8s8(acc, av, bv); + } + + uint32_t sum = (uint32_t)ymm_reduce_add_epi32(acc); + for (; i < length; i++) { + sum += (uint32_t)a[i] * b[i]; + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline void fastop_row_elim(uint8_t *dst, const uint8_t *pivot, uint8_t m_mul, int len) +{ + int t = 0; + __m256i m_mul_v = _mm256_set1_epi16(m_mul); + for (; t + 15 < len; t += 16) { + __m256i dst_v = _mm256_cvtepi8_epi16(_mm_loadu_si128((const __m128i *)&dst[t])); + __m256i piv_v = _mm256_cvtepi8_epi16(_mm_loadu_si128((const __m128i *)&pivot[t])); + __m256i tmp = _mm256_add_epi16(dst_v, _mm256_mullo_epi16(m_mul_v, piv_v)); + tmp = ymm_modq_epi15(tmp); + _mm_storeu_si128((__m128i *)&dst[t], ymm_cvtusepi16_epi8(tmp)); + } + for (; t < len; t++) { + dst[t] = (uint8_t)(((uint32_t)dst[t] + (uint32_t)m_mul * pivot[t]) % QRUOV_q); + } +} + +static inline void fastop_store_fq(uint8_t *dst, const uint8_t *src, size_t src_len) +{ + size_t i = 0; + size_t out = 0; + uint32_t acc = 0; + unsigned bits = 0; + +#if defined(__BMI2__) + { + const size_t FQ_IN_64 = (64u + QRUOV_q_LOG - 1u) / QRUOV_q_LOG; + const uint64_t q = QRUOV_q; + const uint64_t mask = q | (q << 8) | (q << 16) | (q << 24) | + (q << 32) | (q << 40) | (q << 48) | (q << 56); + while (src_len - i >= FQ_IN_64) { + uint64_t mem = _pext_u64(load_u64(&src[i]), mask); + memcpy(&dst[out], &mem, QRUOV_q_LOG); + i += 8; + out += QRUOV_q_LOG; + } + } +#endif + + while (i < src_len) { + acc |= (uint32_t)src[i++] << bits; + bits += QRUOV_q_LOG; + while (bits >= 8) { + dst[out++] = (uint8_t)acc; + acc >>= 8; + bits -= 8; + } + } + if (bits > 0) dst[out] = (uint8_t)acc; +} + +static inline void fastop_load_fq(uint8_t *dst, const uint8_t *src, size_t dst_len) +{ + size_t i = 0; + size_t in = 0; + uint32_t acc = 0; + unsigned bits = 0; + const uint32_t mask32 = (1u << QRUOV_q_LOG) - 1u; + +#if defined(__BMI2__) + { + const size_t FQ_IN_64 = (64u + QRUOV_q_LOG - 1u) / QRUOV_q_LOG; + const uint64_t q = QRUOV_q; + const uint64_t mask = q | (q << 8) | (q << 16) | (q << 24) | + (q << 32) | (q << 40) | (q << 48) | (q << 56); + while (dst_len - i >= FQ_IN_64) { + uint64_t packed = load_u64(&src[in]); + uint64_t mem = _pdep_u64(packed, mask); + store_u64(&dst[i], mem); + i += 8; + in += QRUOV_q_LOG; + } + } +#endif + + while (i < dst_len) { + while (bits < QRUOV_q_LOG) { + acc |= ((uint32_t)src[in++]) << bits; + bits += 8; + } + dst[i++] = (uint8_t)(acc & mask32); + acc >>= QRUOV_q_LOG; + bits -= QRUOV_q_LOG; + } +} + +#endif // FASTOP_H diff --git a/src/sig/qruov/qruov_qruov_avx2/helpers.c b/src/sig/qruov/qruov_qruov_avx2/helpers.c new file mode 100644 index 0000000000..5240b16670 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/helpers.c @@ -0,0 +1,441 @@ +#include +#include +#include +#include "qruov.h" +#include "helpers.h" +#include "kernel.h" +#include "qruov_simd.h" +#include "emi_transform.h" +#include "fastop.h" + +void fql_soa_to_aos_permute(uint8_t dst_aos[], const uint8_t src_soa[], int items, int plane) +{ + for (int i = 0; i < items; i++) { + for (int j = 0; j < QRUOV_L; j++) { + dst_aos[i * QRUOV_L + QRUOV_perm(j)] = src_soa[j * plane + i]; + } + } +} + +void fql_soa_to_aos_permute_double(uint8_t dst_aos[], const uint8_t src_soa[], int items, int plane) +{ + for (int i = 0; i < items; i++) { + for (int j = 0; j < QRUOV_L; j++) { + uint8_t t = src_soa[j * plane + i]; + t = (uint8_t)(t + t); + if (t >= QRUOV_q) t = (uint8_t)(t - QRUOV_q); + dst_aos[i * QRUOV_L + QRUOV_perm(j)] = t; + } + } +} + +void fql_aos_to_soa(uint8_t dst_soa[], const uint8_t src_aos[], int items, int plane) +{ + for (int i = 0; i < items; i++) { + for (int j = 0; j < QRUOV_L; j++) { + dst_soa[j * plane + i] = src_aos[i * QRUOV_L + j]; + } + } +} + +void fql_matmul_vnni_fast(uint8_t C[], const uint8_t A[], const uint8_t Bvnni[], int M, int N, int K) +{ + assert(K % 4 == 0); + assert(N == 6 || N == 7 || N >= 8); + const int incout = N; + const int incA = K; + const int incB = N; + const int incLout = M * N; + const int incLA = M * K; + const int incLB = K * N; + if (N == 7) { + for (int i = 0; i < M; i++) { + int j = 0; + matmulfql_vnni_1x7(&C[i * N + j], &A[i * K], &Bvnni[j * 4], K, incout, incA, incB, incLout, incLA, incLB); + } + return; + } + if (N == 6) { + for (int i = 0; i < M; i++) { + int j = 0; + matmulfql_vnni_1x6(&C[i * N + j], &A[i * K], &Bvnni[j * 4], K, incout, incA, incB, incLout, incLA, incLB); + } + return; + } + for (int i = 0; i < M; i++) { + int j = 0; + for (; j + 8 <= N; j += 8) { + matmulfql_vnni_1x8(&C[i * N + j], &A[i * K], &Bvnni[j * 4], K, incout, incA, incB, incLout, incLA, incLB); + } + int rem = N - j; + if (rem > 0) { + if (rem <= 4) { + j = N - 4; + matmulfql_vnni_1x4(&C[i * N + j], &A[i * K], &Bvnni[j * 4], K, incout, incA, incB, incLout, incLA, incLB); + } else { + j = N - 8; + matmulfql_vnni_1x8(&C[i * N + j], &A[i * K], &Bvnni[j * 4], K, incout, incA, incB, incLout, incLA, incLB); + } + } + } +} + +#if QRUOV_L == 3 +static void fql_aos_to_vnni_L3_impl(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origN); + if (origM <= 0 || origN <= 0) { + return; + } + const int plane = M * N; + int i = 0; + const int stride = origN * QRUOV_L; + const __m128i INTL4 = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + for (; i + 3 < origM; i += 4) { + int j = 0; + for (; j < origN; j += 4) { + if (j + 3 >= origN) j = origN - 4; + const uint8_t *input = &bytes[(i * origN + j) * QRUOV_L]; + __m128i a0 = _mm_loadu_si128((__m128i*)&input[0 * stride]); + __m128i a1 = _mm_loadu_si128((__m128i*)&input[1 * stride]); + __m128i a2 = _mm_loadu_si128((__m128i*)&input[2 * stride]); + __m128i a3 = _mm_loadu_si128((__m128i*)&input[3 * stride]); + __m128i y0, y1, y2; + deint3_transpose(a0, a1, a2, a3, &y0, &y1, &y2); + uint8_t *vnni = &Avnni[i / 4 * N * 4 + j * 4]; + _mm_storeu_si128((__m128i*)&vnni[0 * plane], _mm_shuffle_epi8(y0, INTL4)); + _mm_storeu_si128((__m128i*)&vnni[1 * plane], _mm_shuffle_epi8(y1, INTL4)); + _mm_storeu_si128((__m128i*)&vnni[2 * plane], _mm_shuffle_epi8(y2, INTL4)); + } + } + if (i < origM) { + const int rem = origM - i; + for (int j = 0; j < origN; j++) { + const uint8_t *input = &bytes[(i * origN + j) * QRUOV_L]; + const size_t dst_base = (size_t)(i >> 2) * (size_t)N * 4u + (size_t)j * 4u; + for (int l = 0; l < QRUOV_L; l++) { + uint32_t v = input[l]; + if (rem > 1) v |= (uint32_t)input[stride + l] << 8; + if (rem > 2) v |= (uint32_t)input[2 * stride + l] << 16; + store_u32(&Avnni[(size_t)l * (size_t)plane + dst_base], v); + } + } + } +} +#elif QRUOV_L == 10 +static void fql_aos_to_vnni_L10_impl(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origN); + if (origM <= 0 || origN <= 0) { + return; + } + const int plane = M * N; + int i = 0; + const int stride = origN * QRUOV_L; + const __m128i INTL4 = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + uint8_t buffer[160], buffer2[160]; + for (; i + 3 < origM; i += 4) { + int j = 0; + for (; j < origN; j += 4) { + if (j + 3 >= origN) j = origN - 4; + const uint8_t *input = &bytes[(i * origN + j) * QRUOV_L]; + memcpy(&buffer[0 * 4 * QRUOV_L], &input[0 * stride], QRUOV_L * 4); + memcpy(&buffer[1 * 4 * QRUOV_L], &input[1 * stride], QRUOV_L * 4); + memcpy(&buffer[2 * 4 * QRUOV_L], &input[2 * stride], QRUOV_L * 4); + memcpy(&buffer[3 * 4 * QRUOV_L], &input[3 * stride], QRUOV_L * 4); + transpose16x10(buffer2, buffer); + uint8_t *vnni = &Avnni[i / 4 * N * 4 + j * 4]; + for (int l = 0; l < QRUOV_L; l++) { + __m128i y = _mm_loadu_si128((__m128i*)&buffer2[l * 16]); + _mm_storeu_si128((__m128i*)&vnni[l * plane], _mm_shuffle_epi8(y, INTL4)); + } + } + } + if (i < origM) { + const int rem = origM - i; + for (int j = 0; j < origN; j++) { + const uint8_t *input = &bytes[(i * origN + j) * QRUOV_L]; + const size_t dst_base = (size_t)(i >> 2) * (size_t)N * 4u + (size_t)j * 4u; + for (int l = 0; l < QRUOV_L; l++) { + uint32_t v = input[l]; + if (rem > 1) v |= (uint32_t)input[stride + l] << 8; + if (rem > 2) v |= (uint32_t)input[2 * stride + l] << 16; + store_u32(&Avnni[(size_t)l * (size_t)plane + dst_base], v); + } + } + } +} +#else +#error "Unknown QRUOV_L" +#endif + +void fql_aos_to_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ +#if QRUOV_L == 3 + fql_aos_to_vnni_L3_impl(Avnni, M, N, bytes, origM, origN); +#elif QRUOV_L == 10 + fql_aos_to_vnni_L10_impl(Avnni, M, N, bytes, origM, origN); +#else +#error "Unknown QRUOV_L" +#endif +} + +#if QRUOV_L == 3 +static void fql_compact_sym_aos_to_vnni_L3_impl(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origM); + int i = 0; + for (; i + 3 < origM; i += 4) { + const __m128i INTL4 = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + const __m128i SYMM = _mm_setr_epi8(0, 1, 2, 3, 1, 4, 5, 6, 2, 5, 8, 9, 3, 6, 9, 12); + const int stride = origM - i; + const int plane = M * N; + { + const uint8_t *input = &bytes[SYMM_COMPACT_INDEX(i, i, origM) * QRUOV_L]; + __m128i a0 = _mm_loadu_si128((__m128i*)&input[0]); + __m128i a1 = _mm_loadu_si128((__m128i*)&input[(1 * stride) * 3]); + __m128i a2 = _mm_loadu_si128((__m128i*)&input[(2 * stride - 1) * 3]); + __m128i a3 = _mm_loadu_si128((__m128i*)&input[(3 * stride - 3) * 3]); + __m128i y0, y1, y2; + deint3_transpose(a0, a1, a2, a3, &y0, &y1, &y2); + uint8_t *symm = &Avnni[i / 4 * N * 4 + i * 4]; + _mm_storeu_si128((__m128i*)&symm[0 * plane], _mm_shuffle_epi8(y0, SYMM)); + _mm_storeu_si128((__m128i*)&symm[1 * plane], _mm_shuffle_epi8(y1, SYMM)); + _mm_storeu_si128((__m128i*)&symm[2 * plane], _mm_shuffle_epi8(y2, SYMM)); + } + int j = i + 4; + for (; j + 3 < origM; j += 4) { + const uint8_t *input = &bytes[SYMM_COMPACT_INDEX(i, j, origM) * QRUOV_L]; + __m128i a0 = _mm_loadu_si128((__m128i*)&input[0]); + __m128i a1 = _mm_loadu_si128((__m128i*)&input[(1 * stride - 1) * 3]); + __m128i a2 = _mm_loadu_si128((__m128i*)&input[(2 * stride - 3) * 3]); + __m128i a3 = _mm_loadu_si128((__m128i*)&input[(3 * stride - 6) * 3]); + __m128i y0, y1, y2; + deint3_transpose(a0, a1, a2, a3, &y0, &y1, &y2); + uint8_t *trans = &Avnni[j / 4 * N * 4 + i * 4]; + uint8_t *copy = &Avnni[i / 4 * N * 4 + j * 4]; + _mm_storeu_si128((__m128i*)&trans[0 * plane], y0); + _mm_storeu_si128((__m128i*)&trans[1 * plane], y1); + _mm_storeu_si128((__m128i*)&trans[2 * plane], y2); + _mm_storeu_si128((__m128i*)©[0 * plane], _mm_shuffle_epi8(y0, INTL4)); + _mm_storeu_si128((__m128i*)©[1 * plane], _mm_shuffle_epi8(y1, INTL4)); + _mm_storeu_si128((__m128i*)©[2 * plane], _mm_shuffle_epi8(y2, INTL4)); + } + for (; j < origM; j++) { + for (int i0 = i; i0 < i + 4; i0++) { + for (int l = 0; l < QRUOV_L; l++) { + Avnni[l * M * N + i0 / 4 * N * 4 + j * 4 + i0 % 4] = + Avnni[l * M * N + j / 4 * N * 4 + i0 * 4 + j % 4] = + bytes[SYMM_COMPACT_INDEX(i0, j, origM) * QRUOV_L + l]; + } + } + } + } + for (; i < origM; i++) { + for (int j = i; j < origM; j++) { + for (int l = 0; l < QRUOV_L; l++) { + Avnni[l * M * N + i / 4 * N * 4 + j * 4 + i % 4] = + Avnni[l * M * N + j / 4 * N * 4 + i * 4 + j % 4] = + bytes[SYMM_COMPACT_INDEX(i, j, origM) * QRUOV_L + l]; + } + } + } +} +#endif + +#if QRUOV_L == 10 +static void fql_compact_sym_aos_to_vnni_L10_impl(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origM); + uint8_t buffer[160] = {0}, buffer2[160]; + int i = 0; + for (; i + 3 < origM; i += 4) { + const __m128i INTL4 = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + const __m128i SYMM = _mm_setr_epi8(0, 1, 2, 3, 1, 4, 5, 6, 2, 5, 8, 9, 3, 6, 9, 12); + const int stride = origM - i; + const int plane = M * N; + { + const uint8_t *input = &bytes[SYMM_COMPACT_INDEX(i, i, origM) * QRUOV_L]; + memcpy(&buffer[0 * 4 * QRUOV_L], &input[0], QRUOV_L * 4); + memcpy(&buffer[1 * 4 * QRUOV_L], &input[(1 * stride) * QRUOV_L], QRUOV_L * 4); + memcpy(&buffer[2 * 4 * QRUOV_L], &input[(2 * stride - 1) * QRUOV_L], QRUOV_L * 4); + memcpy(&buffer[3 * 4 * QRUOV_L], &input[(3 * stride - 3) * QRUOV_L], QRUOV_L * 4); + transpose16x10(buffer2, buffer); + uint8_t *symm = &Avnni[i / 4 * N * 4 + i * 4]; + for (int l = 0; l < QRUOV_L; l++) { + __m128i y = _mm_loadu_si128((__m128i*)&buffer2[l * 16]); + _mm_storeu_si128((__m128i*)&symm[l * plane], _mm_shuffle_epi8(y, SYMM)); + } + } + int j = i + 4; + for (; j + 3 < origM; j += 4) { + const uint8_t *input = &bytes[SYMM_COMPACT_INDEX(i, j, origM) * QRUOV_L]; + memcpy(&buffer[0 * 4 * QRUOV_L], &input[0], QRUOV_L * 4); + memcpy(&buffer[1 * 4 * QRUOV_L], &input[(1 * stride - 1) * QRUOV_L], QRUOV_L * 4); + memcpy(&buffer[2 * 4 * QRUOV_L], &input[(2 * stride - 3) * QRUOV_L], QRUOV_L * 4); + memcpy(&buffer[3 * 4 * QRUOV_L], &input[(3 * stride - 6) * QRUOV_L], QRUOV_L * 4); + transpose16x10(buffer2, buffer); + uint8_t *trans = &Avnni[j / 4 * N * 4 + i * 4]; + uint8_t *copy = &Avnni[i / 4 * N * 4 + j * 4]; + for (int l = 0; l < QRUOV_L; l++) { + __m128i y = _mm_loadu_si128((__m128i*)&buffer2[l * 16]); + _mm_storeu_si128((__m128i*)&trans[l * plane], y); + _mm_storeu_si128((__m128i*)©[l * plane], _mm_shuffle_epi8(y, INTL4)); + } + } + for (; j < origM; j++) { + for (int i0 = i; i0 < i + 4; i0++) { + for (int l = 0; l < QRUOV_L; l++) { + Avnni[l * M * N + i0 / 4 * N * 4 + j * 4 + i0 % 4] = + Avnni[l * M * N + j / 4 * N * 4 + i0 * 4 + j % 4] = + bytes[SYMM_COMPACT_INDEX(i0, j, origM) * QRUOV_L + l]; + } + } + } + } + for (; i < origM; i++) { + for (int j = i; j < origM; j++) { + for (int l = 0; l < QRUOV_L; l++) { + Avnni[l * M * N + i / 4 * N * 4 + j * 4 + i % 4] = + Avnni[l * M * N + j / 4 * N * 4 + i * 4 + j % 4] = + bytes[SYMM_COMPACT_INDEX(i, j, origM) * QRUOV_L + l]; + } + } + } +} +#endif + +#if QRUOV_L == 3 +void fql_compact_sym_aos_to_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM) +{ + fql_compact_sym_aos_to_vnni_L3_impl(Avnni, M, N, bytes, origM); +} +#elif QRUOV_L == 10 +void fql_compact_sym_aos_to_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM) +{ + fql_compact_sym_aos_to_vnni_L10_impl(Avnni, M, N, bytes, origM); +} +#else +#error "unknown QRUOV_L" +#endif + +static void transpose_mat(uint8_t *B, const uint8_t *A, int ldB, int ldA, int M, int N) +{ + int i = 0; + for (; i + 7 < M; i += 8) { + int j = 0; + for (; j + 7 < N; j += 8) { + transpose8x8(&B[j * ldB + i], &A[i * ldA + j], ldB, ldA); + } + for (; j < N; j++) { + B[j * ldB + i + 0] = A[(i + 0) * ldA + j]; + B[j * ldB + i + 1] = A[(i + 1) * ldA + j]; + B[j * ldB + i + 2] = A[(i + 2) * ldA + j]; + B[j * ldB + i + 3] = A[(i + 3) * ldA + j]; + B[j * ldB + i + 4] = A[(i + 4) * ldA + j]; + B[j * ldB + i + 5] = A[(i + 5) * ldA + j]; + B[j * ldB + i + 6] = A[(i + 6) * ldA + j]; + B[j * ldB + i + 7] = A[(i + 7) * ldA + j]; + } + } + for (; i < M; i++) { + for (int j = 0; j < N; j++) { + B[j * ldB + i] = A[i * ldA + j]; + } + } +} + +void fq_eval_transpose_planes(uint8_t B[], const uint8_t A[], int planeB, int planeA, int ldB, int ldA, int M, int N) +{ + for (int l = 0; l < QRUOV_LL; l++) { + transpose_mat(&B[l * planeB], &A[l * planeA], ldB, ldA, M, N); + } +} + +static void fql_aos_to_transposed_soa(uint8_t A[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ + assert(M >= origN && N >= origM); + for (int i = 0; i < origM; i++) { + for (int j = 0; j < origN; j++) { + for (int k = 0; k < QRUOV_L; k++) { + A[k * M * N + j * N + i] = bytes[i * origN * QRUOV_L + j * QRUOV_L + k]; + } + } + } +} + +void fql_matmul_eval_vnni_fast(uint8_t C[], const uint8_t A[], const uint8_t Bvnni[], int M, int N, int K) +{ + assert(K % 4 == 0); + assert(N >= 4); + for (int l = 0; l < QRUOV_LL; l++) { + for (int i = 0; i < M; i += 4) { + if (i + 3 >= M) i = M - 4; + int j = 0; + for (; j + 15 < N; j += 16) { + matmulfq_vnni_4x16(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } + if (j + 7 < N) { + matmulfq_vnni_4x8(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + j += 8; + } + int rem = N - j; + if (rem == 7 && N == 7) { + matmulfq_vnni_4x7(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } else if (rem == 6 && N == 6) { + matmulfq_vnni_4x6(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } else if (rem >= 5 && N >= 8) { + j = N - 8; + matmulfq_vnni_4x8(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } else if (rem >= 5) { + matmulfq_vnni_4x4(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + j = N - 4; + matmulfq_vnni_4x4(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } else if (rem >= 1) { + j = N - 4; + matmulfq_vnni_4x4(&C[l * M * N + i * N + j], &A[l * M * K + i * K], + &Bvnni[l * K * N + j * 4], K, N, K, 4 * N); + } + } + } +} + +void fql_compact_sym_aos_to_eval_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origM); + uint8_t tmp[QRUOV_L * M * N]; + memset(tmp, 0, sizeof(tmp)); + fql_compact_sym_aos_to_vnni(tmp, M, N, bytes, origM); + evaluate(Avnni, M * N, tmp, M * N, M * N); +} + +void fql_aos_to_eval_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ + assert(M % 4 == 0); + assert(M >= origM && N >= origN); + uint8_t tmp[QRUOV_L * M * N]; + if (N != origN) memset(tmp, 0, sizeof(tmp)); + fql_aos_to_vnni(tmp, M, N, bytes, origM, origN); + evaluate(Avnni, M * N, tmp, M * N, M * N); +} + +void fql_aos_to_eval_transposed_soa(uint8_t A[], int M, int N, const uint8_t bytes[], int origM, int origN) +{ + assert(M >= origN && N >= origM); + uint8_t tmp[QRUOV_L * M * N]; + memset(tmp, 0, sizeof(tmp)); + fql_aos_to_transposed_soa(tmp, M, N, bytes, origM, origN); + evaluate(A, M * N, tmp, M * N, M * N); +} diff --git a/src/sig/qruov/qruov_qruov_avx2/helpers.h b/src/sig/qruov/qruov_qruov_avx2/helpers.h new file mode 100644 index 0000000000..a79ca18d15 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/helpers.h @@ -0,0 +1,27 @@ +#ifndef AVX2_HELPERS_H +#define AVX2_HELPERS_H + +#include + +#define SYMM_COMPACT_INDEX(i, j, N) ((j) + (i) * (N) - ((i) * ((i) + 1) / 2)) + +// AoS layout stores F_{q^L} coefficients as [items][L]. +// SoA layout stores them as [L][plane], where plane may include padding. +void fql_aos_to_soa(uint8_t dst_soa[], const uint8_t src_aos[], int items, int plane); +void fql_soa_to_aos_permute(uint8_t dst_aos[], const uint8_t src_soa[], int items, int plane); +void fql_soa_to_aos_permute_double(uint8_t dst_aos[], const uint8_t src_soa[], int items, int plane); + +void fql_matmul_vnni_fast(uint8_t C[], const uint8_t A[], const uint8_t Bvnni[], int M, int N, int K); +void fql_matmul_eval_vnni_fast(uint8_t C[], const uint8_t A[], const uint8_t Bvnni[], int M, int N, int K); +void fq_eval_transpose_planes(uint8_t B[], const uint8_t A[], int planeB, int planeA, int ldB, int ldA, int M, int N); + +// Convert AoS coefficient matrices to AVX2 VNNI layouts, optionally after +// applying the EMI evaluation transform. The compact_sym variants take +// upper-triangle compact symmetric input. +void fql_aos_to_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN); +void fql_compact_sym_aos_to_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM); +void fql_aos_to_eval_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM, int origN); +void fql_compact_sym_aos_to_eval_vnni(uint8_t Avnni[], int M, int N, const uint8_t bytes[], int origM); +void fql_aos_to_eval_transposed_soa(uint8_t A[], int M, int N, const uint8_t bytes[], int origM, int origN); + +#endif diff --git a/src/sig/qruov/qruov_qruov_avx2/kernel.c b/src/sig/qruov/qruov_qruov_avx2/kernel.c new file mode 100644 index 0000000000..9cae4d47dd --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/kernel.c @@ -0,0 +1,1204 @@ +#include +#include + +#include "kernel.h" +#include "qruov_simd.h" + +static inline __m256i load_row_vnni_8(const uint8_t *ptr) +{ + return _mm256_loadu_si256((const __m256i *)ptr); +} + +static inline __m256i load_row_vnni_7(const uint8_t *ptr) +{ + __m128i lo = _mm_loadu_si128((const __m128i *)ptr); + __m128i hi = _mm_loadu_si128((const __m128i *)(ptr + 12)); + return _mm256_setr_m128i(lo, _mm_srli_si128(hi, 4)); +} + +static inline __m256i load_row_vnni_6(const uint8_t *ptr) +{ + __m128i lo = _mm_loadu_si128((const __m128i *)ptr); + __m128i hi = _mm_loadu_si128((const __m128i *)(ptr + 8)); + return _mm256_setr_m128i(lo, _mm_srli_si128(hi, 8)); +} + +static inline __m256i load_row_vnni_4x2(const uint8_t *ptr0, const uint8_t *ptr1) +{ + const __m256i idx = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + __m128i lo = _mm_loadu_si128((const __m128i *)ptr0); + __m128i hi = _mm_loadu_si128((const __m128i *)ptr1); + return _mm256_permutevar8x32_epi32( + _mm256_set_m128i(hi, lo), idx); +} + +static inline __m256i load_row_vnni_4x1(const uint8_t *ptr) +{ + const __m256i idx = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + __m128i lo = _mm_loadu_si128((const __m128i *)ptr); + return _mm256_permutevar8x32_epi32( + _mm256_set_m128i(_mm_setzero_si128(), lo), idx); +} + +static inline void load_row_vnni_16(__m256i *lo, __m256i *hi, const uint8_t *ptr) +{ + *lo = _mm256_loadu_si256((const __m256i *)ptr); + *hi = _mm256_loadu_si256((const __m256i *)(ptr + 32)); +} + +static inline void store_row_8_epi32(uint8_t *out, __m256i acc) +{ + _mm_storel_epi64((__m128i *)out, ymm_modq_epi32_epi8(acc)); +} + +static inline void store_row_7_epi32(uint8_t *out, __m256i acc) +{ + __m128i tmp = ymm_modq_epi32_epi8(acc); + memcpy(out, &tmp, 7); +} + +static inline void store_row_6_epi32(uint8_t *out, __m256i acc) +{ + __m128i tmp = ymm_modq_epi32_epi8(acc); + memcpy(out, &tmp, 6); +} + +static inline void store_row_4_pair_epi32(uint8_t *out, __m256i acc) +{ + __m256i sum = _mm256_hadd_epi32(acc, _mm256_setzero_si256()); + sum = _mm256_permute4x64_epi64(sum, _MM_SHUFFLE(3, 1, 2, 0)); + __m128i tmp = ymm_modq_epi32_epi8(sum); + store_u32(out, (uint32_t)_mm_cvtsi128_si32(tmp)); +} + +#if QRUOV_q != 7 +static inline void store_row_16_epi32(uint8_t *out, __m256i lo, __m256i hi) +{ + __m128i tmp = ymm2_modq_epi32_epi8(lo, hi); + memcpy(out, &tmp, 16); +} +#endif + +#if QRUOV_q == 7 +static inline void store_row_8_hadd_epi16(uint8_t *out, __m256i acc) +{ + __m256i sum = _mm256_hadd_epi16(acc, _mm256_setzero_si256()); + sum = ymm_mod7_epi15(sum); + __m128i sum16 = _mm_unpacklo_epi64(_mm256_castsi256_si128(sum), + _mm256_extracti128_si256(sum, 1)); + __m128i tmp = _mm_packus_epi16(sum16, _mm_setzero_si128()); + _mm_storel_epi64((__m128i *)out, tmp); +} + +static inline void store_row_16_hadd_epi16(uint8_t *out, __m256i lo, __m256i hi) +{ + __m256i sum = _mm256_hadd_epi16(lo, hi); + sum = ymm_mod7_epi15(sum); + sum = _mm256_permute4x64_epi64(sum, _MM_SHUFFLE(3, 1, 2, 0)); + __m128i tmp = _mm_packus_epi16(_mm256_castsi256_si128(sum), + _mm256_extracti128_si256(sum, 1)); + memcpy(out, &tmp, 16); +} +#endif + +#define ADD1(dst, src) \ + do { \ + dst = _mm256_add_epi32(dst, src); \ + } while (0) + +#define ADD2(dst, src) \ + do { \ + dst = _mm256_add_epi32(dst, src); \ + dst = _mm256_add_epi32(dst, src); \ + } while (0) + +#define ADD5(dst, src) \ + do { \ + dst = _mm256_add_epi32(dst, src); \ + dst = _mm256_add_epi32(dst, src); \ + dst = _mm256_add_epi32(dst, src); \ + dst = _mm256_add_epi32(dst, src); \ + dst = _mm256_add_epi32(dst, src); \ + } while (0) + +#define ADD25(dst, src) \ + do { \ + __m256i src_x5 = _mm256_add_epi32(src, _mm256_slli_epi32(src, 2)); \ + dst = _mm256_add_epi32(dst, _mm256_add_epi32(src_x5, _mm256_slli_epi32(src_x5, 2))); \ + } while (0) + +#if QRUOV_L == 3 +static void matmulfql3_symmetric_upper_impl(uint8_t *output_soa, const uint8_t *vector_soa, int size) +{ + assert(size % 16 == 0); + for (int i = 0; i < size; i++) { + __m256i a0 = _mm256_set1_epi16(vector_soa[0 * size + i]); + __m256i a1 = _mm256_set1_epi16(vector_soa[1 * size + i]); + __m256i a2 = _mm256_set1_epi16(vector_soa[2 * size + i]); + for (int j = i & ~15; j < size; j += 16) { + __m256i b0 = _mm256_cvtepi8_epi16( + _mm_loadu_si128((const __m128i *)&vector_soa[0 * size + j])); + __m256i b1 = _mm256_cvtepi8_epi16( + _mm_loadu_si128((const __m128i *)&vector_soa[1 * size + j])); + __m256i b2 = _mm256_cvtepi8_epi16( + _mm_loadu_si128((const __m128i *)&vector_soa[2 * size + j])); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + + c0 = _mm256_add_epi16(c0, _mm256_mullo_epi16(a0, b0)); + c1 = _mm256_add_epi16(c1, _mm256_mullo_epi16(a0, b1)); + c2 = _mm256_add_epi16(c2, _mm256_mullo_epi16(a0, b2)); + c1 = _mm256_add_epi16(c1, _mm256_mullo_epi16(a1, b0)); + c2 = _mm256_add_epi16(c2, _mm256_mullo_epi16(a1, b1)); + c3 = _mm256_add_epi16(c3, _mm256_mullo_epi16(a1, b2)); + c2 = _mm256_add_epi16(c2, _mm256_mullo_epi16(a2, b0)); + c3 = _mm256_add_epi16(c3, _mm256_mullo_epi16(a2, b1)); + c4 = _mm256_add_epi16(c4, _mm256_mullo_epi16(a2, b2)); + +#if QRUOV_q == 127 + c2 = ymm_reduceq_epi16(c2); + c3 = ymm_reduceq_epi16(c3); + c4 = ymm_reduceq_epi16(c4); +#endif + c0 = _mm256_add_epi16(c0, c3); + c1 = _mm256_add_epi16(c1, c3); + c1 = _mm256_add_epi16(c1, c4); + c2 = _mm256_add_epi16(c2, c4); + _mm_storeu_si128((__m128i *)&output_soa[0 * size * size + i * size + j], + ymm_cvtusepi16_epi8(ymm_modq_epi15(c0))); + _mm_storeu_si128((__m128i *)&output_soa[1 * size * size + i * size + j], + ymm_cvtusepi16_epi8(ymm_modq_epi15(c1))); + _mm_storeu_si128((__m128i *)&output_soa[2 * size * size + i * size + j], + ymm_cvtusepi16_epi8(ymm_modq_epi15(c2))); + } + } +} +#elif QRUOV_L == 10 +static void matmulfql10_symmetric_upper_impl(uint8_t *output_soa, const uint8_t *vector_soa, int size) +{ + assert(size % 16 == 0); + for (int i = 0; i < size; i++) { + __m256i a[QRUOV_L]; + for (int l = 0; l < QRUOV_L; l++) { + a[l] = _mm256_set1_epi16(vector_soa[l * size + i]); + } + for (int j = i & ~15; j < size; j += 16) { + __m256i b[QRUOV_L]; + __m256i c[2 * QRUOV_L - 1]; + for (int l = 0; l < QRUOV_L; l++) { + b[l] = _mm256_cvtepi8_epi16(_mm_loadu_si128((const __m128i *)&vector_soa[l * size + j])); + } + for (int l = 0; l < 2 * QRUOV_L - 1; l++) { + c[l] = _mm256_setzero_si256(); + } + for (int l = 0; l < QRUOV_L; l++) { + for (int m = 0; m < QRUOV_L; m++) { +#if QRUOV_q == 127 + const __m256i prod = _mm256_mullo_epi16(a[l], b[m]); + c[l + m] = ymm_modq_epi15(_mm256_add_epi16(c[l + m], prod)); +#else + c[l + m] = _mm256_add_epi16(c[l + m], _mm256_mullo_epi16(a[l], b[m])); +#endif + } + } +#if QRUOV_q == 127 || QRUOV_q == 31 + for (int l = 2 * QRUOV_L - 2; l >= QRUOV_L - 1; l--) { + c[l] = ymm_reduceq_epi16(c[l]); + } +#endif + for (int t = 2 * QRUOV_L - 2; t >= QRUOV_L; t--) { + for (int n = 0; n < QRUOV_fc0; n++) { + c[t - QRUOV_L] = _mm256_add_epi16(c[t - QRUOV_L], c[t]); + } + for (int n = 0; n < QRUOV_fc; n++) { + c[t - QRUOV_L + QRUOV_fe] = _mm256_add_epi16(c[t - QRUOV_L + QRUOV_fe], c[t]); + } + } + for (int l = 0; l < QRUOV_L; l++) { + _mm_storeu_si128((__m128i *)&output_soa[l * size * size + i * size + j], + ymm_cvtusepi16_epi8(ymm_modq_epi15(c[l]))); + } + } + } +} +#else +#error "Unsupported QRUOV_L" +#endif + +void matmulfql_symmetric_upper(uint8_t *output_soa, const uint8_t *vector_soa, int size) +{ +#if QRUOV_L == 3 + matmulfql3_symmetric_upper_impl(output_soa, vector_soa, size); +#elif QRUOV_L == 10 + matmulfql10_symmetric_upper_impl(output_soa, vector_soa, size); +#else +#error "Unsupported QRUOV_L" +#endif +} + +#if QRUOV_L == 3 + +static void matmulfql3_vnni_1x8_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_8(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_8(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_8(&Bvnni[k * incB + 2 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + c0 = ymm_dot_u8s8(c0, a0, b0); + c1 = ymm_dot_u8s8(c1, a0, b1); + c1 = ymm_dot_u8s8(c1, a1, b0); + c2 = ymm_dot_u8s8(c2, a0, b2); + c2 = ymm_dot_u8s8(c2, a1, b1); + c2 = ymm_dot_u8s8(c2, a2, b0); + c3 = ymm_dot_u8s8(c3, a1, b2); + c3 = ymm_dot_u8s8(c3, a2, b1); + c4 = ymm_dot_u8s8(c4, a2, b2); + } + + c0 = _mm256_add_epi32(c0, c3); + c1 = _mm256_add_epi32(c1, c3); + c1 = _mm256_add_epi32(c1, c4); + c2 = _mm256_add_epi32(c2, c4); + store_row_8_epi32(&out[0 * incLout], c0); + store_row_8_epi32(&out[1 * incLout], c1); + store_row_8_epi32(&out[2 * incLout], c2); +} + +static void matmulfql3_vnni_1x7_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_7(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_7(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_7(&Bvnni[k * incB + 2 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + c0 = ymm_dot_u8s8(c0, a0, b0); + c1 = ymm_dot_u8s8(c1, a0, b1); + c1 = ymm_dot_u8s8(c1, a1, b0); + c2 = ymm_dot_u8s8(c2, a0, b2); + c2 = ymm_dot_u8s8(c2, a1, b1); + c2 = ymm_dot_u8s8(c2, a2, b0); + c3 = ymm_dot_u8s8(c3, a1, b2); + c3 = ymm_dot_u8s8(c3, a2, b1); + c4 = ymm_dot_u8s8(c4, a2, b2); + } + + c0 = _mm256_add_epi32(c0, c3); + c1 = _mm256_add_epi32(c1, c3); + c1 = _mm256_add_epi32(c1, c4); + c2 = _mm256_add_epi32(c2, c4); + store_row_7_epi32(&out[0 * incLout], c0); + store_row_7_epi32(&out[1 * incLout], c1); + store_row_7_epi32(&out[2 * incLout], c2); +} + +static void matmulfql3_vnni_1x6_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_6(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_6(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_6(&Bvnni[k * incB + 2 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + c0 = ymm_dot_u8s8(c0, a0, b0); + c1 = ymm_dot_u8s8(c1, a0, b1); + c1 = ymm_dot_u8s8(c1, a1, b0); + c2 = ymm_dot_u8s8(c2, a0, b2); + c2 = ymm_dot_u8s8(c2, a1, b1); + c2 = ymm_dot_u8s8(c2, a2, b0); + c3 = ymm_dot_u8s8(c3, a1, b2); + c3 = ymm_dot_u8s8(c3, a2, b1); + c4 = ymm_dot_u8s8(c4, a2, b2); + } + + c0 = _mm256_add_epi32(c0, c3); + c1 = _mm256_add_epi32(c1, c3); + c1 = _mm256_add_epi32(c1, c4); + c2 = _mm256_add_epi32(c2, c4); + store_row_6_epi32(&out[0 * incLout], c0); + store_row_6_epi32(&out[1 * incLout], c1); + store_row_6_epi32(&out[2 * incLout], c2); +} + +static void matmulfql3_vnni_1x4_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + + int k = 0; + for (; k + 8 <= K; k += 8) { + __m256i b0 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 0 * incLB], + &Bvnni[(k + 4) * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 1 * incLB], + &Bvnni[(k + 4) * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 2 * incLB], + &Bvnni[(k + 4) * incB + 2 * incLB]); + __m256i a0 = _mm256_set1_epi64x((long long)load_u64(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi64x((long long)load_u64(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi64x((long long)load_u64(&A[k + 2 * incLA])); + c0 = ymm_dot_u8s8(c0, a0, b0); + c1 = ymm_dot_u8s8(c1, a0, b1); + c1 = ymm_dot_u8s8(c1, a1, b0); + c2 = ymm_dot_u8s8(c2, a0, b2); + c2 = ymm_dot_u8s8(c2, a1, b1); + c2 = ymm_dot_u8s8(c2, a2, b0); + c3 = ymm_dot_u8s8(c3, a1, b2); + c3 = ymm_dot_u8s8(c3, a2, b1); + c4 = ymm_dot_u8s8(c4, a2, b2); + } + for (; k < K; k += 4) { + __m256i b0 = load_row_vnni_4x1(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_4x1(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_4x1(&Bvnni[k * incB + 2 * incLB]); + __m256i a0 = _mm256_set1_epi64x((long long)load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi64x((long long)load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi64x((long long)load_u32(&A[k + 2 * incLA])); + c0 = ymm_dot_u8s8(c0, a0, b0); + c1 = ymm_dot_u8s8(c1, a0, b1); + c1 = ymm_dot_u8s8(c1, a1, b0); + c2 = ymm_dot_u8s8(c2, a0, b2); + c2 = ymm_dot_u8s8(c2, a1, b1); + c2 = ymm_dot_u8s8(c2, a2, b0); + c3 = ymm_dot_u8s8(c3, a1, b2); + c3 = ymm_dot_u8s8(c3, a2, b1); + c4 = ymm_dot_u8s8(c4, a2, b2); + } + + c0 = _mm256_add_epi32(c0, c3); + c1 = _mm256_add_epi32(c1, c3); + c1 = _mm256_add_epi32(c1, c4); + c2 = _mm256_add_epi32(c2, c4); + store_row_4_pair_epi32(&out[0 * incLout], c0); + store_row_4_pair_epi32(&out[1 * incLout], c1); + store_row_4_pair_epi32(&out[2 * incLout], c2); +} + +#elif QRUOV_L == 10 + +#define DOT_ACC(dst, a, b) dst = ymm_dot_u8s8(dst, a, b) + +#define MATMULFQL10_DOT_BODY \ + DOT_ACC(c0, a0, b0); \ + DOT_ACC(c1, a0, b1); DOT_ACC(c1, a1, b0); \ + DOT_ACC(c2, a0, b2); DOT_ACC(c2, a1, b1); DOT_ACC(c2, a2, b0); \ + DOT_ACC(c3, a0, b3); DOT_ACC(c3, a1, b2); DOT_ACC(c3, a2, b1); DOT_ACC(c3, a3, b0); \ + DOT_ACC(c4, a0, b4); DOT_ACC(c4, a1, b3); DOT_ACC(c4, a2, b2); DOT_ACC(c4, a3, b1); DOT_ACC(c4, a4, b0); \ + DOT_ACC(c5, a0, b5); DOT_ACC(c5, a1, b4); DOT_ACC(c5, a2, b3); DOT_ACC(c5, a3, b2); DOT_ACC(c5, a4, b1); DOT_ACC(c5, a5, b0); \ + DOT_ACC(c6, a0, b6); DOT_ACC(c6, a1, b5); DOT_ACC(c6, a2, b4); DOT_ACC(c6, a3, b3); DOT_ACC(c6, a4, b2); DOT_ACC(c6, a5, b1); DOT_ACC(c6, a6, b0); \ + DOT_ACC(c7, a0, b7); DOT_ACC(c7, a1, b6); DOT_ACC(c7, a2, b5); DOT_ACC(c7, a3, b4); DOT_ACC(c7, a4, b3); DOT_ACC(c7, a5, b2); DOT_ACC(c7, a6, b1); DOT_ACC(c7, a7, b0); \ + DOT_ACC(c8, a0, b8); DOT_ACC(c8, a1, b7); DOT_ACC(c8, a2, b6); DOT_ACC(c8, a3, b5); DOT_ACC(c8, a4, b4); DOT_ACC(c8, a5, b3); DOT_ACC(c8, a6, b2); DOT_ACC(c8, a7, b1); DOT_ACC(c8, a8, b0); \ + DOT_ACC(c9, a0, b9); DOT_ACC(c9, a1, b8); DOT_ACC(c9, a2, b7); DOT_ACC(c9, a3, b6); DOT_ACC(c9, a4, b5); DOT_ACC(c9, a5, b4); DOT_ACC(c9, a6, b3); DOT_ACC(c9, a7, b2); DOT_ACC(c9, a8, b1); DOT_ACC(c9, a9, b0); \ + DOT_ACC(c10, a1, b9); DOT_ACC(c10, a2, b8); DOT_ACC(c10, a3, b7); DOT_ACC(c10, a4, b6); DOT_ACC(c10, a5, b5); DOT_ACC(c10, a6, b4); DOT_ACC(c10, a7, b3); DOT_ACC(c10, a8, b2); DOT_ACC(c10, a9, b1); \ + DOT_ACC(c11, a2, b9); DOT_ACC(c11, a3, b8); DOT_ACC(c11, a4, b7); DOT_ACC(c11, a5, b6); DOT_ACC(c11, a6, b5); DOT_ACC(c11, a7, b4); DOT_ACC(c11, a8, b3); DOT_ACC(c11, a9, b2); \ + DOT_ACC(c12, a3, b9); DOT_ACC(c12, a4, b8); DOT_ACC(c12, a5, b7); DOT_ACC(c12, a6, b6); DOT_ACC(c12, a7, b5); DOT_ACC(c12, a8, b4); DOT_ACC(c12, a9, b3); \ + DOT_ACC(c13, a4, b9); DOT_ACC(c13, a5, b8); DOT_ACC(c13, a6, b7); DOT_ACC(c13, a7, b6); DOT_ACC(c13, a8, b5); DOT_ACC(c13, a9, b4); \ + DOT_ACC(c14, a5, b9); DOT_ACC(c14, a6, b8); DOT_ACC(c14, a7, b7); DOT_ACC(c14, a8, b6); DOT_ACC(c14, a9, b5); \ + DOT_ACC(c15, a6, b9); DOT_ACC(c15, a7, b8); DOT_ACC(c15, a8, b7); DOT_ACC(c15, a9, b6); \ + DOT_ACC(c16, a7, b9); DOT_ACC(c16, a8, b8); DOT_ACC(c16, a9, b7); \ + DOT_ACC(c17, a8, b9); DOT_ACC(c17, a9, b8); \ + DOT_ACC(c18, a9, b9) + +#if QRUOV_q == 7 +#define MATMULFQL10_FOLD_BODY \ + ADD1(c0, c10); ADD2(c1, c10); \ + ADD1(c1, c11); ADD2(c2, c11); \ + ADD1(c2, c12); ADD2(c3, c12); \ + ADD1(c3, c13); ADD2(c4, c13); \ + ADD1(c4, c14); ADD2(c5, c14); \ + ADD1(c5, c15); ADD2(c6, c15); \ + ADD1(c6, c16); ADD2(c7, c16); \ + ADD1(c7, c17); ADD2(c8, c17); \ + ADD1(c8, c18); ADD2(c9, c18) +#elif QRUOV_q == 31 +#define MATMULFQL10_FOLD_BODY \ + ADD1(c0, c10); ADD5(c3, c10); ADD25(c3, c17); \ + ADD1(c1, c11); ADD5(c4, c11); ADD25(c4, c18); \ + ADD1(c2, c12); ADD5(c5, c12); \ + ADD1(c3, c13); ADD5(c6, c13); \ + ADD1(c4, c14); ADD5(c7, c14); \ + ADD1(c5, c15); ADD5(c8, c15); \ + ADD1(c6, c16); ADD5(c9, c16); \ + ADD1(c7, c17); ADD5(c0, c17); \ + ADD1(c8, c18); ADD5(c1, c18) +#elif QRUOV_q == 127 +#define MATMULFQL10_FOLD_BODY \ + ADD2(c10, c17); ADD2(c11, c18); \ + ADD1(c0, c10); ADD2(c3, c10); \ + ADD1(c1, c11); ADD2(c4, c11); \ + ADD1(c2, c12); ADD2(c5, c12); \ + ADD1(c3, c13); ADD2(c6, c13); \ + ADD1(c4, c14); ADD2(c7, c14); \ + ADD1(c5, c15); ADD2(c8, c15); \ + ADD1(c6, c16); ADD2(c9, c16); \ + ADD1(c7, c17); \ + ADD1(c8, c18) +#else +#error "Unsupported QRUOV_q for QRUOV_L == 10" +#endif + +static void matmulfql10_vnni_1x4_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + __m256i c5 = _mm256_setzero_si256(); + __m256i c6 = _mm256_setzero_si256(); + __m256i c7 = _mm256_setzero_si256(); + __m256i c8 = _mm256_setzero_si256(); + __m256i c9 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c12 = _mm256_setzero_si256(); + __m256i c13 = _mm256_setzero_si256(); + __m256i c14 = _mm256_setzero_si256(); + __m256i c15 = _mm256_setzero_si256(); + __m256i c16 = _mm256_setzero_si256(); + __m256i c17 = _mm256_setzero_si256(); + __m256i c18 = _mm256_setzero_si256(); + + int k = 0; + for (; k + 8 <= K; k += 8) { + __m256i b0 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 0 * incLB], + &Bvnni[(k + 4) * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 1 * incLB], + &Bvnni[(k + 4) * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 2 * incLB], + &Bvnni[(k + 4) * incB + 2 * incLB]); + __m256i b3 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 3 * incLB], + &Bvnni[(k + 4) * incB + 3 * incLB]); + __m256i b4 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 4 * incLB], + &Bvnni[(k + 4) * incB + 4 * incLB]); + __m256i b5 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 5 * incLB], + &Bvnni[(k + 4) * incB + 5 * incLB]); + __m256i b6 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 6 * incLB], + &Bvnni[(k + 4) * incB + 6 * incLB]); + __m256i b7 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 7 * incLB], + &Bvnni[(k + 4) * incB + 7 * incLB]); + __m256i b8 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 8 * incLB], + &Bvnni[(k + 4) * incB + 8 * incLB]); + __m256i b9 = load_row_vnni_4x2(&Bvnni[(k + 0) * incB + 9 * incLB], + &Bvnni[(k + 4) * incB + 9 * incLB]); + __m256i a0 = _mm256_set1_epi64x((long long)load_u64(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi64x((long long)load_u64(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi64x((long long)load_u64(&A[k + 2 * incLA])); + __m256i a3 = _mm256_set1_epi64x((long long)load_u64(&A[k + 3 * incLA])); + __m256i a4 = _mm256_set1_epi64x((long long)load_u64(&A[k + 4 * incLA])); + __m256i a5 = _mm256_set1_epi64x((long long)load_u64(&A[k + 5 * incLA])); + __m256i a6 = _mm256_set1_epi64x((long long)load_u64(&A[k + 6 * incLA])); + __m256i a7 = _mm256_set1_epi64x((long long)load_u64(&A[k + 7 * incLA])); + __m256i a8 = _mm256_set1_epi64x((long long)load_u64(&A[k + 8 * incLA])); + __m256i a9 = _mm256_set1_epi64x((long long)load_u64(&A[k + 9 * incLA])); + MATMULFQL10_DOT_BODY; + } + for (; k < K; k += 4) { + __m256i b0 = load_row_vnni_4x1(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_4x1(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_4x1(&Bvnni[k * incB + 2 * incLB]); + __m256i b3 = load_row_vnni_4x1(&Bvnni[k * incB + 3 * incLB]); + __m256i b4 = load_row_vnni_4x1(&Bvnni[k * incB + 4 * incLB]); + __m256i b5 = load_row_vnni_4x1(&Bvnni[k * incB + 5 * incLB]); + __m256i b6 = load_row_vnni_4x1(&Bvnni[k * incB + 6 * incLB]); + __m256i b7 = load_row_vnni_4x1(&Bvnni[k * incB + 7 * incLB]); + __m256i b8 = load_row_vnni_4x1(&Bvnni[k * incB + 8 * incLB]); + __m256i b9 = load_row_vnni_4x1(&Bvnni[k * incB + 9 * incLB]); + __m256i a0 = _mm256_set1_epi64x((long long)load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi64x((long long)load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi64x((long long)load_u32(&A[k + 2 * incLA])); + __m256i a3 = _mm256_set1_epi64x((long long)load_u32(&A[k + 3 * incLA])); + __m256i a4 = _mm256_set1_epi64x((long long)load_u32(&A[k + 4 * incLA])); + __m256i a5 = _mm256_set1_epi64x((long long)load_u32(&A[k + 5 * incLA])); + __m256i a6 = _mm256_set1_epi64x((long long)load_u32(&A[k + 6 * incLA])); + __m256i a7 = _mm256_set1_epi64x((long long)load_u32(&A[k + 7 * incLA])); + __m256i a8 = _mm256_set1_epi64x((long long)load_u32(&A[k + 8 * incLA])); + __m256i a9 = _mm256_set1_epi64x((long long)load_u32(&A[k + 9 * incLA])); + MATMULFQL10_DOT_BODY; + } + MATMULFQL10_FOLD_BODY; + store_row_4_pair_epi32(&out[0 * incLout], c0); + store_row_4_pair_epi32(&out[1 * incLout], c1); + store_row_4_pair_epi32(&out[2 * incLout], c2); + store_row_4_pair_epi32(&out[3 * incLout], c3); + store_row_4_pair_epi32(&out[4 * incLout], c4); + store_row_4_pair_epi32(&out[5 * incLout], c5); + store_row_4_pair_epi32(&out[6 * incLout], c6); + store_row_4_pair_epi32(&out[7 * incLout], c7); + store_row_4_pair_epi32(&out[8 * incLout], c8); + store_row_4_pair_epi32(&out[9 * incLout], c9); +} + +static void matmulfql10_vnni_1x8_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + __m256i c5 = _mm256_setzero_si256(); + __m256i c6 = _mm256_setzero_si256(); + __m256i c7 = _mm256_setzero_si256(); + __m256i c8 = _mm256_setzero_si256(); + __m256i c9 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c12 = _mm256_setzero_si256(); + __m256i c13 = _mm256_setzero_si256(); + __m256i c14 = _mm256_setzero_si256(); + __m256i c15 = _mm256_setzero_si256(); + __m256i c16 = _mm256_setzero_si256(); + __m256i c17 = _mm256_setzero_si256(); + __m256i c18 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_8(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_8(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_8(&Bvnni[k * incB + 2 * incLB]); + __m256i b3 = load_row_vnni_8(&Bvnni[k * incB + 3 * incLB]); + __m256i b4 = load_row_vnni_8(&Bvnni[k * incB + 4 * incLB]); + __m256i b5 = load_row_vnni_8(&Bvnni[k * incB + 5 * incLB]); + __m256i b6 = load_row_vnni_8(&Bvnni[k * incB + 6 * incLB]); + __m256i b7 = load_row_vnni_8(&Bvnni[k * incB + 7 * incLB]); + __m256i b8 = load_row_vnni_8(&Bvnni[k * incB + 8 * incLB]); + __m256i b9 = load_row_vnni_8(&Bvnni[k * incB + 9 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[k + 3 * incLA])); + __m256i a4 = _mm256_set1_epi32(load_u32(&A[k + 4 * incLA])); + __m256i a5 = _mm256_set1_epi32(load_u32(&A[k + 5 * incLA])); + __m256i a6 = _mm256_set1_epi32(load_u32(&A[k + 6 * incLA])); + __m256i a7 = _mm256_set1_epi32(load_u32(&A[k + 7 * incLA])); + __m256i a8 = _mm256_set1_epi32(load_u32(&A[k + 8 * incLA])); + __m256i a9 = _mm256_set1_epi32(load_u32(&A[k + 9 * incLA])); + MATMULFQL10_DOT_BODY; + } + MATMULFQL10_FOLD_BODY; + store_row_8_epi32(&out[0 * incLout], c0); + store_row_8_epi32(&out[1 * incLout], c1); + store_row_8_epi32(&out[2 * incLout], c2); + store_row_8_epi32(&out[3 * incLout], c3); + store_row_8_epi32(&out[4 * incLout], c4); + store_row_8_epi32(&out[5 * incLout], c5); + store_row_8_epi32(&out[6 * incLout], c6); + store_row_8_epi32(&out[7 * incLout], c7); + store_row_8_epi32(&out[8 * incLout], c8); + store_row_8_epi32(&out[9 * incLout], c9); +} + +static void matmulfql10_vnni_1x7_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + __m256i c5 = _mm256_setzero_si256(); + __m256i c6 = _mm256_setzero_si256(); + __m256i c7 = _mm256_setzero_si256(); + __m256i c8 = _mm256_setzero_si256(); + __m256i c9 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c12 = _mm256_setzero_si256(); + __m256i c13 = _mm256_setzero_si256(); + __m256i c14 = _mm256_setzero_si256(); + __m256i c15 = _mm256_setzero_si256(); + __m256i c16 = _mm256_setzero_si256(); + __m256i c17 = _mm256_setzero_si256(); + __m256i c18 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_7(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_7(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_7(&Bvnni[k * incB + 2 * incLB]); + __m256i b3 = load_row_vnni_7(&Bvnni[k * incB + 3 * incLB]); + __m256i b4 = load_row_vnni_7(&Bvnni[k * incB + 4 * incLB]); + __m256i b5 = load_row_vnni_7(&Bvnni[k * incB + 5 * incLB]); + __m256i b6 = load_row_vnni_7(&Bvnni[k * incB + 6 * incLB]); + __m256i b7 = load_row_vnni_7(&Bvnni[k * incB + 7 * incLB]); + __m256i b8 = load_row_vnni_7(&Bvnni[k * incB + 8 * incLB]); + __m256i b9 = load_row_vnni_7(&Bvnni[k * incB + 9 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[k + 3 * incLA])); + __m256i a4 = _mm256_set1_epi32(load_u32(&A[k + 4 * incLA])); + __m256i a5 = _mm256_set1_epi32(load_u32(&A[k + 5 * incLA])); + __m256i a6 = _mm256_set1_epi32(load_u32(&A[k + 6 * incLA])); + __m256i a7 = _mm256_set1_epi32(load_u32(&A[k + 7 * incLA])); + __m256i a8 = _mm256_set1_epi32(load_u32(&A[k + 8 * incLA])); + __m256i a9 = _mm256_set1_epi32(load_u32(&A[k + 9 * incLA])); + MATMULFQL10_DOT_BODY; + } + MATMULFQL10_FOLD_BODY; + store_row_7_epi32(&out[0 * incLout], c0); + store_row_7_epi32(&out[1 * incLout], c1); + store_row_7_epi32(&out[2 * incLout], c2); + store_row_7_epi32(&out[3 * incLout], c3); + store_row_7_epi32(&out[4 * incLout], c4); + store_row_7_epi32(&out[5 * incLout], c5); + store_row_7_epi32(&out[6 * incLout], c6); + store_row_7_epi32(&out[7 * incLout], c7); + store_row_7_epi32(&out[8 * incLout], c8); + store_row_7_epi32(&out[9 * incLout], c9); +} + +static void matmulfql10_vnni_1x6_impl(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout __attribute__((unused)), int incA __attribute__((unused)), int incB, + int incLout, int incLA, int incLB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + __m256i c4 = _mm256_setzero_si256(); + __m256i c5 = _mm256_setzero_si256(); + __m256i c6 = _mm256_setzero_si256(); + __m256i c7 = _mm256_setzero_si256(); + __m256i c8 = _mm256_setzero_si256(); + __m256i c9 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c12 = _mm256_setzero_si256(); + __m256i c13 = _mm256_setzero_si256(); + __m256i c14 = _mm256_setzero_si256(); + __m256i c15 = _mm256_setzero_si256(); + __m256i c16 = _mm256_setzero_si256(); + __m256i c17 = _mm256_setzero_si256(); + __m256i c18 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0 = load_row_vnni_6(&Bvnni[k * incB + 0 * incLB]); + __m256i b1 = load_row_vnni_6(&Bvnni[k * incB + 1 * incLB]); + __m256i b2 = load_row_vnni_6(&Bvnni[k * incB + 2 * incLB]); + __m256i b3 = load_row_vnni_6(&Bvnni[k * incB + 3 * incLB]); + __m256i b4 = load_row_vnni_6(&Bvnni[k * incB + 4 * incLB]); + __m256i b5 = load_row_vnni_6(&Bvnni[k * incB + 5 * incLB]); + __m256i b6 = load_row_vnni_6(&Bvnni[k * incB + 6 * incLB]); + __m256i b7 = load_row_vnni_6(&Bvnni[k * incB + 7 * incLB]); + __m256i b8 = load_row_vnni_6(&Bvnni[k * incB + 8 * incLB]); + __m256i b9 = load_row_vnni_6(&Bvnni[k * incB + 9 * incLB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[k + 0 * incLA])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[k + 1 * incLA])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[k + 2 * incLA])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[k + 3 * incLA])); + __m256i a4 = _mm256_set1_epi32(load_u32(&A[k + 4 * incLA])); + __m256i a5 = _mm256_set1_epi32(load_u32(&A[k + 5 * incLA])); + __m256i a6 = _mm256_set1_epi32(load_u32(&A[k + 6 * incLA])); + __m256i a7 = _mm256_set1_epi32(load_u32(&A[k + 7 * incLA])); + __m256i a8 = _mm256_set1_epi32(load_u32(&A[k + 8 * incLA])); + __m256i a9 = _mm256_set1_epi32(load_u32(&A[k + 9 * incLA])); + MATMULFQL10_DOT_BODY; + } + MATMULFQL10_FOLD_BODY; + store_row_6_epi32(&out[0 * incLout], c0); + store_row_6_epi32(&out[1 * incLout], c1); + store_row_6_epi32(&out[2 * incLout], c2); + store_row_6_epi32(&out[3 * incLout], c3); + store_row_6_epi32(&out[4 * incLout], c4); + store_row_6_epi32(&out[5 * incLout], c5); + store_row_6_epi32(&out[6 * incLout], c6); + store_row_6_epi32(&out[7 * incLout], c7); + store_row_6_epi32(&out[8 * incLout], c8); + store_row_6_epi32(&out[9 * incLout], c9); +} + +#undef MATMULFQL10_DOT_BODY +#undef MATMULFQL10_FOLD_BODY +#undef DOT_ACC + +#else +#error "Unsupported QRUOV_L" +#endif + +void matmulfql_vnni_1x8(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB) +{ +#if QRUOV_L == 3 + matmulfql3_vnni_1x8_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#elif QRUOV_L == 10 + matmulfql10_vnni_1x8_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#else +#error "Unsupported QRUOV_L" +#endif +} + +void matmulfql_vnni_1x7(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB) +{ +#if QRUOV_L == 3 + matmulfql3_vnni_1x7_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#elif QRUOV_L == 10 + matmulfql10_vnni_1x7_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#else +#error "Unsupported QRUOV_L" +#endif +} + +void matmulfql_vnni_1x6(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB) +{ +#if QRUOV_L == 3 + matmulfql3_vnni_1x6_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#elif QRUOV_L == 10 + matmulfql10_vnni_1x6_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#else +#error "Unsupported QRUOV_L" +#endif +} + +void matmulfql_vnni_1x4(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB) +{ +#if QRUOV_L == 3 + matmulfql3_vnni_1x4_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#elif QRUOV_L == 10 + matmulfql10_vnni_1x4_impl(out, A, Bvnni, K, incout, incA, incB, incLout, incLA, incLB); +#else +#error "Unsupported QRUOV_L" +#endif +} + +#if QRUOV_q != 7 && QRUOV_q != 31 +static void matmulfq_vnni_4x16_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c00 = _mm256_setzero_si256(); + __m256i c01 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c20 = _mm256_setzero_si256(); + __m256i c21 = _mm256_setzero_si256(); + __m256i c30 = _mm256_setzero_si256(); + __m256i c31 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0, b1; + load_row_vnni_16(&b0, &b1, &B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c00 = ymm_dot_u8s8(c00, a0, b0); + c01 = ymm_dot_u8s8(c01, a0, b1); + c10 = ymm_dot_u8s8(c10, a1, b0); + c11 = ymm_dot_u8s8(c11, a1, b1); + c20 = ymm_dot_u8s8(c20, a2, b0); + c21 = ymm_dot_u8s8(c21, a2, b1); + c30 = ymm_dot_u8s8(c30, a3, b0); + c31 = ymm_dot_u8s8(c31, a3, b1); + } + + store_row_16_epi32(&out[0 * incout], c00, c01); + store_row_16_epi32(&out[1 * incout], c10, c11); + store_row_16_epi32(&out[2 * incout], c20, c21); + store_row_16_epi32(&out[3 * incout], c30, c31); +} +#endif + +#if QRUOV_q == 7 +// q=7 can keep maddubs pair-sums in 16-bit lanes and reduce mod 7 at the end. +static void matmulfq7_vnni_4x16_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c00 = _mm256_setzero_si256(); + __m256i c01 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c20 = _mm256_setzero_si256(); + __m256i c21 = _mm256_setzero_si256(); + __m256i c30 = _mm256_setzero_si256(); + __m256i c31 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b0, b1; + load_row_vnni_16(&b0, &b1, &B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c00 = _mm256_add_epi16(c00, _mm256_maddubs_epi16(a0, b0)); + c01 = _mm256_add_epi16(c01, _mm256_maddubs_epi16(a0, b1)); + c10 = _mm256_add_epi16(c10, _mm256_maddubs_epi16(a1, b0)); + c11 = _mm256_add_epi16(c11, _mm256_maddubs_epi16(a1, b1)); + c20 = _mm256_add_epi16(c20, _mm256_maddubs_epi16(a2, b0)); + c21 = _mm256_add_epi16(c21, _mm256_maddubs_epi16(a2, b1)); + c30 = _mm256_add_epi16(c30, _mm256_maddubs_epi16(a3, b0)); + c31 = _mm256_add_epi16(c31, _mm256_maddubs_epi16(a3, b1)); + } + + store_row_16_hadd_epi16(&out[0 * incout], c00, c01); + store_row_16_hadd_epi16(&out[1 * incout], c10, c11); + store_row_16_hadd_epi16(&out[2 * incout], c20, c21); + store_row_16_hadd_epi16(&out[3 * incout], c30, c31); +} +#elif QRUOV_q == 31 + +// q=31 uses the unsafe grouped dot paths; even the 4-way case stays below +// the signed 16-bit lane limit: 4 * 2 * (31 - 1)^2 = 7200. +static void matmulfq31_vnni_4x16_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c00 = _mm256_setzero_si256(); + __m256i c01 = _mm256_setzero_si256(); + __m256i c10 = _mm256_setzero_si256(); + __m256i c11 = _mm256_setzero_si256(); + __m256i c20 = _mm256_setzero_si256(); + __m256i c21 = _mm256_setzero_si256(); + __m256i c30 = _mm256_setzero_si256(); + __m256i c31 = _mm256_setzero_si256(); + + int k = 0; + for (; k + 8 <= K; k += 8) { + __m256i b00, b01, b40, b41; + load_row_vnni_16(&b00, &b01, &B[((k >> 2) + 0) * incB]); + load_row_vnni_16(&b40, &b41, &B[((k >> 2) + 1) * incB]); + __m256i a00 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 0])); + __m256i a04 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 4])); + __m256i a10 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 0])); + __m256i a14 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 4])); + __m256i a20 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 0])); + __m256i a24 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 4])); + __m256i a30 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 0])); + __m256i a34 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 4])); + c00 = ymm2_dot_u8s8_unsafe(c00, a00, b00, a04, b40); + c01 = ymm2_dot_u8s8_unsafe(c01, a00, b01, a04, b41); + c10 = ymm2_dot_u8s8_unsafe(c10, a10, b00, a14, b40); + c11 = ymm2_dot_u8s8_unsafe(c11, a10, b01, a14, b41); + c20 = ymm2_dot_u8s8_unsafe(c20, a20, b00, a24, b40); + c21 = ymm2_dot_u8s8_unsafe(c21, a20, b01, a24, b41); + c30 = ymm2_dot_u8s8_unsafe(c30, a30, b00, a34, b40); + c31 = ymm2_dot_u8s8_unsafe(c31, a30, b01, a34, b41); + } + + for (; k < K; k += 4) { + __m256i b0, b1; + load_row_vnni_16(&b0, &b1, &B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c00 = ymm_dot_u8s8(c00, a0, b0); + c01 = ymm_dot_u8s8(c01, a0, b1); + c10 = ymm_dot_u8s8(c10, a1, b0); + c11 = ymm_dot_u8s8(c11, a1, b1); + c20 = ymm_dot_u8s8(c20, a2, b0); + c21 = ymm_dot_u8s8(c21, a2, b1); + c30 = ymm_dot_u8s8(c30, a3, b0); + c31 = ymm_dot_u8s8(c31, a3, b1); + } + + store_row_16_epi32(&out[0 * incout], c00, c01); + store_row_16_epi32(&out[1 * incout], c10, c11); + store_row_16_epi32(&out[2 * incout], c20, c21); + store_row_16_epi32(&out[3 * incout], c30, c31); +} +#endif + +void matmulfq_vnni_4x16(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ +#if QRUOV_q == 7 + matmulfq7_vnni_4x16_impl(out, A, B, K, incout, incA, incB); +#elif QRUOV_q == 31 + matmulfq31_vnni_4x16_impl(out, A, B, K, incout, incA, incB); +#else + matmulfq_vnni_4x16_impl(out, A, B, K, incout, incA, incB); +#endif +} + +#if QRUOV_q != 7 && QRUOV_q != 31 +static void matmulfq_vnni_4x8_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b = load_row_vnni_8(&B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c0 = ymm_dot_u8s8(c0, a0, b); + c1 = ymm_dot_u8s8(c1, a1, b); + c2 = ymm_dot_u8s8(c2, a2, b); + c3 = ymm_dot_u8s8(c3, a3, b); + } + + store_row_8_epi32(&out[0 * incout], c0); + store_row_8_epi32(&out[1 * incout], c1); + store_row_8_epi32(&out[2 * incout], c2); + store_row_8_epi32(&out[3 * incout], c3); +} +#endif + +#if QRUOV_q == 7 +static void matmulfq7_vnni_4x8_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b = load_row_vnni_8(&B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c0 = _mm256_add_epi16(c0, _mm256_maddubs_epi16(a0, b)); + c1 = _mm256_add_epi16(c1, _mm256_maddubs_epi16(a1, b)); + c2 = _mm256_add_epi16(c2, _mm256_maddubs_epi16(a2, b)); + c3 = _mm256_add_epi16(c3, _mm256_maddubs_epi16(a3, b)); + } + + store_row_8_hadd_epi16(&out[0 * incout], c0); + store_row_8_hadd_epi16(&out[1 * incout], c1); + store_row_8_hadd_epi16(&out[2 * incout], c2); + store_row_8_hadd_epi16(&out[3 * incout], c3); +} +#elif QRUOV_q == 31 +static void matmulfq31_vnni_4x8_impl(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + + int k = 0; + for (; k + 16 <= K; k += 16) { + __m256i b0 = load_row_vnni_8(&B[((k >> 2) + 0) * incB]); + __m256i b1 = load_row_vnni_8(&B[((k >> 2) + 1) * incB]); + __m256i b2 = load_row_vnni_8(&B[((k >> 2) + 2) * incB]); + __m256i b3 = load_row_vnni_8(&B[((k >> 2) + 3) * incB]); + __m256i a00 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 0])); + __m256i a01 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 4])); + __m256i a02 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 8])); + __m256i a03 = _mm256_set1_epi32(load_u32(&A[0 * incA + k + 12])); + __m256i a10 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 0])); + __m256i a11 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 4])); + __m256i a12 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 8])); + __m256i a13 = _mm256_set1_epi32(load_u32(&A[1 * incA + k + 12])); + __m256i a20 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 0])); + __m256i a21 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 4])); + __m256i a22 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 8])); + __m256i a23 = _mm256_set1_epi32(load_u32(&A[2 * incA + k + 12])); + __m256i a30 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 0])); + __m256i a31 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 4])); + __m256i a32 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 8])); + __m256i a33 = _mm256_set1_epi32(load_u32(&A[3 * incA + k + 12])); + c0 = ymm4_dot_u8s8_unsafe(c0, a00, b0, a01, b1, a02, b2, a03, b3); + c1 = ymm4_dot_u8s8_unsafe(c1, a10, b0, a11, b1, a12, b2, a13, b3); + c2 = ymm4_dot_u8s8_unsafe(c2, a20, b0, a21, b1, a22, b2, a23, b3); + c3 = ymm4_dot_u8s8_unsafe(c3, a30, b0, a31, b1, a32, b2, a33, b3); + } + + for (; k < K; k += 4) { + __m256i b = load_row_vnni_8(&B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c0 = ymm_dot_u8s8(c0, a0, b); + c1 = ymm_dot_u8s8(c1, a1, b); + c2 = ymm_dot_u8s8(c2, a2, b); + c3 = ymm_dot_u8s8(c3, a3, b); + } + + store_row_8_epi32(&out[0 * incout], c0); + store_row_8_epi32(&out[1 * incout], c1); + store_row_8_epi32(&out[2 * incout], c2); + store_row_8_epi32(&out[3 * incout], c3); +} +#endif + +void matmulfq_vnni_4x8(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ +#if QRUOV_q == 7 + matmulfq7_vnni_4x8_impl(out, A, B, K, incout, incA, incB); +#elif QRUOV_q == 31 + matmulfq31_vnni_4x8_impl(out, A, B, K, incout, incA, incB); +#else + matmulfq_vnni_4x8_impl(out, A, B, K, incout, incA, incB); +#endif +} + +void matmulfq_vnni_4x7(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b = load_row_vnni_7(&B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c0 = ymm_dot_u8s8(c0, a0, b); + c1 = ymm_dot_u8s8(c1, a1, b); + c2 = ymm_dot_u8s8(c2, a2, b); + c3 = ymm_dot_u8s8(c3, a3, b); + } + + store_row_7_epi32(&out[0 * incout], c0); + store_row_7_epi32(&out[1 * incout], c1); + store_row_7_epi32(&out[2 * incout], c2); + store_row_7_epi32(&out[3 * incout], c3); +} + +void matmulfq_vnni_4x6(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + + for (int k = 0; k < K; k += 4) { + __m256i b = load_row_vnni_6(&B[(k >> 2) * incB]); + __m256i a0 = _mm256_set1_epi32(load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi32(load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi32(load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi32(load_u32(&A[3 * incA + k])); + c0 = ymm_dot_u8s8(c0, a0, b); + c1 = ymm_dot_u8s8(c1, a1, b); + c2 = ymm_dot_u8s8(c2, a2, b); + c3 = ymm_dot_u8s8(c3, a3, b); + } + + store_row_6_epi32(&out[0 * incout], c0); + store_row_6_epi32(&out[1 * incout], c1); + store_row_6_epi32(&out[2 * incout], c2); + store_row_6_epi32(&out[3 * incout], c3); +} + +void matmulfq_vnni_4x4(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, int incout, int incA, int incB) +{ + assert(K % 4 == 0); + __m256i c0 = _mm256_setzero_si256(); + __m256i c1 = _mm256_setzero_si256(); + __m256i c2 = _mm256_setzero_si256(); + __m256i c3 = _mm256_setzero_si256(); + const __m256i idx = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0); + + int k = 0; + for (; k + 16 <= K; k += 16) { + __m128i b00 = _mm_loadu_si128((const __m128i *)&B[((k >> 2) + 0) * incB]); + __m128i b04 = _mm_loadu_si128((const __m128i *)&B[((k >> 2) + 1) * incB]); + __m128i b08 = _mm_loadu_si128((const __m128i *)&B[((k >> 2) + 2) * incB]); + __m128i b12 = _mm_loadu_si128((const __m128i *)&B[((k >> 2) + 3) * incB]); + __m256i bk0 = _mm256_set_m128i(b04, b00); + __m256i bk1 = _mm256_set_m128i(b12, b08); + bk0 = _mm256_permutevar8x32_epi32(bk0, idx); + bk1 = _mm256_permutevar8x32_epi32(bk1, idx); + + __m256i a00 = _mm256_set1_epi64x((long long)load_u64(&A[0 * incA + k + 0])); + __m256i a01 = _mm256_set1_epi64x((long long)load_u64(&A[0 * incA + k + 8])); + __m256i a10 = _mm256_set1_epi64x((long long)load_u64(&A[1 * incA + k + 0])); + __m256i a11 = _mm256_set1_epi64x((long long)load_u64(&A[1 * incA + k + 8])); + __m256i a20 = _mm256_set1_epi64x((long long)load_u64(&A[2 * incA + k + 0])); + __m256i a21 = _mm256_set1_epi64x((long long)load_u64(&A[2 * incA + k + 8])); + __m256i a30 = _mm256_set1_epi64x((long long)load_u64(&A[3 * incA + k + 0])); + __m256i a31 = _mm256_set1_epi64x((long long)load_u64(&A[3 * incA + k + 8])); +#if QRUOV_q == 127 + c0 = ymm2_dot_u8s8(c0, a00, bk0, a01, bk1); + c1 = ymm2_dot_u8s8(c1, a10, bk0, a11, bk1); + c2 = ymm2_dot_u8s8(c2, a20, bk0, a21, bk1); + c3 = ymm2_dot_u8s8(c3, a30, bk0, a31, bk1); +#else + c0 = ymm2_dot_u8s8_unsafe(c0, a00, bk0, a01, bk1); + c1 = ymm2_dot_u8s8_unsafe(c1, a10, bk0, a11, bk1); + c2 = ymm2_dot_u8s8_unsafe(c2, a20, bk0, a21, bk1); + c3 = ymm2_dot_u8s8_unsafe(c3, a30, bk0, a31, bk1); +#endif + } + + for (; k < K; k += 4) { + __m128i b0 = _mm_loadu_si128((const __m128i *)&B[(k >> 2) * incB]); + __m256i b = _mm256_set_m128i(_mm_setzero_si128(), b0); + b = _mm256_permutevar8x32_epi32(b, idx); + __m256i a0 = _mm256_set1_epi64x((long long)load_u32(&A[0 * incA + k])); + __m256i a1 = _mm256_set1_epi64x((long long)load_u32(&A[1 * incA + k])); + __m256i a2 = _mm256_set1_epi64x((long long)load_u32(&A[2 * incA + k])); + __m256i a3 = _mm256_set1_epi64x((long long)load_u32(&A[3 * incA + k])); + c0 = ymm_dot_u8s8(c0, a0, b); + c1 = ymm_dot_u8s8(c1, a1, b); + c2 = ymm_dot_u8s8(c2, a2, b); + c3 = ymm_dot_u8s8(c3, a3, b); + } + + __m256i t01 = _mm256_hadd_epi32(c0, c1); + __m256i t23 = _mm256_hadd_epi32(c2, c3); + t01 = _mm256_permute4x64_epi64(t01, _MM_SHUFFLE(3, 1, 2, 0)); + t23 = _mm256_permute4x64_epi64(t23, _MM_SHUFFLE(3, 1, 2, 0)); + __m128i r01 = ymm_modq_epi32_epi8(t01); + __m128i r23 = ymm_modq_epi32_epi8(t23); + store_u32(&out[0 * incout], (uint32_t)_mm_extract_epi32(r01, 0)); + store_u32(&out[1 * incout], (uint32_t)_mm_extract_epi32(r01, 1)); + store_u32(&out[2 * incout], (uint32_t)_mm_extract_epi32(r23, 0)); + store_u32(&out[3 * incout], (uint32_t)_mm_extract_epi32(r23, 1)); +} + +#undef ADD5 +#undef ADD25 +#undef ADD2 +#undef ADD1 diff --git a/src/sig/qruov/qruov_qruov_avx2/kernel.h b/src/sig/qruov/qruov_qruov_avx2/kernel.h new file mode 100644 index 0000000000..260883db9b --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/kernel.h @@ -0,0 +1,29 @@ +#ifndef AVX2_KERNEL_H +#define AVX2_KERNEL_H + +#include +#include "qruov.h" + +void matmulfql_vnni_1x8(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB); +void matmulfql_vnni_1x7(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB); +void matmulfql_vnni_1x6(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB); +void matmulfql_vnni_1x4(uint8_t *out, const uint8_t *A, const uint8_t *Bvnni, int K, + int incout, int incA, int incB, int incLout, int incLA, int incLB); + +void matmulfql_symmetric_upper(uint8_t *output_soa, const uint8_t *vector_soa, int size); + +void matmulfq_vnni_4x16(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, + int incout, int incA, int incB); +void matmulfq_vnni_4x8(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, + int incout, int incA, int incB); +void matmulfq_vnni_4x7(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, + int incout, int incA, int incB); +void matmulfq_vnni_4x6(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, + int incout, int incA, int incB); +void matmulfq_vnni_4x4(uint8_t *out, const uint8_t *A, const uint8_t *B, int K, + int incout, int incA, int incB); + +#endif diff --git a/src/sig/qruov/qruov_qruov_avx2/qruov.c b/src/sig/qruov/qruov_qruov_avx2/qruov.c new file mode 100644 index 0000000000..e48a7293e5 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/qruov.c @@ -0,0 +1,310 @@ +#include +#include + +#if defined(QRUOV_PRIM_OQS) +#include +#endif + +#if !defined(QRUOV_PRIM_OQS) || defined(OQS_USE_PTHREADS) +#include +#endif +#include "qruov.h" +#include "qrop.h" +#include "prg.h" +#include "util.h" +#include "linsys.h" +#include "gf.h" +#include "emi_transform.h" +#include "helpers.h" +#include "kernel.h" +#include "qruov_simd.h" +#include "fql.h" +#include "fastop.h" +#include "qruov_common.h" + +__attribute__((aligned(16))) uint8_t qruov_avx2_bextmask[1u << 16][16]; +__attribute__((aligned(16))) uint8_t qruov_avx2_bdepmask[1u << 16][16]; +#if !defined(QRUOV_PRIM_OQS) || defined(OQS_USE_PTHREADS) +static pthread_once_t qruov_avx2_init_once = PTHREAD_ONCE_INIT; +#else +static int qruov_avx2_initialized = 0; +#endif + +static void qruov_avx2_init_impl(void) +{ + for (unsigned int i = 0; i < (1u << 16); i++) { + uint8_t extmask[16]; + uint8_t depmask[16]; + memset(extmask, 0xFF, sizeof(extmask)); + memset(depmask, 0xFF, sizeof(depmask)); + int t = 0; + for (int j = 0; j < 16; j++) { + if (i & (1u << j)) { + extmask[t] = (uint8_t)j; + depmask[j] = (uint8_t)t; + t++; + } + } + memcpy(qruov_avx2_bextmask[i], extmask, sizeof(extmask)); + memcpy(qruov_avx2_bdepmask[i], depmask, sizeof(depmask)); + } +} + +void qruov_init(void) +{ +#if !defined(QRUOV_PRIM_OQS) || defined(OQS_USE_PTHREADS) + pthread_once(&qruov_avx2_init_once, qruov_avx2_init_impl); +#else + if (!qruov_avx2_initialized) { + qruov_avx2_init_impl(); + qruov_avx2_initialized = 1; + } +#endif +} + +// Convert SoA [L][rows][cols] to AoS [rows][cols][L]. +static void fql_soa_to_aos(uint8_t *dst_aos, const uint8_t *src_soa, int rows, int cols) +{ + int n = rows * cols; + for (int i = 0; i < n; i++) { + for (int l = 0; l < QRUOV_L; l++) { + dst_aos[i * QRUOV_L + l] = src_soa[l * n + i]; + } + } +} + +static void fq_minus_a_plus_b_plus_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, const uint8_t *c, size_t len) +{ + const __m256i q = _mm256_set1_epi8(QRUOV_q); + size_t i = 0; + for (; i + 31 < len; i += 32) { + __m256i va = _mm256_loadu_si256((const __m256i *)&a[i]); + __m256i vb = _mm256_loadu_si256((const __m256i *)&b[i]); + __m256i vc = _mm256_loadu_si256((const __m256i *)&c[i]); + __m256i tmp = _mm256_add_epi8(_mm256_xor_si256(va, q), vb); + tmp = ymm_subq_if_greater_epi8(tmp); + tmp = _mm256_add_epi8(tmp, vc); + tmp = ymm_subq_if_greater_epi8(tmp); + _mm256_storeu_si256((__m256i *)&dst[i], tmp); + } + for (; i < len; i++) { + dst[i] = (uint8_t)(((a[i] ^ QRUOV_q) + b[i] + c[i]) % QRUOV_q); + } +} + +static void sigmap_sym_features(uint8_t *dst, const uint8_t *products_soa, + int base, int len, int stride) +{ + for (int i = 0; i < len; i++) { + int row = base + i; + fql_soa_to_aos_permute(&dst[SYMM_COMPACT_INDEX(i, i, len) * QRUOV_L], + &products_soa[row * stride + row], 1, stride * stride); + fql_soa_to_aos_permute_double(&dst[SYMM_COMPACT_INDEX(i, i + 1, len) * QRUOV_L], + &products_soa[row * stride + row + 1], len - i - 1, + stride * stride); + } +} + +static void sigmap_rect_features(uint8_t *dst, const uint8_t *products_soa, + int row_base, int rows, int col_base, int cols, + int stride) +{ + for (int i = 0; i < rows; i++) { + fql_soa_to_aos_permute(&dst[i * cols * QRUOV_L], + &products_soa[(row_base + i) * stride + col_base], + cols, stride * stride); + } +} + +static void sign_build_system(uint8_t eqn_out[QRUOV_m * QRUOV_m], uint8_t u_out[QRUOV_m], const uint8_t sd[QRUOV_tau_n2], const uint8_t y[QRUOV_V * QRUOV_L], const SEED_PK seed_pk) +{ + // AVX2-specific sign system construction with the same semantics as + // qruov_common.c sign_build_system() used by ref/opt. + enum { V4 = ROUND_UP4(QRUOV_V) }; + uint8_t y_soa[QRUOV_L * V4]; + uint8_t y_perm_soa[QRUOV_L * V4]; + uint8_t sdvnni[QRUOV_L * V4 * QRUOV_M]; + uint8_t p1vnni[QRUOV_L * V4 * V4] = {0}; + uint8_t p2vnni[QRUOV_L * V4 * QRUOV_M]; + uint8_t yT_p1[QRUOV_L * V4] = {0}; + uint8_t yT_p1_sd[QRUOV_L * QRUOV_M]; + uint8_t yT_p2[QRUOV_L * QRUOV_M]; + + memset(y_soa, 0, sizeof(y_soa)); + fql_aos_to_soa(y_soa, y, QRUOV_V, V4); + for (int l = 0; l < QRUOV_L; l++) { + memcpy(&y_perm_soa[l * V4], &y_soa[QRUOV_perm(l) * V4], V4); + } + fql_aos_to_vnni(sdvnni, V4, QRUOV_M, sd, QRUOV_V, QRUOV_M); + + prg pk_prg; + prg_init(&pk_prg, seed_pk); + for (int eq = 0; eq < QRUOV_m; eq++) { + uint8_t pi1_coeffs[QRUOV_tau_n1]; + uint8_t pi2_coeffs[QRUOV_tau_n2]; + prepare_pi1_coeffs_from_prg(pi1_coeffs, &pk_prg, (uint16_t)eq); + fql_compact_sym_aos_to_vnni(p1vnni, V4, V4, pi1_coeffs, QRUOV_V); + prepare_pi2_coeffs_from_prg(pi2_coeffs, &pk_prg, (uint16_t)eq); + fql_aos_to_vnni(p2vnni, V4, QRUOV_M, pi2_coeffs, QRUOV_V, QRUOV_M); + + fql_matmul_vnni_fast(yT_p1, y_soa, p1vnni, 1, V4, V4); + fql_matmul_vnni_fast(yT_p1_sd, yT_p1, sdvnni, 1, QRUOV_M, V4); + fql_matmul_vnni_fast(yT_p2, y_soa, p2vnni, 1, QRUOV_M, V4); + + for (int l = 0; l < QRUOV_L; l++) { + for (int j = 0; j < QRUOV_M; j++) { + eqn_out[eq * QRUOV_m + j * QRUOV_L + QRUOV_perm(l)] = + (uint8_t)(((uint32_t)(0x2 ^ QRUOV_q) * yT_p1_sd[l * QRUOV_M + j] + + 2u * yT_p2[l * QRUOV_M + j]) % QRUOV_q); + } + } + u_out[eq] = fastop_dotprod((unsigned int)sizeof(yT_p1), yT_p1, y_perm_soa); + } + prg_free(&pk_prg); + secure_zero(yT_p2, sizeof(yT_p2)); + secure_zero(yT_p1_sd, sizeof(yT_p1_sd)); + secure_zero(yT_p1, sizeof(yT_p1)); + secure_zero(sdvnni, sizeof(sdvnni)); + secure_zero(y_perm_soa, sizeof(y_perm_soa)); + secure_zero(y_soa, sizeof(y_soa)); +} + +void qruov_keygen(const SEED_PK seed_pk, const SEED_SK seed_sk, uint8_t pk_p3[P3_SERIALIZED_LEN]) +{ + enum { V4 = ROUND_UP4(QRUOV_V) }; + uint8_t sdbuf[QRUOV_tau_n2]; + prepare_sd_from_seed(sdbuf, seed_sk); + + uint8_t sdvnni[QRUOV_LL * V4 * QRUOV_M]; + uint8_t sdt_eval[QRUOV_LL * QRUOV_M * V4]; + uint8_t sdt_p1_eval[QRUOV_LL * QRUOV_M * V4]; + uint8_t sdt_p1_reval[QRUOV_LL * QRUOV_M * V4]; + uint8_t p2t_sd_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t sdt_p2_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t p1vnni[QRUOV_LL * V4 * V4]; + uint8_t p2vnni[QRUOV_LL * V4 * QRUOV_M]; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + int chunk_eqs = 0; + size_t p3_offset = 0; + + fql_aos_to_eval_vnni(sdvnni, V4, QRUOV_M, sdbuf, QRUOV_V, QRUOV_M); + fql_aos_to_eval_transposed_soa(sdt_eval, QRUOV_M, V4, sdbuf, QRUOV_V, QRUOV_M); + + prg pk_prg; + prg_init(&pk_prg, seed_pk); + for (int eq = 0; eq < QRUOV_m; eq++) { + uint8_t pi1_coeffs[QRUOV_tau_n1]; + uint8_t pi2_coeffs[QRUOV_tau_n2]; + uint8_t pi3_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t pi3_soa[QRUOV_L * QRUOV_M * QRUOV_M]; + uint8_t pi3[QRUOV_M * QRUOV_M * QRUOV_L]; + + prepare_pi1_coeffs_from_prg(pi1_coeffs, &pk_prg, (uint16_t)eq); + fql_compact_sym_aos_to_eval_vnni(p1vnni, V4, V4, pi1_coeffs, QRUOV_V); + + prepare_pi2_coeffs_from_prg(pi2_coeffs, &pk_prg, (uint16_t)eq); + fql_aos_to_eval_vnni(p2vnni, V4, QRUOV_M, pi2_coeffs, QRUOV_V, QRUOV_M); + + fql_matmul_eval_vnni_fast(sdt_p2_eval, sdt_eval, p2vnni, QRUOV_M, QRUOV_M, V4); + fq_eval_transpose_planes(p2t_sd_eval, sdt_p2_eval, QRUOV_M * QRUOV_M, QRUOV_M * QRUOV_M, + QRUOV_M, QRUOV_M, QRUOV_M, QRUOV_M); + fql_matmul_eval_vnni_fast(sdt_p1_eval, sdt_eval, p1vnni, QRUOV_M, V4, V4); + reevaluate(sdt_p1_reval, QRUOV_M * V4, sdt_p1_eval, QRUOV_M * V4, QRUOV_M * V4); + fql_matmul_eval_vnni_fast(pi3_eval, sdt_p1_reval, sdvnni, QRUOV_M, QRUOV_M, V4); + fq_minus_a_plus_b_plus_c(pi3_eval, pi3_eval, p2t_sd_eval, sdt_p2_eval, sizeof(pi3_eval)); + + interpolate(pi3_soa, QRUOV_M * QRUOV_M, pi3_eval, QRUOV_M * QRUOV_M, QRUOV_M * QRUOV_M); + fql_soa_to_aos(pi3, pi3_soa, QRUOV_M, QRUOV_M); + p3_store_upper_MxM(&p3_chunk[chunk_eqs * P3_EQ_COEFF_LEN], pi3); + chunk_eqs++; + if (chunk_eqs == P3_CHUNK_EQS) { + store_fq(pk_p3 + p3_offset, p3_chunk, P3_CHUNK_COEFF_LEN); + p3_offset += BITS2BYTE(QRUOV_q_LOG * P3_CHUNK_COEFF_LEN); + chunk_eqs = 0; + } + } + if (chunk_eqs > 0) { + store_fq(pk_p3 + p3_offset, p3_chunk, (size_t)chunk_eqs * P3_EQ_COEFF_LEN); + } + prg_free(&pk_prg); + secure_zero(sdt_p2_eval, sizeof(sdt_p2_eval)); + secure_zero(p2t_sd_eval, sizeof(p2t_sd_eval)); + secure_zero(sdt_p1_reval, sizeof(sdt_p1_reval)); + secure_zero(sdt_p1_eval, sizeof(sdt_p1_eval)); + secure_zero(sdt_eval, sizeof(sdt_eval)); + secure_zero(sdvnni, sizeof(sdvnni)); + secure_zero(sdbuf, sizeof(sdbuf)); +} + +int qruov_sign(const SEED_PK seed_pk, const SEED_SK seed_sk, const SEED_SK seed_y, const SEED_SK seed_r, const SEED_SK seed_sol, const uint8_t msg[], size_t msg_len, SALT sig_r, SIG_S sig_s) +{ + uint8_t sd[QRUOV_tau_n2]; + uint8_t y[QRUOV_V * QRUOV_L]; // vinegar + uint8_t eqn[QRUOV_m * QRUOV_m]; // L + uint8_t u[QRUOV_m]; + prepare_sd_from_seed(sd, seed_sk); + prepare_y_from_seed(y, seed_y); + sign_build_system(eqn, u, sd, y, seed_pk); + uint8_t oil[QRUOV_m]; + int ret = qruov_common_sign_solve_oil(oil, sig_r, eqn, u, seed_pk, seed_r, + seed_sol, msg, msg_len); + if (ret == 0) { + qruov_common_sig_s(sig_s, sd, y, oil); + } + secure_zero(oil, sizeof(oil)); + secure_zero(y, sizeof(y)); + secure_zero(u, sizeof(u)); + secure_zero(sd, sizeof(sd)); + secure_zero(eqn, sizeof(eqn)); + return ret; +} + +int qruov_verify(const SEED_PK seed_pk, const uint8_t pk_p3[P3_SERIALIZED_LEN], const uint8_t msg[], size_t msg_len, const SALT sig_r, const SIG_S sig_s) +{ + uint8_t t[QRUOV_m]; + enum { N16 = ROUND_UP16(QRUOV_N) }; + uint8_t s_soa[QRUOV_L * N16]; + uint8_t ss_soa[QRUOV_L * N16 * N16]; + uint8_t s11[QRUOV_n1 + 32]; + uint8_t s12[QRUOV_n2 + 32]; + uint8_t s22[P3_EQ_COEFF_LEN]; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + prg pk_prg; + if (!qruov_common_is_canonical_s(sig_s)) return 0; + compute_mu_and_hash(t, seed_pk, msg, msg_len, sig_r); + memset(s_soa, 0, sizeof(s_soa)); + fql_aos_to_soa(s_soa, sig_s, QRUOV_N, N16); + matmulfql_symmetric_upper(ss_soa, s_soa, N16); + sigmap_sym_features(s11, ss_soa, 0, QRUOV_V, N16); + sigmap_rect_features(s12, ss_soa, 0, QRUOV_V, QRUOV_V, QRUOV_M, N16); + sigmap_sym_features(s22, ss_soa, QRUOV_V, QRUOV_M, N16); + memset(&s11[QRUOV_n1], 0, 32); + memset(&s12[QRUOV_n2], 0, 32); + prg_init(&pk_prg, seed_pk); + int ok = 1; + size_t p3_offset = 0; + for (int eq_base = 0; eq_base < QRUOV_m; eq_base += P3_CHUNK_EQS) { + int chunk_eqs = QRUOV_m - eq_base; + if (chunk_eqs > P3_CHUNK_EQS) chunk_eqs = P3_CHUNK_EQS; + size_t chunk_coeffs = (size_t)chunk_eqs * P3_EQ_COEFF_LEN; + if (!load_fq_checked(p3_chunk, pk_p3 + p3_offset, chunk_coeffs)) { + ok = 0; + memset(p3_chunk, 0, chunk_coeffs); + } + p3_offset += BITS2BYTE(QRUOV_q_LOG * chunk_coeffs); + for (int chunk_eq = 0; chunk_eq < chunk_eqs; chunk_eq++) { + int eq = eq_base + chunk_eq; + uint8_t pi1_raw[QRUOV_tau_n1]; + uint8_t pi2_raw[QRUOV_tau_n2]; + uint32_t sum = 0; + prepare_pi1_raw_from_prg(pi1_raw, &pk_prg, (uint16_t)eq); + prepare_pi2_raw_from_prg(pi2_raw, &pk_prg, (uint16_t)eq); + sum += fastop_rejection_dotprod(QRUOV_n1, QRUOV_tau_n1, pi1_raw, s11); + sum += 2u * fastop_rejection_dotprod(QRUOV_n2, QRUOV_tau_n2, pi2_raw, s12); + sum += fastop_dotprod(P3_EQ_COEFF_LEN, s22, &p3_chunk[chunk_eq * P3_EQ_COEFF_LEN]); + ok &= (gf_reduce(sum) == t[eq]); + } + } + prg_free(&pk_prg); + return ok; +} diff --git a/src/sig/qruov/qruov_qruov_avx2/qruov_simd.h b/src/sig/qruov/qruov_qruov_avx2/qruov_simd.h new file mode 100644 index 0000000000..33e95fecbc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/qruov_simd.h @@ -0,0 +1,29 @@ +#ifndef QRUOV_SIMD_H_ +#define QRUOV_SIMD_H_ + +#include "qruov.h" +#include "simd.h" + +#if QRUOV_q == 7 +#define ymm_subq_if_greater_epi8 ymm_sub7_if_greater_epi8 +#define ymm_modq_epi15 ymm_mod7_epi15 +#define ymm_modq_epi32_epi8 ymm_mod7_epi32_epi8 +#define ymm2_modq_epi32_epi8 ymm2_mod7_epi32_epi8 +#define ymm_reduceq_epi16 ymm_reduce7_epi16 +#elif QRUOV_q == 31 +#define ymm_subq_if_greater_epi8 ymm_sub31_if_greater_epi8 +#define ymm_modq_epi15 ymm_mod31_epi15 +#define ymm_modq_epi32_epi8 ymm_mod31_epi32_epi8 +#define ymm2_modq_epi32_epi8 ymm2_mod31_epi32_epi8 +#define ymm_reduceq_epi16 ymm_reduce31_epi16 +#elif QRUOV_q == 127 +#define ymm_subq_if_greater_epi8 ymm_sub127_if_greater_epi8 +#define ymm_modq_epi15 ymm_mod127_epi15 +#define ymm_modq_epi32_epi8 ymm_mod127_epi32_epi8 +#define ymm2_modq_epi32_epi8 ymm2_mod127_epi32_epi8 +#define ymm_reduceq_epi16 ymm_reduce127_epi16 +#else +#error "Unsupported QRUOV_q" +#endif + +#endif // QRUOV_SIMD_H_ diff --git a/src/sig/qruov/qruov_qruov_avx2/simd.h b/src/sig/qruov/qruov_qruov_avx2/simd.h new file mode 100644 index 0000000000..1bd0928b47 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/simd.h @@ -0,0 +1,286 @@ +#ifndef SIMD_H_ +#define SIMD_H_ + +#include +#include +#include +#include + +#define SIMD_CAT_(a, b) a ## b +#define SIMD_CAT(a, b) SIMD_CAT_(a, b) + +static inline uint16_t load_u16 (const void *ptr) { uint16_t x; memcpy(&x, ptr, 2); return x; } +static inline uint32_t load_u32 (const void *ptr) { uint32_t x; memcpy(&x, ptr, 4); return x; } +static inline uint64_t load_u64 (const void *ptr) { uint64_t x; memcpy(&x, ptr, 8); return x; } + +static inline void store_u32(void *ptr, uint32_t x) { memcpy(ptr, &x, 4); } +static inline void store_u64(void *ptr, uint64_t x) { memcpy(ptr, &x, 8); } + +static inline __m256i ymm_dot_u8s8(__m256i acc32, __m256i u8, __m256i s8) +{ + return _mm256_add_epi32(acc32, _mm256_madd_epi16(_mm256_set1_epi16(1), _mm256_maddubs_epi16(u8, s8))); +} + +static inline __m256i ymm2_dot_u8s8(__m256i acc32, __m256i u8_0, __m256i s8_0, __m256i u8_1, __m256i s8_1) +{ + acc32 = ymm_dot_u8s8(acc32, u8_0, s8_0); + return ymm_dot_u8s8(acc32, u8_1, s8_1); +} + +// Unsafe grouped variant of ymm2_dot_u8s8: exact only when the grouped +// signed 16-bit maddubs lane sums cannot overflow. +static inline __m256i ymm2_dot_u8s8_unsafe(__m256i acc32, __m256i u8_0, __m256i s8_0, __m256i u8_1, __m256i s8_1) +{ + __m256i tmp = _mm256_add_epi16(_mm256_maddubs_epi16(u8_0, s8_0), _mm256_maddubs_epi16(u8_1, s8_1)); + return _mm256_add_epi32(acc32, _mm256_madd_epi16(_mm256_set1_epi16(1), tmp)); +} + +static inline __m256i ymm4_dot_u8s8(__m256i acc32, __m256i u8_0, __m256i s8_0, __m256i u8_1, __m256i s8_1, __m256i u8_2, __m256i s8_2, __m256i u8_3, __m256i s8_3) +{ + acc32 = ymm_dot_u8s8(acc32, u8_0, s8_0); + acc32 = ymm_dot_u8s8(acc32, u8_1, s8_1); + acc32 = ymm_dot_u8s8(acc32, u8_2, s8_2); + return ymm_dot_u8s8(acc32, u8_3, s8_3); +} + +// Unsafe grouped variant of ymm4_dot_u8s8: exact only when the grouped +// signed 16-bit maddubs lane sums cannot overflow. +static inline __m256i ymm4_dot_u8s8_unsafe(__m256i acc32, __m256i u8_0, __m256i s8_0, __m256i u8_1, __m256i s8_1, __m256i u8_2, __m256i s8_2, __m256i u8_3, __m256i s8_3) +{ + __m256i tmp0 = _mm256_add_epi16(_mm256_maddubs_epi16(u8_0, s8_0), _mm256_maddubs_epi16(u8_1, s8_1)); + __m256i tmp1 = _mm256_add_epi16(_mm256_maddubs_epi16(u8_2, s8_2), _mm256_maddubs_epi16(u8_3, s8_3)); + return _mm256_add_epi32(acc32, _mm256_madd_epi16(_mm256_set1_epi16(1), _mm256_add_epi16(tmp0, tmp1))); +} + +static inline __m128i ymm_cvtusepi16_epi8(__m256i x) +{ + __m128i lo = _mm256_castsi256_si128(x); + __m128i hi = _mm256_extracti128_si256(x, 1); + return _mm_packus_epi16(lo, hi); +} +static inline __m128i ymm_cvtusepi32_epi16(__m256i x) +{ + __m128i lo = _mm256_castsi256_si128(x); + __m128i hi = _mm256_extracti128_si256(x, 1); + return _mm_packus_epi32(lo, hi); +} + +static inline __m256i ymm2_cvtusepi32_epi16(__m256i x0, __m256i x1) +{ + __m128i y0 = ymm_cvtusepi32_epi16(x0); + __m128i y1 = ymm_cvtusepi32_epi16(x1); + return _mm256_set_m128i(y1, y0); +} + +#define GENERATE_YMM_MODQ_EPI15(Q, W) \ +static inline __m256i SIMD_CAT(ymm_mod, SIMD_CAT(Q, _epi15))(__m256i x)\ +{\ + __m256i q = _mm256_mulhi_epu16(x, _mm256_set1_epi16((int16_t)(((1 << (16 + W)) + Q - 1) / Q)));\ + q = _mm256_srli_epi16(q, W);\ + x = _mm256_add_epi16(q, x);\ + return _mm256_and_si256(x, _mm256_set1_epi16(Q));\ +} + +#define GENERATE_YMM_MODQ_EPI32_EPI8(Q) \ +static inline __m128i SIMD_CAT(ymm_mod, SIMD_CAT(Q, _epi32_epi8))(__m256i x)\ +{\ + x = ymm_dot_u8s8(_mm256_setzero_si256(), x, _mm256_set1_epi32(((1 << 24) % Q) << 24 | ((1 << 16) % Q) << 16 | ((1 << 8) % Q) << 8 | 1));\ + __m128i y = ymm_cvtusepi32_epi16(x);\ + __m256i z = SIMD_CAT(ymm_mod, SIMD_CAT(Q, _epi15))(_mm256_castsi128_si256(y));\ + return _mm_packus_epi16(_mm256_castsi256_si128(z), _mm_setzero_si128());\ +}\ +static inline __m128i SIMD_CAT(ymm2_mod, SIMD_CAT(Q, _epi32_epi8))(__m256i x0, __m256i x1)\ +{\ + x0 = ymm_dot_u8s8(_mm256_setzero_si256(), x0, _mm256_set1_epi32(((1 << 24) % Q) << 24 | ((1 << 16) % Q) << 16 | ((1 << 8) % Q) << 8 | 1));\ + x1 = ymm_dot_u8s8(_mm256_setzero_si256(), x1, _mm256_set1_epi32(((1 << 24) % Q) << 24 | ((1 << 16) % Q) << 16 | ((1 << 8) % Q) << 8 | 1));\ + __m256i y = ymm2_cvtusepi32_epi16(x0, x1);\ + __m256i z = SIMD_CAT(ymm_mod, SIMD_CAT(Q, _epi15))(y);\ + return ymm_cvtusepi16_epi8(z);\ +} + +GENERATE_YMM_MODQ_EPI15(7, 1) +GENERATE_YMM_MODQ_EPI15(31, 3) +GENERATE_YMM_MODQ_EPI15(127, 6) +GENERATE_YMM_MODQ_EPI32_EPI8(7) +GENERATE_YMM_MODQ_EPI32_EPI8(31) +GENERATE_YMM_MODQ_EPI32_EPI8(127) + +static inline void transpose8x8(uint8_t *output, const uint8_t *input, int stride_out, int stride_in) +{ + __m128i r0 = _mm_loadl_epi64((__m128i*)(input + 0*stride_in)); + __m128i r1 = _mm_loadl_epi64((__m128i*)(input + 1*stride_in)); + __m128i r2 = _mm_loadl_epi64((__m128i*)(input + 2*stride_in)); + __m128i r3 = _mm_loadl_epi64((__m128i*)(input + 3*stride_in)); + __m128i r4 = _mm_loadl_epi64((__m128i*)(input + 4*stride_in)); + __m128i r5 = _mm_loadl_epi64((__m128i*)(input + 5*stride_in)); + __m128i r6 = _mm_loadl_epi64((__m128i*)(input + 6*stride_in)); + __m128i r7 = _mm_loadl_epi64((__m128i*)(input + 7*stride_in)); + __m128i t0 = _mm_unpacklo_epi8(r0, r1); + __m128i t1 = _mm_unpacklo_epi8(r2, r3); + __m128i t2 = _mm_unpacklo_epi8(r4, r5); + __m128i t3 = _mm_unpacklo_epi8(r6, r7); + __m128i s0 = _mm_unpacklo_epi16(t0, t1); + __m128i s1 = _mm_unpackhi_epi16(t0, t1); + __m128i s2 = _mm_unpacklo_epi16(t2, t3); + __m128i s3 = _mm_unpackhi_epi16(t2, t3); + __m128i o0 = _mm_unpacklo_epi32(s0, s2); + __m128i o1 = _mm_unpackhi_epi32(s0, s2); + __m128i o2 = _mm_unpacklo_epi32(s1, s3); + __m128i o3 = _mm_unpackhi_epi32(s1, s3); + _mm_storel_epi64((__m128i*)(output + 0*stride_out), o0); + _mm_storel_epi64((__m128i*)(output + 1*stride_out), _mm_srli_si128(o0, 8)); + _mm_storel_epi64((__m128i*)(output + 2*stride_out), o1); + _mm_storel_epi64((__m128i*)(output + 3*stride_out), _mm_srli_si128(o1, 8)); + _mm_storel_epi64((__m128i*)(output + 4*stride_out), o2); + _mm_storel_epi64((__m128i*)(output + 5*stride_out), _mm_srli_si128(o2, 8)); + _mm_storel_epi64((__m128i*)(output + 6*stride_out), o3); + _mm_storel_epi64((__m128i*)(output + 7*stride_out), _mm_srli_si128(o3, 8)); +} + +static inline void transpose4x4_epi32(__m128i a0, __m128i a1, __m128i a2, __m128i a3, __m128i *b0, __m128i *b1, __m128i *b2, __m128i *b3) +{ + __m128i t0 = _mm_unpacklo_epi32(a0, a1); + __m128i t1 = _mm_unpackhi_epi32(a0, a1); + __m128i t2 = _mm_unpacklo_epi32(a2, a3); + __m128i t3 = _mm_unpackhi_epi32(a2, a3); + *b0 = _mm_unpacklo_epi64(t0, t2); + *b1 = _mm_unpackhi_epi64(t0, t2); + *b2 = _mm_unpacklo_epi64(t1, t3); + *b3 = _mm_unpacklo_epi64(t1, t3); +} + +static inline void deint3_transpose(__m128i x0, __m128i x1, __m128i x2, __m128i x3, __m128i* y1, __m128i* y2, __m128i *y3) +{ + const __m128i DEINTL3 = _mm_setr_epi8(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11, -1, -1, -1, -1); + __m128i t0 = _mm_shuffle_epi8(x0, DEINTL3); + __m128i t1 = _mm_shuffle_epi8(x1, DEINTL3); + __m128i t2 = _mm_shuffle_epi8(x2, DEINTL3); + __m128i t3 = _mm_shuffle_epi8(x3, DEINTL3); + __m128i dummy; + transpose4x4_epi32(t0, t1, t2, t3, y1, y2, y3, &dummy); +} + +static inline void transpose16x10(uint8_t output[], const uint8_t input[]) +{ + __m128i row[16]; + for (int i = 0; i < 16; i++) { + row[i] = _mm_loadl_epi64((__m128i const*)(input + i * 10)); + } + // AVX2: transpose two 8x8 blocks in parallel across 128-bit lanes. + __m256i x0 = _mm256_set_m128i(row[8], row[0]); + __m256i x1 = _mm256_set_m128i(row[9], row[1]); + __m256i x2 = _mm256_set_m128i(row[10], row[2]); + __m256i x3 = _mm256_set_m128i(row[11], row[3]); + __m256i x4 = _mm256_set_m128i(row[12], row[4]); + __m256i x5 = _mm256_set_m128i(row[13], row[5]); + __m256i x6 = _mm256_set_m128i(row[14], row[6]); + __m256i x7 = _mm256_set_m128i(row[15], row[7]); + + __m256i t0 = _mm256_unpacklo_epi8(x0, x1); + __m256i t1 = _mm256_unpacklo_epi8(x2, x3); + __m256i t2 = _mm256_unpacklo_epi8(x4, x5); + __m256i t3 = _mm256_unpacklo_epi8(x6, x7); + __m256i s0 = _mm256_unpacklo_epi16(t0, t1); + __m256i s1 = _mm256_unpackhi_epi16(t0, t1); + __m256i s2 = _mm256_unpacklo_epi16(t2, t3); + __m256i s3 = _mm256_unpackhi_epi16(t2, t3); + __m256i y0 = _mm256_unpacklo_epi32(s0, s2); + __m256i y1 = _mm256_unpackhi_epi32(s0, s2); + __m256i y2 = _mm256_unpacklo_epi32(s1, s3); + __m256i y3 = _mm256_unpackhi_epi32(s1, s3); + + // Reorder qwords to [col0_top,col0_bot,col1_top,col1_bot] per ymm. + _mm256_storeu_si256((__m256i *)(output + 0 * 16), + _mm256_permute4x64_epi64(y0, _MM_SHUFFLE(3, 1, 2, 0))); + _mm256_storeu_si256((__m256i *)(output + 2 * 16), + _mm256_permute4x64_epi64(y1, _MM_SHUFFLE(3, 1, 2, 0))); + _mm256_storeu_si256((__m256i *)(output + 4 * 16), + _mm256_permute4x64_epi64(y2, _MM_SHUFFLE(3, 1, 2, 0))); + _mm256_storeu_si256((__m256i *)(output + 6 * 16), + _mm256_permute4x64_epi64(y3, _MM_SHUFFLE(3, 1, 2, 0))); + + const __m128i MASK_LO = _mm_set1_epi16(0x00FF); + __m128i tail0 = _mm_setr_epi16( + load_u16(input + 0 * 10 + 8), load_u16(input + 1 * 10 + 8), + load_u16(input + 2 * 10 + 8), load_u16(input + 3 * 10 + 8), + load_u16(input + 4 * 10 + 8), load_u16(input + 5 * 10 + 8), + load_u16(input + 6 * 10 + 8), load_u16(input + 7 * 10 + 8)); + __m128i tail1 = _mm_setr_epi16( + load_u16(input + 8 * 10 + 8), load_u16(input + 9 * 10 + 8), + load_u16(input + 10 * 10 + 8), load_u16(input + 11 * 10 + 8), + load_u16(input + 12 * 10 + 8), load_u16(input + 13 * 10 + 8), + load_u16(input + 14 * 10 + 8), load_u16(input + 15 * 10 + 8)); + __m128i col8 = _mm_packus_epi16(_mm_and_si128(tail0, MASK_LO), + _mm_and_si128(tail1, MASK_LO)); + __m128i col9 = _mm_packus_epi16(_mm_srli_epi16(tail0, 8), + _mm_srli_epi16(tail1, 8)); + _mm256_storeu_si256((__m256i *)(output + 8 * 16), _mm256_set_m128i(col9, col8)); +} + +static inline __m256i ymm_sub7_if_greater_epi8(__m256i x) +{ + return _mm256_min_epu8(x, _mm256_sub_epi8(x, _mm256_set1_epi8(7))); +} + +static inline __m256i ymm_sub31_if_greater_epi8(__m256i x) +{ + return _mm256_min_epu8(x, _mm256_sub_epi8(x, _mm256_set1_epi8(31))); +} + +static inline __m256i ymm_sub127_if_greater_epi8(__m256i x) +{ + return _mm256_min_epu8(x, _mm256_sub_epi8(x, _mm256_set1_epi8(127))); +} + +static inline __m256i ymm_reduce7_epi8(__m256i x) +{ + __m256i CONST_7 = _mm256_set1_epi8(7); + __m256i CONST_248 = _mm256_set1_epi8(-8); + return _mm256_add_epi8(_mm256_and_si256(x, CONST_7), _mm256_srli_epi16(_mm256_and_si256(x, CONST_248), 3)); +} + +static inline __m256i ymm_reduce31_epi8(__m256i x) +{ + __m256i CONST_31 = _mm256_set1_epi8(31); + __m256i CONST_224 = _mm256_set1_epi8(-32); + return _mm256_add_epi8(_mm256_and_si256(x, CONST_31), _mm256_srli_epi16(_mm256_and_si256(x, CONST_224), 5)); +} + +static inline __m256i ymm_mod7_epi8(__m256i x) +{ + x = ymm_reduce7_epi8(x); + x = ymm_reduce7_epi8(x); + return ymm_sub7_if_greater_epi8(x); +} + +static inline __m256i ymm_mod31_epi8(__m256i x) +{ + x = ymm_reduce31_epi8(x); + return ymm_sub31_if_greater_epi8(x); +} + +static inline int ymm_reduce_add_epi32(__m256i a) +{ + __m256i a_hi = _mm256_permute2x128_si256(a, a, 1); + a = _mm256_hadd_epi32(a, a_hi); + a = _mm256_hadd_epi32(a, a); + a = _mm256_hadd_epi32(a, a); + return _mm256_extract_epi32(a, 0); +} + +static inline __m256i ymm_reduce7_epi16(__m256i x) +{ + return _mm256_maddubs_epi16(x, _mm256_set1_epi16((4 << 8) + 1)); +} + +static inline __m256i ymm_reduce31_epi16(__m256i x) +{ + return _mm256_maddubs_epi16(x, _mm256_set1_epi16((8 << 8) + 1)); +} + +static inline __m256i ymm_reduce127_epi16(__m256i x) +{ + return _mm256_maddubs_epi16(x, _mm256_set1_epi16((2 << 8) + 1)); +} + +#endif // SIMD_H_ diff --git a/src/sig/qruov/qruov_qruov_avx2/x86aesni.c b/src/sig/qruov/qruov_qruov_avx2/x86aesni.c new file mode 100644 index 0000000000..e8e20db943 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/x86aesni.c @@ -0,0 +1,117 @@ +#include "x86aesni.h" + +#include +#include +#include + +static inline __m128i aes128_assist(__m128i temp1, __m128i temp2) +{ + __m128i temp3; + temp2 = _mm_shuffle_epi32(temp2, 0xff); + temp3 = _mm_slli_si128(temp1, 0x4); + temp1 = _mm_xor_si128(temp1, temp3); + temp3 = _mm_slli_si128(temp3, 0x4); + temp1 = _mm_xor_si128(temp1, temp3); + temp3 = _mm_slli_si128(temp3, 0x4); + temp1 = _mm_xor_si128(temp1, temp3); + temp1 = _mm_xor_si128(temp1, temp2); + return temp1; +} + +void AES128_Key_Expansion(unsigned char *key, const unsigned char *userkey) +{ + __m128i temp1, temp2; + __m128i *key_schedule = (__m128i *)key; + + temp1 = _mm_loadu_si128((const __m128i *)userkey); + key_schedule[0] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x1); + temp1 = aes128_assist(temp1, temp2); + key_schedule[1] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x2); + temp1 = aes128_assist(temp1, temp2); + key_schedule[2] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x4); + temp1 = aes128_assist(temp1, temp2); + key_schedule[3] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x8); + temp1 = aes128_assist(temp1, temp2); + key_schedule[4] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x10); + temp1 = aes128_assist(temp1, temp2); + key_schedule[5] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x20); + temp1 = aes128_assist(temp1, temp2); + key_schedule[6] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x40); + temp1 = aes128_assist(temp1, temp2); + key_schedule[7] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x80); + temp1 = aes128_assist(temp1, temp2); + key_schedule[8] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x1b); + temp1 = aes128_assist(temp1, temp2); + key_schedule[9] = temp1; + temp2 = _mm_aeskeygenassist_si128(temp1, 0x36); + temp1 = aes128_assist(temp1, temp2); + key_schedule[10] = temp1; +} + +void AES128_CTR_Stream(unsigned char *out, unsigned long n_16B, + const unsigned char *key, const unsigned char nonce[16], + uint32_t ctr) +{ + const int rounds = 10; + const int blocks = (int)n_16B; + const __m128i one = _mm_set_epi32(0, 0, 0, 1); + const __m128i bswap = _mm_setr_epi8( + 15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0); + __m128i ctr_block, tmp0, tmp1, tmp2, tmp3; + + ctr_block = _mm_loadu_si128((const __m128i *)nonce); + ctr_block = _mm_shuffle_epi8(ctr_block, bswap); + ctr_block = _mm_insert_epi32(ctr_block, (int)ctr, 0); + + int i = 0; + // Valid only for ctr % 4 == 0: +1/+2/+3 affect only the last AES-order byte. + if ((ctr & 3) == 0) { + const __m128i four = _mm_set_epi32(0, 0, 0, 4); + const __m128i key0_0 = ((__m128i *)key)[0]; + const __m128i key0_1 = _mm_xor_si128(key0_0, _mm_set_epi32(0x01000000, 0, 0, 0)); + const __m128i key0_2 = _mm_xor_si128(key0_0, _mm_set_epi32(0x02000000, 0, 0, 0)); + const __m128i key0_3 = _mm_xor_si128(key0_0, _mm_set_epi32(0x03000000, 0, 0, 0)); + for (; i + 3 < blocks; i += 4) { + __m128i ctr_block_bswap = _mm_shuffle_epi8(ctr_block, bswap); + tmp0 = _mm_xor_si128(ctr_block_bswap, key0_0); + tmp1 = _mm_xor_si128(ctr_block_bswap, key0_1); + tmp2 = _mm_xor_si128(ctr_block_bswap, key0_2); + tmp3 = _mm_xor_si128(ctr_block_bswap, key0_3); + ctr_block = _mm_add_epi64(ctr_block, four); + for (int j = 1; j < rounds; j++) { + tmp0 = _mm_aesenc_si128(tmp0, ((__m128i *)key)[j]); + tmp1 = _mm_aesenc_si128(tmp1, ((__m128i *)key)[j]); + tmp2 = _mm_aesenc_si128(tmp2, ((__m128i *)key)[j]); + tmp3 = _mm_aesenc_si128(tmp3, ((__m128i *)key)[j]); + } + tmp0 = _mm_aesenclast_si128(tmp0, ((__m128i *)key)[rounds]); + tmp1 = _mm_aesenclast_si128(tmp1, ((__m128i *)key)[rounds]); + tmp2 = _mm_aesenclast_si128(tmp2, ((__m128i *)key)[rounds]); + tmp3 = _mm_aesenclast_si128(tmp3, ((__m128i *)key)[rounds]); + _mm_storeu_si128(&((__m128i *)out)[i + 0], tmp0); + _mm_storeu_si128(&((__m128i *)out)[i + 1], tmp1); + _mm_storeu_si128(&((__m128i *)out)[i + 2], tmp2); + _mm_storeu_si128(&((__m128i *)out)[i + 3], tmp3); + } + } + for (; i < blocks; i++) { + tmp0 = _mm_shuffle_epi8(ctr_block, bswap); + ctr_block = _mm_add_epi64(ctr_block, one); + tmp0 = _mm_xor_si128(tmp0, ((__m128i *)key)[0]); + for (int j = 1; j < rounds; j++) { + tmp0 = _mm_aesenc_si128(tmp0, ((__m128i *)key)[j]); + } + tmp0 = _mm_aesenclast_si128(tmp0, ((__m128i *)key)[rounds]); + _mm_storeu_si128(&((__m128i *)out)[i], tmp0); + } +} diff --git a/src/sig/qruov/qruov_qruov_avx2/x86aesni.h b/src/sig/qruov/qruov_qruov_avx2/x86aesni.h new file mode 100644 index 0000000000..3566b062d9 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_avx2/x86aesni.h @@ -0,0 +1,11 @@ +#ifndef AVX2_X86AESNI_H +#define AVX2_X86AESNI_H + +#include + +void AES128_Key_Expansion(unsigned char *key, const unsigned char *userkey); +void AES128_CTR_Stream(unsigned char *out, unsigned long n_16B, + const unsigned char *key, const unsigned char nonce[16], + uint32_t ctr); + +#endif // AVX2_X86AESNI_H diff --git a/src/sig/qruov/qruov_qruov_common/api.h b/src/sig/qruov/qruov_qruov_common/api.h new file mode 100644 index 0000000000..77fd666985 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/api.h @@ -0,0 +1,38 @@ +/* +NIST-developed software is provided by NIST as a public service. You may use, copy, and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify, and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software. + +NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. + +You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States. +*/ + +#ifndef QRUOV_API_H +#define QRUOV_API_H + +#include "qruov.h" + +#define CRYPTO_SECRETKEYBYTES QRUOV_SK_LEN +#define CRYPTO_PUBLICKEYBYTES QRUOV_PK_LEN +#define CRYPTO_BYTES QRUOV_SIG_LEN + +#define CRYPTO_ALGNAME QRUOV_ALGNAME + +// RNG initialization: +// This implementation uses the bundled NIST DRBG from rng.c for key generation +// and signing. Call randombytes_init(...) from rng.h before the first call to +// crypto_sign_keypair() or crypto_sign(). Verification does not use randombytes(). + +int +crypto_sign_keypair(unsigned char *pk, unsigned char *sk); + +int +crypto_sign(unsigned char *sm, unsigned long long *smlen, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk); + +int +crypto_sign_open(unsigned char *m, unsigned long long *mlen, + const unsigned char *sm, unsigned long long smlen, + const unsigned char *pk); + +#endif /* QRUOV_API_H */ diff --git a/src/sig/qruov/qruov_qruov_common/fql.h b/src/sig/qruov/qruov_qruov_common/fql.h new file mode 100644 index 0000000000..edb8c2f633 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/fql.h @@ -0,0 +1,157 @@ +#ifndef FQL_H +#define FQL_H + +#include +#include +#include "qruov.h" +#include "gf.h" + +static inline void fql_zero(uint8_t z[QRUOV_L]) +{ + memset(z, 0, QRUOV_L); +} + +static inline void fql_add(uint8_t z[QRUOV_L], const uint8_t x[QRUOV_L], const uint8_t y[QRUOV_L]) +{ + for (int i = 0; i < QRUOV_L; i++) { + z[i] = gf_add(x[i], y[i]); + } +} + +static inline void fql_sub(uint8_t z[QRUOV_L], const uint8_t x[QRUOV_L], const uint8_t y[QRUOV_L]) +{ + for (int i = 0; i < QRUOV_L; i++) { + z[i] = gf_sub(x[i], y[i]); + } +} + +static inline void fql_perm(uint8_t dst[QRUOV_L], const uint8_t src[QRUOV_L]) +{ + for (int l = 0; l < QRUOV_L; l++) { + dst[QRUOV_perm(l)] = src[l]; + } +} + +static inline void fql_add_M(uint8_t *dst, const uint8_t *x, const uint8_t *y) +{ + for (int i = 0; i < QRUOV_M; i++) { + fql_add(&dst[i * QRUOV_L], &x[i * QRUOV_L], &y[i * QRUOV_L]); + } +} + +static inline void fql_sub_M(uint8_t *dst, const uint8_t *x, const uint8_t *y) +{ + for (int i = 0; i < QRUOV_M; i++) { + fql_sub(&dst[i * QRUOV_L], &x[i * QRUOV_L], &y[i * QRUOV_L]); + } +} + +static inline void fql_perm_M(uint8_t *dst, const uint8_t *src) +{ + for (int i = 0; i < QRUOV_M; i++) { + fql_perm(&dst[i * QRUOV_L], &src[i * QRUOV_L]); + } +} + +static inline void fql_mul(uint8_t z[QRUOV_L], const uint8_t x[QRUOV_L], const uint8_t y[QRUOV_L]) +{ + uint32_t acc[2 * QRUOV_L - 1]; + memset(acc, 0, sizeof(acc)); + for (int i = 0; i < QRUOV_L; i++) { + for (int j = 0; j < QRUOV_L; j++) { + acc[i + j] += (uint32_t)x[i] * y[j]; + } + } + for (int t = 2 * QRUOV_L - 2; t >= QRUOV_L; t--) { + acc[t - QRUOV_L] += (uint32_t)QRUOV_fc0 * acc[t]; + acc[t - QRUOV_L + QRUOV_fe] += (uint32_t)QRUOV_fc * acc[t]; + } + for (int i = 0; i < QRUOV_L; i++) { + z[i] = gf_reduce(acc[i]); + } +} + +static inline void fql_dot(uint8_t z[QRUOV_L], const uint8_t *a, const uint8_t *b, int len) +{ + uint32_t acc[2 * QRUOV_L - 1]; + memset(acc, 0, sizeof(acc)); + for (int i = 0; i < len; i++) { + const uint8_t *ai = &a[i * QRUOV_L]; + const uint8_t *bi = &b[i * QRUOV_L]; + for (int j = 0; j < QRUOV_L; j++) { + const uint32_t aij = ai[j]; + for (int k = 0; k < QRUOV_L; k++) { + acc[j + k] += aij * bi[k]; + } + } + } + for (int t = 2 * QRUOV_L - 2; t >= QRUOV_L; t--) { + acc[t - QRUOV_L] += (uint32_t)QRUOV_fc0 * acc[t]; + acc[t - QRUOV_L + QRUOV_fe] += (uint32_t)QRUOV_fc * acc[t]; + } + for (int i = 0; i < QRUOV_L; i++) { + z[i] = gf_reduce(acc[i]); + } +} + +static inline void fql_dot_V(uint8_t z[QRUOV_L], const uint8_t *a, const uint8_t *b) +{ + fql_dot(z, a, b, QRUOV_V); +} + +static inline void fql_dot_M(uint8_t z[QRUOV_L], const uint8_t *a, const uint8_t *b) +{ + fql_dot(z, a, b, QRUOV_M); +} + +static inline void fql_mul_VxV_V(uint8_t *dst, const uint8_t *A_VxV, const uint8_t *x_V) +{ + for (int i = 0; i < QRUOV_V; i++) { + fql_dot_V(&dst[i * QRUOV_L], &A_VxV[i * QRUOV_V * QRUOV_L], x_V); + } +} + +static inline void fql_mul_MxV_V(uint8_t *dst, const uint8_t *A_MxV, const uint8_t *x_V) +{ + for (int i = 0; i < QRUOV_M; i++) { + fql_dot_V(&dst[i * QRUOV_L], &A_MxV[i * QRUOV_V * QRUOV_L], x_V); + } +} + +static inline void fql_mul_MxV_VxVt(uint8_t *dst, const uint8_t *A_MxV, const uint8_t *B_VxVt) +{ + for (int i = 0; i < QRUOV_M; i++) { + for (int j = 0; j < QRUOV_V; j++) { + fql_dot_V(&dst[(i * QRUOV_V + j) * QRUOV_L], + &A_MxV[i * QRUOV_V * QRUOV_L], + &B_VxVt[j * QRUOV_V * QRUOV_L]); + } + } +} + +static inline void fql_mul_MxV_MxVt(uint8_t *dst, const uint8_t *A_MxV, const uint8_t *B_MxV) +{ + for (int i = 0; i < QRUOV_M; i++) { + for (int j = 0; j < QRUOV_M; j++) { + fql_dot_V(&dst[(i * QRUOV_M + j) * QRUOV_L], + &A_MxV[i * QRUOV_V * QRUOV_L], + &B_MxV[j * QRUOV_V * QRUOV_L]); + } + } +} + +static inline void fql_mul_VxM_M(uint8_t *dst, const uint8_t *A_VxM, const uint8_t *x_M) +{ + for (int i = 0; i < QRUOV_V; i++) { + fql_dot_M(&dst[i * QRUOV_L], &A_VxM[i * QRUOV_M * QRUOV_L], x_M); + } +} + +static inline void fql_mul_MxM_M(uint8_t *dst, const uint8_t *A_MxM, const uint8_t *x_M) +{ + for (int i = 0; i < QRUOV_M; i++) { + fql_dot_M(&dst[i * QRUOV_L], &A_MxM[i * QRUOV_M * QRUOV_L], x_M); + } +} + +#endif // FQL_H diff --git a/src/sig/qruov/qruov_qruov_common/gf.h b/src/sig/qruov/qruov_qruov_common/gf.h new file mode 100644 index 0000000000..828b0d15a3 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/gf.h @@ -0,0 +1,56 @@ +#ifndef GF_H +#define GF_H + +#include +#include "qruov.h" + +static inline uint8_t gf_reduce(uint32_t x) +{ + return x % QRUOV_q; +} + +static inline uint8_t gf_add(uint8_t a, uint8_t b) +{ + return gf_reduce(a + b); +} + +static inline uint8_t gf_sub(uint8_t a, uint8_t b) +{ + return gf_reduce(a + QRUOV_q - b); +} + +static inline uint8_t gf_mul(uint8_t a, uint8_t b) +{ + return gf_reduce((uint32_t)a * b); +} + +#if QRUOV_q == 7 +static const uint8_t gf_inv_table[256] = { + 0, 1, 4, 5, 2, 3, 6, +}; +#elif QRUOV_q == 31 +static const uint8_t gf_inv_table[256] = { + 0, 1, 16, 21, 8, 25, 26, 9, 4, 7, 28, 17, 13, 12, 20, 29, + 2, 11, 19, 18, 14, 3, 24, 27, 22, 5, 6, 23, 10, 15, 30, +}; +#elif QRUOV_q == 127 +static const uint8_t gf_inv_table[256] = { + 0, 1, 64, 85, 32, 51, 106, 109, 16, 113, 89, 104, 53, 88, 118, 17, + 8, 15, 120, 107, 108, 121, 52, 116, 90, 61, 44, 80, 59, 92, 72, 41, + 4, 77, 71, 98, 60, 103, 117, 114, 54, 31, 124, 65, 26, 48, 58, 100, + 45, 70, 94, 5, 22, 12, 40, 97, 93, 78, 46, 28, 36, 25, 84, 125, + 2, 43, 102, 91, 99, 81, 49, 34, 30, 87, 115, 105, 122, 33, 57, 82, + 27, 69, 79, 101, 62, 3, 96, 73, 13, 10, 24, 67, 29, 56, 50, 123, + 86, 55, 35, 68, 47, 83, 66, 37, 11, 75, 6, 19, 20, 7, 112, 119, + 110, 9, 39, 74, 23, 38, 14, 111, 18, 21, 76, 95, 42, 63, 126, +}; +#else +#error "Unsupported QRUOV_q" +#endif + +static inline uint8_t gf_inv(uint8_t a) +{ + return gf_inv_table[a]; +} + +#endif // GF_H diff --git a/src/sig/qruov/qruov_qruov_common/linsys.c b/src/sig/qruov/qruov_qruov_common/linsys.c new file mode 100644 index 0000000000..53eaf4f2cc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/linsys.c @@ -0,0 +1,171 @@ +#include +#include "qruov.h" +#include "util.h" +#include "linsys.h" +#include "gf.h" +#include "fastop.h" + +static void echelon_init(uint8_t *mat, linsys_echelon *echelon) +{ + for (int i = 0; i < QRUOV_m; i++) { + echelon->row[i].col = &mat[i * QRUOV_m]; + echelon->row[i].original_row_id = (uint8_t)i; + echelon->eqn[i] = &echelon->row[i]; + echelon->index[i] = 0xff; + } + echelon->rank = 0; + echelon->has_consistency_cache = 0; +} + +static void row_swap(linsys_row *eqn[QRUOV_m], int i, int j) +{ + linsys_row *tmp = eqn[i]; + eqn[i] = eqn[j]; + eqn[j] = tmp; +} + +#define EQN(E, I, J) ((E)->eqn[(I)]->col[(J)]) + +void linsys_lu_decompose(uint8_t *mat, linsys_echelon *echelon) +{ + echelon_init(mat, echelon); + int c = -1; + for (int i = 0; i < QRUOV_m; i++) { + c++; + if (c >= QRUOV_m) return; + + int j = i; + while (EQN(echelon, j, c) == 0) { + j++; + if (j >= QRUOV_m) { + c++; + if (c >= QRUOV_m) return; + j = i; + } + } + + row_swap(echelon->eqn, i, j); + echelon->index[echelon->rank++] = (uint8_t)c; + + uint8_t pivot = EQN(echelon, i, c); + uint8_t inv = gf_inv(pivot); + EQN(echelon, i, i) = pivot; + for (int k = c + 1; k < QRUOV_m; k++) { + EQN(echelon, i, k) = gf_mul(inv, EQN(echelon, i, k)); + } + + for (int r = i + 1; r < QRUOV_m; r++) { + uint8_t mul = EQN(echelon, r, c); + EQN(echelon, r, i) = mul; + uint8_t m_mul = (uint8_t)(mul ^ QRUOV_q); + fastop_row_elim(&EQN(echelon, r, c + 1), + &EQN(echelon, i, c + 1), + m_mul, QRUOV_m - (c + 1)); + } + } +} + +static void linsys_build_consistency_cache(linsys_echelon *echelon) +{ + uint8_t *cache = echelon->consistency_cache; + uint8_t pivot_inv[QRUOV_m]; + uint8_t qv[QRUOV_m]; + + for (int k = 0; k < echelon->rank; k++) { + pivot_inv[k] = gf_inv(EQN(echelon, k, k)); + } + + for (int h = 0; h < QRUOV_m - echelon->rank; h++) { + int s = echelon->rank + h; + uint8_t *row = &cache[h * QRUOV_m]; + memset(qv, 0, sizeof(qv)); + + /* + * The decomposition stores P A = L U. For a dependent row s, this + * builds the lower row of L^{-1} P directly in original-row order, so + * consistency of A x = b is exactly row . b == 0. + */ + for (int k = echelon->rank - 1; k >= 0; k--) { + uint32_t acc = EQN(echelon, s, k); + for (int p = k + 1; p < echelon->rank; p++) { + acc += (uint32_t)qv[p] * EQN(echelon, p, k); + } + uint8_t tmp = gf_reduce(acc); + qv[k] = gf_sub(0, gf_mul(tmp, pivot_inv[k])); + } + + memset(row, 0, QRUOV_m); + for (int k = 0; k < echelon->rank; k++) { + row[echelon->eqn[k]->original_row_id] = qv[k]; + } + row[echelon->eqn[s]->original_row_id] = 1; + } + + secure_zero(qv, sizeof(qv)); + secure_zero(pivot_inv, sizeof(pivot_inv)); + echelon->has_consistency_cache = 1; +} + +int linsys_check_consistency(linsys_echelon *echelon, const uint8_t *b) +{ + if (echelon->rank == QRUOV_m) return 1; + if (!echelon->has_consistency_cache) linsys_build_consistency_cache(echelon); + + for (int h = 0; h < QRUOV_m - echelon->rank; h++) { + const uint8_t *row = &echelon->consistency_cache[h * QRUOV_m]; + if (fastop_dotprod(QRUOV_m, row, b) != 0) return 0; + } + return 1; +} + +void linsys_prepare_consistency(linsys_echelon *echelon, const uint8_t *u, uint8_t *rhs) +{ + memset(rhs, 0, QRUOV_m); + if (echelon->rank == QRUOV_m) return; + if (!echelon->has_consistency_cache) linsys_build_consistency_cache(echelon); + + for (int h = 0; h < QRUOV_m - echelon->rank; h++) { + const uint8_t *row = &echelon->consistency_cache[h * QRUOV_m]; + rhs[h] = fastop_dotprod(QRUOV_m, row, u); + } +} + +int linsys_check_prepared_consistency(linsys_echelon *echelon, const uint8_t *rhs, const uint8_t *t) +{ + if (echelon->rank == QRUOV_m) return 1; + if (!echelon->has_consistency_cache) linsys_build_consistency_cache(echelon); + + for (int h = 0; h < QRUOV_m - echelon->rank; h++) { + const uint8_t *row = &echelon->consistency_cache[h * QRUOV_m]; + if (fastop_dotprod(QRUOV_m, row, t) != rhs[h]) return 0; + } + return 1; +} + +void linsys_sample_solution(const linsys_echelon *echelon, const uint8_t *b, const uint8_t *free_x, uint8_t *x) +{ + uint8_t b2[QRUOV_m]; + memset(b2, 0, sizeof(b2)); + + for (int i = 0; i < echelon->rank; i++) { + uint8_t rhs = b[echelon->eqn[i]->original_row_id]; + uint8_t tmp = gf_sub(rhs, fastop_dotprod((unsigned int)i, &EQN(echelon, i, 0), b2)); + b2[i] = gf_mul(tmp, gf_inv(EQN(echelon, i, i))); + } + + int pivot_idx = echelon->rank - 1; + int free_pos = 0; + for (int col = QRUOV_m - 1; col >= 0; col--) { + if (pivot_idx >= 0 && col == echelon->index[pivot_idx]) { + x[col] = gf_sub(b2[pivot_idx], + fastop_dotprod((unsigned int)(QRUOV_m - (col + 1)), + &EQN(echelon, pivot_idx, col + 1), + &x[col + 1])); + pivot_idx--; + } else { + x[col] = free_x[free_pos++]; + } + } + + secure_zero(b2, sizeof(b2)); +} diff --git a/src/sig/qruov/qruov_qruov_common/linsys.h b/src/sig/qruov/qruov_qruov_common/linsys.h new file mode 100644 index 0000000000..8b326ea0cd --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/linsys.h @@ -0,0 +1,27 @@ +#ifndef LINSYS_H +#define LINSYS_H + +#include +#include "qruov.h" + +typedef struct { + uint8_t *col; + uint8_t original_row_id; +} linsys_row; + +typedef struct { + linsys_row row[QRUOV_m]; + linsys_row *eqn[QRUOV_m]; + uint8_t consistency_cache[QRUOV_m * QRUOV_m]; + uint8_t index[QRUOV_m]; + int rank; + int has_consistency_cache; +} linsys_echelon; + +void linsys_lu_decompose(uint8_t *mat, linsys_echelon *echelon); +int linsys_check_consistency(linsys_echelon *echelon, const uint8_t *b); +void linsys_prepare_consistency(linsys_echelon *echelon, const uint8_t *u, uint8_t *rhs); +int linsys_check_prepared_consistency(linsys_echelon *echelon, const uint8_t *rhs, const uint8_t *t); +void linsys_sample_solution(const linsys_echelon *echelon, const uint8_t *b, const uint8_t *free_x, uint8_t *x); + +#endif // LINSYS_H diff --git a/src/sig/qruov/qruov_qruov_common/namespace.h b/src/sig/qruov/qruov_qruov_common/namespace.h new file mode 100644 index 0000000000..ae6a55eeb4 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/namespace.h @@ -0,0 +1,130 @@ +#ifndef QRUOV_LIBOQS_NAMESPACE_H +#define QRUOV_LIBOQS_NAMESPACE_H + +#ifndef QRUOV_NAMESPACE_PREFIX +#error "QRUOV_NAMESPACE_PREFIX must be defined for the liboqs build" +#endif + +#define QRUOV_CONCAT_INNER(a, b) a##b +#define QRUOV_CONCAT(a, b) QRUOV_CONCAT_INNER(a, b) +#define QRUOV_NAMESPACE(name) QRUOV_CONCAT(QRUOV_NAMESPACE_PREFIX, name) + +#define aes128ctr_free QRUOV_NAMESPACE(aes128ctr_free) +#define aes128ctr_init QRUOV_NAMESPACE(aes128ctr_init) +#define aes128ctr_stream QRUOV_NAMESPACE(aes128ctr_stream) + +#define compute_hash QRUOV_NAMESPACE(compute_hash) +#define compute_mu QRUOV_NAMESPACE(compute_mu) +#define compute_mu_and_hash QRUOV_NAMESPACE(compute_mu_and_hash) + +#define crypto_sign QRUOV_NAMESPACE(crypto_sign) +#define crypto_sign_keypair QRUOV_NAMESPACE(crypto_sign_keypair) +#define crypto_sign_open QRUOV_NAMESPACE(crypto_sign_open) + +#define linsys_check_consistency QRUOV_NAMESPACE(linsys_check_consistency) +#define linsys_check_prepared_consistency QRUOV_NAMESPACE(linsys_check_prepared_consistency) +#define linsys_lu_decompose QRUOV_NAMESPACE(linsys_lu_decompose) +#define linsys_prepare_consistency QRUOV_NAMESPACE(linsys_prepare_consistency) +#define linsys_sample_solution QRUOV_NAMESPACE(linsys_sample_solution) + +#define load_fq_checked QRUOV_NAMESPACE(load_fq_checked) +#define p3_store_upper_MxM QRUOV_NAMESPACE(p3_store_upper_MxM) + +#define prepare_pi1_coeffs_from_prg QRUOV_NAMESPACE(prepare_pi1_coeffs_from_prg) +#define prepare_pi1_from_prg QRUOV_NAMESPACE(prepare_pi1_from_prg) +#define prepare_pi1_raw_from_prg QRUOV_NAMESPACE(prepare_pi1_raw_from_prg) + +#define prepare_pi2_coeffs_from_prg QRUOV_NAMESPACE(prepare_pi2_coeffs_from_prg) +#define prepare_pi2_raw_from_prg QRUOV_NAMESPACE(prepare_pi2_raw_from_prg) +#define prepare_pi2t_from_prg QRUOV_NAMESPACE(prepare_pi2t_from_prg) + +#define prepare_sd_from_seed QRUOV_NAMESPACE(prepare_sd_from_seed) +#define prepare_sdt_from_sd QRUOV_NAMESPACE(prepare_sdt_from_sd) +#define prepare_sdt_from_seed QRUOV_NAMESPACE(prepare_sdt_from_seed) +#define prepare_seed_pk_from_seed QRUOV_NAMESPACE(prepare_seed_pk_from_seed) +#define prepare_sol_from_seed QRUOV_NAMESPACE(prepare_sol_from_seed) +#define prepare_y_from_seed QRUOV_NAMESPACE(prepare_y_from_seed) + +#define prg_free QRUOV_NAMESPACE(prg_free) +#define prg_init QRUOV_NAMESPACE(prg_init) +#define prg_yield QRUOV_NAMESPACE(prg_yield) + +#define qruov_common_canonicalize_s QRUOV_NAMESPACE(qruov_common_canonicalize_s) +#define qruov_common_is_canonical_s QRUOV_NAMESPACE(qruov_common_is_canonical_s) +#define qruov_common_sig_s QRUOV_NAMESPACE(qruov_common_sig_s) +#define qruov_common_sign_scalar QRUOV_NAMESPACE(qruov_common_sign_scalar) +#define qruov_common_sign_solve_oil QRUOV_NAMESPACE(qruov_common_sign_solve_oil) + +#define qruov_init QRUOV_NAMESPACE(qruov_init) +#define qruov_keygen QRUOV_NAMESPACE(qruov_keygen) +#define qruov_sign QRUOV_NAMESPACE(qruov_sign) +#define qruov_verify QRUOV_NAMESPACE(qruov_verify) + +#define rejection_sample QRUOV_NAMESPACE(rejection_sample) + +#define shake128_digestfinal QRUOV_NAMESPACE(shake128_digestfinal) +#define shake128_free QRUOV_NAMESPACE(shake128_free) +#define shake128_init QRUOV_NAMESPACE(shake128_init) +#define shake128_update QRUOV_NAMESPACE(shake128_update) + +#define shake256_digestfinal QRUOV_NAMESPACE(shake256_digestfinal) +#define shake256_free QRUOV_NAMESPACE(shake256_free) +#define shake256_init QRUOV_NAMESPACE(shake256_init) +#define shake256_reset QRUOV_NAMESPACE(shake256_reset) +#define shake256_squeeze QRUOV_NAMESPACE(shake256_squeeze) +#define shake256_update QRUOV_NAMESPACE(shake256_update) + +#define unpack_upper_to_symm_MxM QRUOV_NAMESPACE(unpack_upper_to_symm_MxM) +#define unpack_upper_to_symm_VxV QRUOV_NAMESPACE(unpack_upper_to_symm_VxV) + +#define randombytes QRUOV_NAMESPACE(randombytes) + + +#define crypto_sign_signature QRUOV_NAMESPACE(crypto_sign_signature) +#define crypto_sign_verify QRUOV_NAMESPACE(crypto_sign_verify) + +#define AES128_CTR_Stream QRUOV_NAMESPACE(AES128_CTR_Stream) +#define AES128_Key_Expansion QRUOV_NAMESPACE(AES128_Key_Expansion) +#define evaluate QRUOV_NAMESPACE(evaluate) +#define fq_eval_transpose_planes QRUOV_NAMESPACE(fq_eval_transpose_planes) +#define fql_aos_to_eval_transposed_soa QRUOV_NAMESPACE(fql_aos_to_eval_transposed_soa) +#define fql_aos_to_eval_vnni QRUOV_NAMESPACE(fql_aos_to_eval_vnni) +#define fql_aos_to_soa QRUOV_NAMESPACE(fql_aos_to_soa) +#define fql_aos_to_vnni QRUOV_NAMESPACE(fql_aos_to_vnni) +#define fql_compact_sym_aos_to_eval_vnni QRUOV_NAMESPACE(fql_compact_sym_aos_to_eval_vnni) +#define fql_compact_sym_aos_to_vnni QRUOV_NAMESPACE(fql_compact_sym_aos_to_vnni) +#define fql_matmul_eval_vnni_fast QRUOV_NAMESPACE(fql_matmul_eval_vnni_fast) +#define fql_matmul_vnni_fast QRUOV_NAMESPACE(fql_matmul_vnni_fast) +#define fql_soa_to_aos_permute QRUOV_NAMESPACE(fql_soa_to_aos_permute) +#define fql_soa_to_aos_permute_double QRUOV_NAMESPACE(fql_soa_to_aos_permute_double) +#define interpolate QRUOV_NAMESPACE(interpolate) +#define interpolate_q31_q31L3 QRUOV_NAMESPACE(interpolate_q31_q31L3) +#define MAT_EVAL QRUOV_NAMESPACE(MAT_EVAL) +#define MAT_INTERP QRUOV_NAMESPACE(MAT_INTERP) +#define MAT_REEVAL QRUOV_NAMESPACE(MAT_REEVAL) +#define matmulfq_vnni_4x16 QRUOV_NAMESPACE(matmulfq_vnni_4x16) +#define matmulfq_vnni_4x4 QRUOV_NAMESPACE(matmulfq_vnni_4x4) +#define matmulfq_vnni_4x6 QRUOV_NAMESPACE(matmulfq_vnni_4x6) +#define matmulfq_vnni_4x7 QRUOV_NAMESPACE(matmulfq_vnni_4x7) +#define matmulfq_vnni_4x8 QRUOV_NAMESPACE(matmulfq_vnni_4x8) +#define matmulfql_symmetric_upper QRUOV_NAMESPACE(matmulfql_symmetric_upper) +#define matmulfql_vnni_1x4 QRUOV_NAMESPACE(matmulfql_vnni_1x4) +#define matmulfql_vnni_1x6 QRUOV_NAMESPACE(matmulfql_vnni_1x6) +#define matmulfql_vnni_1x7 QRUOV_NAMESPACE(matmulfql_vnni_1x7) +#define matmulfql_vnni_1x8 QRUOV_NAMESPACE(matmulfql_vnni_1x8) +#define qruov_avx2_bdepmask QRUOV_NAMESPACE(qruov_avx2_bdepmask) +#define qruov_avx2_bextmask QRUOV_NAMESPACE(qruov_avx2_bextmask) +#define reevaluate QRUOV_NAMESPACE(reevaluate) +#define reevaluate_q31_q31L3 QRUOV_NAMESPACE(reevaluate_q31_q31L3) + +#define evaluate_q7_q7L10 QRUOV_NAMESPACE(evaluate_q7_q7L10) +#define interpolate_avx2_q127L10 QRUOV_NAMESPACE(interpolate_avx2_q127L10) +#define interpolate_avx2_q127L3 QRUOV_NAMESPACE(interpolate_avx2_q127L3) +#define interpolate_q31_q31L10 QRUOV_NAMESPACE(interpolate_q31_q31L10) +#define interpolate_q7_q7L10 QRUOV_NAMESPACE(interpolate_q7_q7L10) +#define reevaluate_avx2_q127L10 QRUOV_NAMESPACE(reevaluate_avx2_q127L10) +#define reevaluate_avx2_q127L3 QRUOV_NAMESPACE(reevaluate_avx2_q127L3) +#define reevaluate_q31_q31L10 QRUOV_NAMESPACE(reevaluate_q31_q31L10) +#define reevaluate_q7_q7L10 QRUOV_NAMESPACE(reevaluate_q7_q7L10) + +#endif diff --git a/src/sig/qruov/qruov_qruov_common/prg.c b/src/sig/qruov/qruov_qruov_common/prg.c new file mode 100644 index 0000000000..7c0dc577cc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/prg.c @@ -0,0 +1,40 @@ +#include +#include +#include "util.h" +#include "prg.h" + +void prg_init(prg *ctx, const uint8_t seed[16]) +{ +#if PRG_IS_AES + aes128ctr_init(&ctx->ctx, seed); +#else + memcpy(ctx->seed, seed, 16); +#endif // PRG_IS_AES +} + +void prg_yield(prg *ctx, uint8_t *out, uint16_t index, size_t len) +{ +#if PRG_IS_AES + uint8_t nonce[8] = {0}; + store_u16_be(&nonce[6], index); + aes128ctr_stream(&ctx->ctx, nonce, out, len); +#else + shake128 state; + uint8_t idx_be[2]; + shake128_init(&state); + shake128_update(&state, ctx->seed, 16); + store_u16_be(idx_be, index); + shake128_update(&state, idx_be, sizeof(idx_be)); + shake128_digestfinal(&state, out, len); + shake128_free(&state); +#endif // PRG_IS_AES +} + +void prg_free(prg *ctx) +{ +#if PRG_IS_AES + aes128ctr_free(&ctx->ctx); +#else + secure_zero(ctx->seed, sizeof(ctx->seed)); +#endif // PRG_IS_AES +} diff --git a/src/sig/qruov/qruov_qruov_common/prg.h b/src/sig/qruov/qruov_qruov_common/prg.h new file mode 100644 index 0000000000..e567fe9cc7 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/prg.h @@ -0,0 +1,22 @@ +#ifndef PRG_H +#define PRG_H + +#include "qruov_param.h" +#include "prim.h" + +// Public-seed expansion uses AES-128-CTR when PRG_IS_AES == 1 (default), and SHAKE128 when PRG_IS_AES == 0. + +typedef struct prg { +#if PRG_IS_AES + aes128 ctx; +#else + uint8_t seed[16]; +#endif // PRG_IS_AES +} prg; + +// Requires: call order is init -> yield* -> free +void prg_init(prg *ctx, const uint8_t seed[16]); +void prg_yield(prg *ctx, uint8_t *out, uint16_t index, size_t len); +void prg_free(prg *ctx); + +#endif // PRG_H diff --git a/src/sig/qruov/qruov_qruov_common/prim.c b/src/sig/qruov/qruov_qruov_common/prim.c new file mode 100644 index 0000000000..0ef2cbfadb --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/prim.c @@ -0,0 +1,297 @@ +#include +#include +#include +// AES-NI cleanses round keys regardless of SHAKE backend, so OpenSSL may not be linked. +#if defined(QRUOV_PRIM_OQS) +#include +#define QRUOV_CLEANSE(p, n) OQS_MEM_cleanse((p), (n)) +#define QRUOV_MALLOC(n) OQS_MEM_malloc((n)) +#define QRUOV_SECURE_FREE(p, n) OQS_MEM_secure_free((p), (n)) +#else +#include +#include +#define QRUOV_CLEANSE(p, n) OPENSSL_cleanse((p), (n)) +#define QRUOV_MALLOC(n) malloc((n)) // IGNORE memory-check +#define QRUOV_SECURE_FREE(p, n) do { OPENSSL_cleanse((p), (n)); free((p)); } while (0) // IGNORE memory-check +#endif // QRUOV_PRIM_OQS +#include "prim.h" +#if defined(PRIM_AES_BACKEND_X86AESNI) +#include "x86aesni.h" +#endif // PRIM_AES_BACKEND_X86AESNI + +#if defined(QRUOV_PRIM_OQS) +void shake256_init(shake256 *ctx) +{ + OQS_SHA3_shake256_inc_init(&ctx->st); + ctx->finalized = 0; +} + +void shake256_reset(shake256 *ctx) +{ + OQS_SHA3_shake256_inc_ctx_reset(&ctx->st); + ctx->finalized = 0; +} + +void shake256_update(shake256 *ctx, const uint8_t *data, size_t size) +{ + OQS_SHA3_shake256_inc_absorb(&ctx->st, data, size); +} + +void shake256_digestfinal(shake256 *ctx, uint8_t *dst, size_t size) +{ + shake256_squeeze(ctx, dst, size); +} + +// inc_squeeze() continues the stream across calls, so no cache is needed here. +void shake256_squeeze(shake256 *ctx, uint8_t *dst, size_t size) +{ + if (!ctx->finalized) { + OQS_SHA3_shake256_inc_finalize(&ctx->st); + ctx->finalized = 1; + } + OQS_SHA3_shake256_inc_squeeze(dst, size, &ctx->st); +} + +void shake256_free(shake256 *ctx) +{ + // release() does not NULL st.ctx, and is not NULL-safe on every backend. + if (ctx->st.ctx == NULL) return; + OQS_SHA3_shake256_inc_ctx_release(&ctx->st); + ctx->st.ctx = NULL; + ctx->finalized = 0; +} + +void shake128_init(shake128 *ctx) +{ + OQS_SHA3_shake128_inc_init(&ctx->st); +} + +void shake128_update(shake128 *ctx, const uint8_t *data, size_t size) +{ + OQS_SHA3_shake128_inc_absorb(&ctx->st, data, size); +} + +void shake128_digestfinal(shake128 *ctx, uint8_t *dst, size_t size) +{ + OQS_SHA3_shake128_inc_finalize(&ctx->st); + OQS_SHA3_shake128_inc_squeeze(dst, size, &ctx->st); +} + +void shake128_free(shake128 *ctx) +{ + if (ctx->st.ctx == NULL) return; + OQS_SHA3_shake128_inc_ctx_release(&ctx->st); + ctx->st.ctx = NULL; +} + +#else // QRUOV_PRIM_OQS + +#if PRIM_NO_EVP_DIGEST_SQUEEZE +static void shake256_clear_cache(shake256 *ctx) +{ + if (ctx->cache != NULL) { + QRUOV_SECURE_FREE(ctx->cache, ctx->cache_size); + ctx->cache = NULL; + } + ctx->offset = 0; + ctx->cache_size = 0; +} +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE + +void shake256_init(shake256 *ctx) +{ + ctx->md_ctx = EVP_MD_CTX_new(); + if (ctx->md_ctx == NULL) abort(); +#if PRIM_NO_EVP_DIGEST_SQUEEZE + ctx->offset = 0; + ctx->cache_size = 0; + ctx->cache = NULL; +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE + shake256_reset(ctx); +} + +void shake256_reset(shake256 *ctx) +{ +#if PRIM_NO_EVP_DIGEST_SQUEEZE + shake256_clear_cache(ctx); +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE + if (EVP_DigestInit_ex2(ctx->md_ctx, EVP_shake256(), NULL) != 1) abort(); +} + +void shake256_update(shake256 *ctx, const uint8_t *data, size_t size) +{ + if (EVP_DigestUpdate(ctx->md_ctx, data, size) != 1) abort(); +#if PRIM_NO_EVP_DIGEST_SQUEEZE + shake256_clear_cache(ctx); +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE +} + +void shake256_digestfinal(shake256 *ctx, uint8_t *dst, size_t size) +{ + if (EVP_DigestFinalXOF(ctx->md_ctx, dst, size) != 1) abort(); +} + +void shake256_squeeze(shake256 *ctx, uint8_t *dst, size_t size) +{ +#if !PRIM_NO_EVP_DIGEST_SQUEEZE + if (EVP_DigestSqueeze(ctx->md_ctx, dst, size) != 1) abort(); +#else + if (size > SIZE_MAX - ctx->offset) abort(); + size_t total = ctx->offset + size; + if (total > ctx->cache_size) { + size_t new_size = ctx->cache_size ? ctx->cache_size : 1088; + while (new_size < total) { + if (new_size > SIZE_MAX / 2) { + new_size = total; + break; + } + new_size <<= 1; + } + EVP_MD_CTX *tmp = EVP_MD_CTX_new(); + if (tmp == NULL) abort(); + if (EVP_MD_CTX_copy_ex(tmp, ctx->md_ctx) != 1) { + EVP_MD_CTX_free(tmp); + abort(); + } + uint8_t *new_cache = QRUOV_MALLOC(new_size); + if (new_cache == NULL) { + EVP_MD_CTX_free(tmp); + abort(); + } + if (EVP_DigestFinalXOF(tmp, new_cache, new_size) != 1) { + QRUOV_SECURE_FREE(new_cache, new_size); + EVP_MD_CTX_free(tmp); + abort(); + } + EVP_MD_CTX_free(tmp); + if (ctx->cache != NULL) { + QRUOV_SECURE_FREE(ctx->cache, ctx->cache_size); + } + ctx->cache = new_cache; + ctx->cache_size = new_size; + } + memcpy(dst, &ctx->cache[ctx->offset], size); + ctx->offset = total; +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE +} + +void shake256_free(shake256 *ctx) +{ +#if PRIM_NO_EVP_DIGEST_SQUEEZE + shake256_clear_cache(ctx); +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE + EVP_MD_CTX_free(ctx->md_ctx); + ctx->md_ctx = NULL; +} + +void shake128_init(shake128 *ctx) +{ + ctx->md_ctx = EVP_MD_CTX_new(); + if (ctx->md_ctx == NULL) abort(); + if (EVP_DigestInit_ex2(ctx->md_ctx, EVP_shake128(), NULL) != 1) abort(); +} + +void shake128_update(shake128 *ctx, const uint8_t *data, size_t size) +{ + if (EVP_DigestUpdate(ctx->md_ctx, data, size) != 1) abort(); +} + +void shake128_digestfinal(shake128 *ctx, uint8_t *dst, size_t size) +{ + if (EVP_DigestFinalXOF(ctx->md_ctx, dst, size) != 1) abort(); +} + +void shake128_free(shake128 *ctx) +{ + EVP_MD_CTX_free(ctx->md_ctx); + ctx->md_ctx = NULL; +} + +#endif // QRUOV_PRIM_OQS + +#if defined(PRIM_AES_BACKEND_X86AESNI) +void aes128ctr_init(aes128 *ctx, const uint8_t key[16]) +{ + AES128_Key_Expansion(ctx->round_keys, key); +} + +void aes128ctr_stream(aes128 *ctx, const uint8_t iv[8], uint8_t *dst, size_t size) +{ + const size_t blocks = size / 16u; + const size_t tail = size % 16u; + uint8_t nonce[16] = {0}; + memcpy(nonce, iv, 8); + + if (blocks != 0) { + if (blocks > ULONG_MAX) abort(); + AES128_CTR_Stream(dst, (unsigned long)blocks, ctx->round_keys, nonce, 0); + } + if (tail != 0) { + uint8_t tail_block[16]; + if (blocks > UINT32_MAX) abort(); + AES128_CTR_Stream(tail_block, 1, ctx->round_keys, nonce, (uint32_t)blocks); + memcpy(dst + (blocks * 16u), tail_block, tail); + } +} + +void aes128ctr_free(aes128 *ctx) +{ + QRUOV_CLEANSE(ctx->round_keys, sizeof(ctx->round_keys)); +} +#elif defined(QRUOV_PRIM_OQS) +void aes128ctr_init(aes128 *ctx, const uint8_t key[16]) +{ + OQS_AES128_CTR_inc_init(key, &ctx->schedule); +} + +void aes128ctr_stream(aes128 *ctx, const uint8_t iv[8], uint8_t *dst, size_t size) +{ + if (size == 0) return; + // liboqs exits unless the IV is 12 or 16 bytes; QR-UOV passes 8 and zero-pads. + // Counter carry differs between backends past 2^32 blocks; QR-UOV stays far below. + uint8_t ctr_iv[16] = {0}; + memcpy(ctr_iv, iv, 8); + OQS_AES128_CTR_inc_stream_iv(ctr_iv, sizeof(ctr_iv), ctx->schedule, dst, size); +} + +void aes128ctr_free(aes128 *ctx) +{ + OQS_AES128_free_schedule(ctx->schedule); + ctx->schedule = NULL; +} +#else +void aes128ctr_init(aes128 *ctx, const uint8_t key[16]) +{ + ctx->cipher_ctx = EVP_CIPHER_CTX_new(); + if (ctx->cipher_ctx == NULL) abort(); + if (EVP_EncryptInit_ex2(ctx->cipher_ctx, EVP_aes_128_ctr(), key, NULL, NULL) != 1) abort(); +} + +void aes128ctr_stream(aes128 *ctx, const uint8_t iv[8], uint8_t *dst, size_t size) +{ + uint8_t ctr_iv[16] = {0}; + uint8_t *out = dst; + size_t remaining = size; + + memcpy(ctr_iv, iv, 8); + if (EVP_EncryptInit_ex2(ctx->cipher_ctx, NULL, NULL, ctr_iv, NULL) != 1) abort(); + + if (size == 0) return; + memset(dst, 0, size); + while (remaining != 0) { + const size_t chunk = remaining > (size_t)INT_MAX ? (size_t)INT_MAX : remaining; + const int in_size = (int)chunk; + int out_size = 0; + if (EVP_EncryptUpdate(ctx->cipher_ctx, out, &out_size, out, in_size) != 1) abort(); + if (out_size != in_size) abort(); + out += chunk; + remaining -= chunk; + } +} + +void aes128ctr_free(aes128 *ctx) +{ + EVP_CIPHER_CTX_free(ctx->cipher_ctx); + ctx->cipher_ctx = NULL; +} +#endif // PRIM_AES_BACKEND_X86AESNI diff --git a/src/sig/qruov/qruov_qruov_common/prim.h b/src/sig/qruov/qruov_qruov_common/prim.h new file mode 100644 index 0000000000..b84bddeb93 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/prim.h @@ -0,0 +1,83 @@ +#ifndef PRIM_H +#define PRIM_H + +#include +#include + +// QRUOV_PRIM_OQS: build against liboqs instead of OpenSSL, as in pqov's utils_hash.c. +#if defined(QRUOV_PRIM_OQS) +#include +#include + +// Defined even without EVP: test.c prints it unconditionally. +#define PRIM_NO_EVP_DIGEST_SQUEEZE 0 +#else +#include + +// OpenSSL < 3.3 does not provide EVP_DigestSqueeze(). +// For testing, defining PRIM_FORCE_NO_EVP_DIGEST_SQUEEZE forces +// the fallback path even when the API exists. +#if defined(PRIM_FORCE_NO_EVP_DIGEST_SQUEEZE) +#define PRIM_NO_EVP_DIGEST_SQUEEZE 1 +#else +#define PRIM_NO_EVP_DIGEST_SQUEEZE (!OPENSSL_VERSION_PREREQ(3, 3)) +#endif // PRIM_FORCE_NO_EVP_DIGEST_SQUEEZE +#endif // QRUOV_PRIM_OQS + +typedef struct shake256 { +#if defined(QRUOV_PRIM_OQS) + OQS_SHA3_shake256_inc_ctx st; + // liboqs needs an explicit finalize before the first squeeze; this API has + // none, so the first squeeze does it. + int finalized; +#else + EVP_MD_CTX *md_ctx; +#if PRIM_NO_EVP_DIGEST_SQUEEZE + size_t offset; + size_t cache_size; + uint8_t *cache; +#endif // PRIM_NO_EVP_DIGEST_SQUEEZE +#endif // QRUOV_PRIM_OQS +} shake256; + +typedef struct shake128 { +#if defined(QRUOV_PRIM_OQS) + OQS_SHA3_shake128_inc_ctx st; +#else + EVP_MD_CTX *md_ctx; +#endif // QRUOV_PRIM_OQS +} shake128; + +typedef struct aes128 { +#if defined(PRIM_AES_BACKEND_X86AESNI) + // AES-128 round keys (11 x 16 bytes), 16-byte aligned for AES-NI loads. + uint8_t round_keys[11 * 16] __attribute__((aligned(16))); +#elif defined(QRUOV_PRIM_OQS) + void *schedule; +#else + EVP_CIPHER_CTX *cipher_ctx; +#endif // PRIM_AES_BACKEND_X86AESNI +} aes128; + +// Requires: +// - message := update* -> digestfinal | update* -> squeeze* +// - call order: init -> message -> (reset -> message)* -> free +void shake256_init(shake256 *ctx); +void shake256_reset(shake256 *ctx); +void shake256_update(shake256 *ctx, const uint8_t *data, size_t size); +void shake256_digestfinal(shake256 *ctx, uint8_t *dst, size_t size); +void shake256_squeeze(shake256 *ctx, uint8_t *dst, size_t size); +void shake256_free(shake256 *ctx); + +// Requires: call order is init -> update* -> digestfinal -> free +void shake128_init(shake128 *ctx); +void shake128_update(shake128 *ctx, const uint8_t *data, size_t size); +void shake128_digestfinal(shake128 *ctx, uint8_t *dst, size_t size); +void shake128_free(shake128 *ctx); + +// Requires: call order is init -> stream* -> free +void aes128ctr_init(aes128 *ctx, const uint8_t key[16]); +void aes128ctr_stream(aes128 *ctx, const uint8_t iv[8], uint8_t *dst, size_t size); +void aes128ctr_free(aes128 *ctx); + +#endif // PRIM_H diff --git a/src/sig/qruov/qruov_qruov_common/qrop.c b/src/sig/qruov/qruov_qruov_common/qrop.c new file mode 100644 index 0000000000..bc70ea95bc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qrop.c @@ -0,0 +1,205 @@ +#include +#include "qrop.h" +#include "fastop.h" +#include "prim.h" +#include "util.h" + +static void expand_transposed_matrix_MxV(uint8_t *mat, const uint8_t *vec) +{ + const uint8_t *ptr = vec; + for (int i = 0; i < QRUOV_V; i++) { + for (int j = 0; j < QRUOV_M; j++) { + memcpy(&mat[(j * QRUOV_V + i) * QRUOV_L], ptr, QRUOV_L); + ptr += QRUOV_L; + } + } +} + +static void unpack_upper_to_symm(uint8_t *dst, const uint8_t *packed_upper, int dim) +{ + size_t offset = 0; + for (int i = 0; i < dim; i++) { + for (int j = i; j < dim; j++) { + memcpy(&dst[(i * dim + j) * QRUOV_L], packed_upper + offset, QRUOV_L); + memcpy(&dst[(j * dim + i) * QRUOV_L], packed_upper + offset, QRUOV_L); + offset += QRUOV_L; + } + } +} + +void p3_store_upper_MxM(uint8_t upper[P3_EQ_COEFF_LEN], + const uint8_t src[QRUOV_M * QRUOV_M * QRUOV_L]) +{ + size_t offset = 0; + for (int i = 0; i < QRUOV_M; i++) { + for (int j = i; j < QRUOV_M; j++) { + memcpy(upper + offset, &src[(i * QRUOV_M + j) * QRUOV_L], QRUOV_L); + offset += QRUOV_L; + } + } +} + +void unpack_upper_to_symm_VxV(uint8_t dst[QRUOV_V * QRUOV_V * QRUOV_L], + const uint8_t packed_upper[QRUOV_n1]) +{ + unpack_upper_to_symm(dst, packed_upper, QRUOV_V); +} + +void unpack_upper_to_symm_MxM(uint8_t dst[QRUOV_M * QRUOV_M * QRUOV_L], + const uint8_t packed_upper[P3_EQ_COEFF_LEN]) +{ + unpack_upper_to_symm(dst, packed_upper, QRUOV_M); +} + +int load_fq_checked(uint8_t *dst, const uint8_t *src, size_t dst_len) +{ + if (!check_fq_trailing_bits(src, dst_len)) return 0; + load_fq(dst, src, dst_len); + return memchr(dst, QRUOV_q, dst_len) == NULL; +} + +void rejection_sample(uint8_t *dst, int tau, int length) +{ + fastop_rejection_sample(dst, tau, length); +} + +void compute_mu_and_hash(uint8_t out[QRUOV_m], const SEED_PK seed_pk, const uint8_t *msg, size_t msg_len, const SALT sig_r) +{ + uint8_t mu[64]; + uint8_t sampled[QRUOV_tau_m]; + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_pk, SEED_PK_LEN); + shake256_update(&st, msg, msg_len); + shake256_digestfinal(&st, mu, sizeof(mu)); + shake256_reset(&st); + shake256_update(&st, mu, sizeof(mu)); + shake256_update(&st, sig_r, SALT_LEN); + shake256_digestfinal(&st, sampled, sizeof(sampled)); + shake256_free(&st); + rejection_sample(sampled, QRUOV_tau_m, QRUOV_m); + memcpy(out, sampled, QRUOV_m); +} + +void compute_mu(uint8_t mu[64], const SEED_PK seed_pk, const uint8_t *msg, size_t msg_len) +{ + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_pk, SEED_PK_LEN); + shake256_update(&st, msg, msg_len); + shake256_digestfinal(&st, mu, 64); + shake256_free(&st); +} + +void compute_hash(uint8_t t[QRUOV_m], const uint8_t mu[64], const SALT sig_r) +{ + uint8_t sampled[QRUOV_tau_m]; + shake256 st; + shake256_init(&st); + shake256_update(&st, mu, 64); + shake256_update(&st, sig_r, SALT_LEN); + shake256_digestfinal(&st, sampled, sizeof(sampled)); + shake256_free(&st); + rejection_sample(sampled, QRUOV_tau_m, QRUOV_m); + memcpy(t, sampled, QRUOV_m); +} + +void prepare_y_from_seed(uint8_t y[QRUOV_V * QRUOV_L], const SEED_SK seed_y) +{ + uint8_t y_buf[QRUOV_tau_v]; + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_y, SEED_SK_LEN); + shake256_digestfinal(&st, y_buf, QRUOV_tau_v); + shake256_free(&st); + rejection_sample(y_buf, QRUOV_tau_v, QRUOV_v); + memcpy(y, y_buf, QRUOV_V * QRUOV_L); + secure_zero(y_buf, sizeof(y_buf)); +} + +void prepare_sol_from_seed(uint8_t free_oil[QRUOV_m], const SEED_SK seed_sol) +{ + uint8_t free_oil_buf[QRUOV_tau_m]; + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_sol, SEED_SK_LEN); + shake256_digestfinal(&st, free_oil_buf, QRUOV_tau_m); + shake256_free(&st); + rejection_sample(free_oil_buf, QRUOV_tau_m, QRUOV_m); + memcpy(free_oil, free_oil_buf, QRUOV_m); + secure_zero(free_oil_buf, sizeof(free_oil_buf)); +} + +void prepare_seed_pk_from_seed(SEED_PK seed_pk, const SEED_SK seed_sk) +{ + uint8_t idx_be[2]; + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_sk, SEED_SK_LEN); + store_u16_be(idx_be, 1); + shake256_update(&st, idx_be, sizeof(idx_be)); + shake256_digestfinal(&st, seed_pk, SEED_PK_LEN); + shake256_free(&st); +} + +void prepare_sd_from_seed(uint8_t sd[QRUOV_tau_n2], const SEED_SK seed_sk) +{ + uint8_t idx_be[2]; + shake256 st; + shake256_init(&st); + shake256_update(&st, seed_sk, SEED_SK_LEN); + store_u16_be(idx_be, 0); + shake256_update(&st, idx_be, sizeof(idx_be)); + shake256_digestfinal(&st, sd, QRUOV_tau_n2); + shake256_free(&st); + rejection_sample(sd, QRUOV_tau_n2, QRUOV_n2); +} + +void prepare_sdt_from_sd(uint8_t *sdt_MxV, const uint8_t sd[QRUOV_tau_n2]) +{ + expand_transposed_matrix_MxV(sdt_MxV, sd); +} + +void prepare_sdt_from_seed(uint8_t *sdt_MxV, const SEED_SK seed_sk) +{ + uint8_t sd[QRUOV_tau_n2]; + prepare_sd_from_seed(sd, seed_sk); + prepare_sdt_from_sd(sdt_MxV, sd); + secure_zero(sd, sizeof(sd)); +} + +void prepare_pi1_raw_from_prg(uint8_t pi1_raw[QRUOV_tau_n1], prg *pk_prg, uint16_t eq) +{ + prg_yield(pk_prg, pi1_raw, (uint16_t)(2 * eq), QRUOV_tau_n1); +} + +void prepare_pi1_coeffs_from_prg(uint8_t pi1_coeffs[QRUOV_tau_n1], prg *pk_prg, uint16_t eq) +{ + prepare_pi1_raw_from_prg(pi1_coeffs, pk_prg, eq); + rejection_sample(pi1_coeffs, QRUOV_tau_n1, QRUOV_n1); +} + +void prepare_pi1_from_prg(uint8_t *pi1_VxV, prg *pk_prg, uint16_t eq) +{ + uint8_t pi1_coeffs[QRUOV_tau_n1]; + prepare_pi1_coeffs_from_prg(pi1_coeffs, pk_prg, eq); + unpack_upper_to_symm_VxV(pi1_VxV, pi1_coeffs); +} + +void prepare_pi2_raw_from_prg(uint8_t pi2_raw[QRUOV_tau_n2], prg *pk_prg, uint16_t eq) +{ + prg_yield(pk_prg, pi2_raw, (uint16_t)(2 * eq + 1), QRUOV_tau_n2); +} + +void prepare_pi2_coeffs_from_prg(uint8_t pi2_coeffs[QRUOV_tau_n2], prg *pk_prg, uint16_t eq) +{ + prepare_pi2_raw_from_prg(pi2_coeffs, pk_prg, eq); + rejection_sample(pi2_coeffs, QRUOV_tau_n2, QRUOV_n2); +} + +void prepare_pi2t_from_prg(uint8_t *pi2t_MxV, prg *pk_prg, uint16_t eq) +{ + uint8_t pi2_coeffs[QRUOV_tau_n2]; + prepare_pi2_coeffs_from_prg(pi2_coeffs, pk_prg, eq); + expand_transposed_matrix_MxV(pi2t_MxV, pi2_coeffs); +} diff --git a/src/sig/qruov/qruov_qruov_common/qrop.h b/src/sig/qruov/qruov_qruov_common/qrop.h new file mode 100644 index 0000000000..2691607231 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qrop.h @@ -0,0 +1,57 @@ +#ifndef QROP_H +#define QROP_H + +#include "qruov.h" +#include "fastop.h" +#include "prg.h" + +#define P3_CHUNK_EQS 8 +#define P3_CHUNK_COEFF_LEN (P3_CHUNK_EQS * P3_EQ_COEFF_LEN) + +void rejection_sample(uint8_t *dst, int tau, int length); +void compute_mu_and_hash(uint8_t out[QRUOV_m], const SEED_PK seed_pk, const uint8_t *msg, size_t msg_len, const SALT sig_r); +void compute_mu(uint8_t mu[64], const SEED_PK seed_pk, const uint8_t *msg, size_t msg_len); +void compute_hash(uint8_t t[QRUOV_m], const uint8_t mu[64], const SALT sig_r); +void prepare_seed_pk_from_seed(SEED_PK seed_pk, const SEED_SK seed_sk); +void prepare_sd_from_seed(uint8_t sd[QRUOV_tau_n2], const SEED_SK seed_sk); +void prepare_sdt_from_sd(uint8_t *sdt_MxV, const uint8_t sd[QRUOV_tau_n2]); +void prepare_y_from_seed(uint8_t y[QRUOV_V * QRUOV_L], const SEED_SK seed_y); +void prepare_sol_from_seed(uint8_t free_oil[QRUOV_m], const SEED_SK seed_sol); +void prepare_sdt_from_seed(uint8_t *sdt_MxV, const SEED_SK seed_sk); +void prepare_pi1_raw_from_prg(uint8_t pi1_raw[QRUOV_tau_n1], prg *pk_prg, uint16_t eq); +void prepare_pi2_raw_from_prg(uint8_t pi2_raw[QRUOV_tau_n2], prg *pk_prg, uint16_t eq); +void prepare_pi1_coeffs_from_prg(uint8_t pi1_coeffs[QRUOV_tau_n1], prg *pk_prg, uint16_t eq); +void prepare_pi2_coeffs_from_prg(uint8_t pi2_coeffs[QRUOV_tau_n2], prg *pk_prg, uint16_t eq); +void prepare_pi1_from_prg(uint8_t *pi1_VxV, prg *pk_prg, uint16_t eq); +void prepare_pi2t_from_prg(uint8_t *pi2t_MxV, prg *pk_prg, uint16_t eq); +void p3_store_upper_MxM(uint8_t upper[P3_EQ_COEFF_LEN], + const uint8_t src[QRUOV_M * QRUOV_M * QRUOV_L]); +void unpack_upper_to_symm_VxV(uint8_t dst[QRUOV_V * QRUOV_V * QRUOV_L], + const uint8_t packed_upper[QRUOV_n1]); +void unpack_upper_to_symm_MxM(uint8_t dst[QRUOV_M * QRUOV_M * QRUOV_L], + const uint8_t packed_upper[P3_EQ_COEFF_LEN]); +int load_fq_checked(uint8_t *dst, const uint8_t *src, size_t dst_len); + +// Checks that unused high bits in the last packed byte are zero. +static inline int check_fq_trailing_bits(const uint8_t *src, size_t dst_len) +{ + const unsigned used_bits = (unsigned)((QRUOV_q_LOG * dst_len) & 7u); + if (used_bits == 0) return 1; + const size_t src_len = BITS2BYTE(QRUOV_q_LOG * dst_len); + const uint8_t mask = (uint8_t)((1u << used_bits) - 1u); + return (src[src_len - 1] & (uint8_t)~mask) == 0; +} + +// Requires: src[i] in [0, QRUOV_q). No validation/reduction for speed. +static inline void store_fq(uint8_t *dst, const uint8_t *src, size_t src_len) +{ + fastop_store_fq(dst, src, src_len); +} + +// Requires: src is canonical packed Fq. No validation/reduction for speed. +static inline void load_fq(uint8_t *dst, const uint8_t *src, size_t dst_len) +{ + fastop_load_fq(dst, src, dst_len); +} + +#endif // QROP_H diff --git a/src/sig/qruov/qruov_qruov_common/qruov.h b/src/sig/qruov/qruov_qruov_common/qruov.h new file mode 100644 index 0000000000..aceca9d0c8 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qruov.h @@ -0,0 +1,84 @@ +#ifndef QRUOV_H +#define QRUOV_H + +#include +#include + +#include "qruov_param.h" +#include "qruov_tau.h" + +#define QRUOV_n (QRUOV_v + QRUOV_m) +#define QRUOV_N (QRUOV_n / QRUOV_L) +#define QRUOV_V (QRUOV_v / QRUOV_L) +#define QRUOV_M (QRUOV_m / QRUOV_L) + +#define QRUOV_n1 (QRUOV_L * QRUOV_V * (QRUOV_V + 1) / 2) +#define QRUOV_n2 (QRUOV_L * QRUOV_V * QRUOV_M) +#define QRUOV_perm(t) ((t <= QRUOV_fe - 1) ? (QRUOV_fe - 1 - t) : (QRUOV_L + QRUOV_fe - 1 - t)) + +#if QRUOV_q == 127 +#define QRUOV_q_LOG 7 +#elif QRUOV_q == 31 +#define QRUOV_q_LOG 5 +#elif QRUOV_q == 7 +#define QRUOV_q_LOG 3 +#else +#error "Unsupported QRUOV_q" +#endif // QRUOV_q + +#define BITS2BYTE(x) (((x) + 7) >> 3) +#define SEED_PK_LEN 16 +#define SEED_SK_LEN 32 + +#if QRUOV_security == 1 +#define SALT_LEN 16 +#elif QRUOV_security == 3 +#define SALT_LEN 24 +#elif QRUOV_security == 5 +#define SALT_LEN 32 +#else +#error "Unsupported QRUOV_security" +#endif + +#define P3_EQ_COEFF_LEN (QRUOV_L * QRUOV_M * (QRUOV_M + 1) / 2) +#define P3_COEFF_LEN (QRUOV_m * P3_EQ_COEFF_LEN) +#define SIG_S_COEFF_LEN (QRUOV_L * QRUOV_N) + +#define P3_SERIALIZED_LEN BITS2BYTE(QRUOV_q_LOG * P3_COEFF_LEN) +#define SIG_S_SERIALIZED_LEN BITS2BYTE(QRUOV_q_LOG * SIG_S_COEFF_LEN) + +#define QRUOV_POW0(x) (1) +#define QRUOV_POW1(x) (((x) + QRUOV_q) % QRUOV_q) +#define QRUOV_POW2(x) (QRUOV_POW1(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW3(x) (QRUOV_POW2(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW4(x) (QRUOV_POW3(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW5(x) (QRUOV_POW4(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW6(x) (QRUOV_POW5(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW7(x) (QRUOV_POW6(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW8(x) (QRUOV_POW7(x) * QRUOV_POW1(x) % QRUOV_q) +#define QRUOV_POW9(x) (QRUOV_POW8(x) * QRUOV_POW1(x) % QRUOV_q) + +#define QRUOV_SIG_LEN (SALT_LEN + SIG_S_SERIALIZED_LEN) +#define QRUOV_PK_LEN (SEED_PK_LEN + P3_SERIALIZED_LEN) +#define QRUOV_SK_LEN SEED_SK_LEN + +#define QRUOV_STR_(x) #x +#define QRUOV_STR(x) QRUOV_STR_(x) +#if PRG_IS_AES +#define QRUOV_PRG_NAME "aes" +#else +#define QRUOV_PRG_NAME "shake" +#endif // PRG_IS_AES +#define QRUOV_ALGNAME "qruov" QRUOV_STR(QRUOV_security) "q" QRUOV_STR(QRUOV_q) "l" QRUOV_STR(QRUOV_L) "v" QRUOV_STR(QRUOV_v) "m" QRUOV_STR(QRUOV_m) QRUOV_PRG_NAME + +typedef uint8_t SEED_PK[SEED_PK_LEN]; +typedef uint8_t SEED_SK[SEED_SK_LEN]; +typedef uint8_t SALT[SALT_LEN]; +typedef uint8_t SIG_S[SIG_S_COEFF_LEN]; + +void qruov_init(void); +void qruov_keygen(const SEED_PK seed_pk, const SEED_SK seed_sk, uint8_t pk_p3[P3_SERIALIZED_LEN]); +int qruov_sign(const SEED_PK seed_pk, const SEED_SK seed_sk, const SEED_SK seed_y, const SEED_SK seed_r, const SEED_SK seed_sol, const uint8_t msg[], size_t msg_len, SALT sig_r, SIG_S sig_s); +int qruov_verify(const SEED_PK seed_pk, const uint8_t pk_p3[P3_SERIALIZED_LEN], const uint8_t msg[], size_t msg_len, const SALT sig_r, const SIG_S sig_s); + +#endif // QRUOV_H diff --git a/src/sig/qruov/qruov_qruov_common/qruov_common.c b/src/sig/qruov/qruov_qruov_common/qruov_common.c new file mode 100644 index 0000000000..b9f573b185 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qruov_common.c @@ -0,0 +1,163 @@ +#include "qruov_common.h" + +#include + +#include "fql.h" +#include "gf.h" +#include "linsys.h" +#include "qrop.h" +#include "util.h" + +static void fql_sub_V(uint8_t *dst, const uint8_t *x_V, const uint8_t *y_V) +{ + for (int i = 0; i < QRUOV_V; i++) { + fql_sub(&dst[i * QRUOV_L], &x_V[i * QRUOV_L], &y_V[i * QRUOV_L]); + } +} + +int qruov_common_is_canonical_s(const SIG_S sig_s) +{ + for (int i = 0; i < SIG_S_COEFF_LEN; i++) { + uint8_t a = sig_s[i]; + if (a != 0) { + return a <= (QRUOV_q - 1) / 2; + } + } + return 1; +} + +void qruov_common_canonicalize_s(SIG_S sig_s) +{ + if (qruov_common_is_canonical_s(sig_s)) return; + for (int i = 0; i < SIG_S_COEFF_LEN; i++) { + if (sig_s[i] != 0) { + sig_s[i] = (uint8_t)(QRUOV_q - sig_s[i]); + } + } +} + +static void sign_build_system(uint8_t eqn_out[QRUOV_m * QRUOV_m], + uint8_t u_out[QRUOV_m], + const uint8_t sdt[QRUOV_M * QRUOV_V * QRUOV_L], + const uint8_t y[QRUOV_V * QRUOV_L], + const SEED_PK seed_pk) +{ + const int perm0 = QRUOV_perm(0); + prg pk_prg; + uint8_t pi1_y[QRUOV_V * QRUOV_L]; + uint8_t y_pi1_y[QRUOV_L]; + uint8_t y_pi1_sd[QRUOV_M * QRUOV_L]; + uint8_t y_pi2[QRUOV_M * QRUOV_L]; + uint8_t y_fi2[QRUOV_M * QRUOV_L]; + prg_init(&pk_prg, seed_pk); + for (int eq = 0; eq < QRUOV_m; eq++) { + uint8_t pi1[QRUOV_V * QRUOV_V * QRUOV_L]; + uint8_t pi2t[QRUOV_M * QRUOV_V * QRUOV_L]; + prepare_pi1_from_prg(pi1, &pk_prg, (uint16_t)eq); + prepare_pi2t_from_prg(pi2t, &pk_prg, (uint16_t)eq); + fql_mul_VxV_V(pi1_y, pi1, y); + fql_dot_V(y_pi1_y, y, pi1_y); + fql_mul_MxV_V(y_pi1_sd, sdt, pi1_y); + fql_mul_MxV_V(y_pi2, pi2t, y); + fql_sub_M(y_fi2, y_pi2, y_pi1_sd); + fql_add_M(y_fi2, y_fi2, y_fi2); + fql_perm_M(&eqn_out[eq * QRUOV_m], y_fi2); + u_out[eq] = y_pi1_y[perm0]; + } + prg_free(&pk_prg); + secure_zero(y_fi2, sizeof(y_fi2)); + secure_zero(y_pi2, sizeof(y_pi2)); + secure_zero(y_pi1_sd, sizeof(y_pi1_sd)); + secure_zero(y_pi1_y, sizeof(y_pi1_y)); + secure_zero(pi1_y, sizeof(pi1_y)); +} + +void qruov_common_sig_s(SIG_S sig_s, + const uint8_t sd[QRUOV_tau_n2], + const uint8_t y[QRUOV_V * QRUOV_L], + const uint8_t oil[QRUOV_m]) +{ + uint8_t sd_o[QRUOV_V * QRUOV_L]; + fql_mul_VxM_M(sd_o, sd, oil); + fql_sub_V(sig_s, y, sd_o); + memcpy(&sig_s[QRUOV_V * QRUOV_L], oil, QRUOV_M * QRUOV_L); + qruov_common_canonicalize_s(sig_s); + secure_zero(sd_o, sizeof(sd_o)); +} + +int qruov_common_sign_solve_oil(uint8_t oil_out[QRUOV_m], SALT sig_r_out, + uint8_t eqn[QRUOV_m * QRUOV_m], + const uint8_t u[QRUOV_m], + const SEED_PK seed_pk, const SEED_SK seed_r, + const SEED_SK seed_sol, const uint8_t *msg, + size_t msg_len) +{ + int ret = 1; + uint8_t mu[64]; + compute_mu(mu, seed_pk, msg, msg_len); + uint8_t free_oil[QRUOV_m]; + prepare_sol_from_seed(free_oil, seed_sol); + uint8_t t[QRUOV_m]; + uint8_t rhs[QRUOV_m]; + uint8_t consistency_rhs[QRUOV_m]; + linsys_echelon echelon; + linsys_lu_decompose(eqn, &echelon); + int rank = echelon.rank; + if (rank < QRUOV_m - QRUOV_delta) { + goto cleanup; + } + if (rank < QRUOV_m) { + linsys_prepare_consistency(&echelon, u, consistency_rhs); + } + shake256 r_stream; + shake256_init(&r_stream); + shake256_update(&r_stream, seed_r, SEED_SK_LEN); + for (;;) { + shake256_squeeze(&r_stream, sig_r_out, SALT_LEN); + compute_hash(t, mu, sig_r_out); + if (rank == QRUOV_m || linsys_check_prepared_consistency(&echelon, consistency_rhs, t)) { + for (int i = 0; i < QRUOV_m; i++) rhs[i] = gf_sub(t[i], u[i]); + linsys_sample_solution(&echelon, rhs, free_oil, oil_out); + ret = 0; + break; + } + } + shake256_free(&r_stream); +cleanup: + secure_zero(consistency_rhs, sizeof(consistency_rhs)); + secure_zero(rhs, sizeof(rhs)); + secure_zero(t, sizeof(t)); + secure_zero(&echelon, sizeof(echelon)); + secure_zero(free_oil, sizeof(free_oil)); + secure_zero(mu, sizeof(mu)); + return ret; +} + +int qruov_common_sign_scalar(const SEED_PK seed_pk, const SEED_SK seed_sk, + const SEED_SK seed_y, const SEED_SK seed_r, + const SEED_SK seed_sol, const uint8_t msg[], + size_t msg_len, SALT sig_r, SIG_S sig_s) +{ + uint8_t sd[QRUOV_tau_n2]; + uint8_t sdt[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t y[QRUOV_V * QRUOV_L]; // vinegar + uint8_t eqn[QRUOV_m * QRUOV_m]; // L + uint8_t u[QRUOV_m]; + prepare_sd_from_seed(sd, seed_sk); + prepare_sdt_from_sd(sdt, sd); + prepare_y_from_seed(y, seed_y); + sign_build_system(eqn, u, sdt, y, seed_pk); + uint8_t oil[QRUOV_m]; + int ret = qruov_common_sign_solve_oil(oil, sig_r, eqn, u, seed_pk, seed_r, + seed_sol, msg, msg_len); + if (ret == 0) { + qruov_common_sig_s(sig_s, sd, y, oil); + } + secure_zero(oil, sizeof(oil)); + secure_zero(y, sizeof(y)); + secure_zero(u, sizeof(u)); + secure_zero(sd, sizeof(sd)); + secure_zero(sdt, sizeof(sdt)); + secure_zero(eqn, sizeof(eqn)); + return ret; +} diff --git a/src/sig/qruov/qruov_qruov_common/qruov_common.h b/src/sig/qruov/qruov_qruov_common/qruov_common.h new file mode 100644 index 0000000000..27aae0a886 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qruov_common.h @@ -0,0 +1,25 @@ +#ifndef QRUOV_COMMON_H +#define QRUOV_COMMON_H + +#include +#include +#include "qruov.h" + +void qruov_common_sig_s(SIG_S sig_s, const uint8_t sd[QRUOV_tau_n2], + const uint8_t y[QRUOV_V * QRUOV_L], + const uint8_t oil[QRUOV_m]); +int qruov_common_is_canonical_s(const SIG_S sig_s); +void qruov_common_canonicalize_s(SIG_S sig_s); + +int qruov_common_sign_solve_oil(uint8_t oil_out[QRUOV_m], SALT sig_r_out, + uint8_t eqn[QRUOV_m * QRUOV_m], + const uint8_t u[QRUOV_m], + const SEED_PK seed_pk, const SEED_SK seed_r, + const SEED_SK seed_sol, const uint8_t *msg, + size_t msg_len); +int qruov_common_sign_scalar(const SEED_PK seed_pk, const SEED_SK seed_sk, + const SEED_SK seed_y, const SEED_SK seed_r, + const SEED_SK seed_sol, const uint8_t msg[], + size_t msg_len, SALT sig_r, SIG_S sig_s); + +#endif // QRUOV_COMMON_H diff --git a/src/sig/qruov/qruov_qruov_common/qruov_param.h b/src/sig/qruov/qruov_qruov_common/qruov_param.h new file mode 100644 index 0000000000..dcd1cc78ea --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qruov_param.h @@ -0,0 +1,212 @@ +#ifndef QRUOV_PARAM_H +#define QRUOV_PARAM_H + +#ifndef PRG_IS_AES +#define PRG_IS_AES 1 +#endif // PRG_IS_AES +#if (PRG_IS_AES != 0) && (PRG_IS_AES != 1) +#error "PRG_IS_AES must be 0 or 1" +#endif // PRG_IS_AES != 0 && PRG_IS_AES != 1 + +// Select one parameter set with -DQRUOV_PARAM_qL +// Example: -DQRUOV_PARAM_1q127L3 + +#if !defined(QRUOV_PARAM_1q7L10) \ + && !defined(QRUOV_PARAM_1q31L3) \ + && !defined(QRUOV_PARAM_1q31L10) \ + && !defined(QRUOV_PARAM_1q127L3) \ + && !defined(QRUOV_PARAM_1q127L10) \ + && !defined(QRUOV_PARAM_3q7L10) \ + && !defined(QRUOV_PARAM_3q31L3) \ + && !defined(QRUOV_PARAM_3q31L10) \ + && !defined(QRUOV_PARAM_3q127L3) \ + && !defined(QRUOV_PARAM_3q127L10) \ + && !defined(QRUOV_PARAM_5q7L10) \ + && !defined(QRUOV_PARAM_5q31L3) \ + && !defined(QRUOV_PARAM_5q31L10) \ + && !defined(QRUOV_PARAM_5q127L3) \ + && !defined(QRUOV_PARAM_5q127L10) +#warning "Using default parameter set QRUOV_PARAM_1q127L3" +#define QRUOV_PARAM_1q127L3 +#endif + +#if defined(QRUOV_PARAM_1q7L10) +#define QRUOV_security 1 +#define QRUOV_q 7 +#define QRUOV_L 10 +#define QRUOV_v 740 +#define QRUOV_m 100 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_3q7L10) +#define QRUOV_security 3 +#define QRUOV_q 7 +#define QRUOV_L 10 +#define QRUOV_v 1100 +#define QRUOV_m 140 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_5q7L10) +#define QRUOV_security 5 +#define QRUOV_q 7 +#define QRUOV_L 10 +#define QRUOV_v 1490 +#define QRUOV_m 190 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_1q31L3) +#define QRUOV_security 1 +#define QRUOV_q 31 +#define QRUOV_L 3 +#define QRUOV_v 165 +#define QRUOV_m 60 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_3q31L3) +#define QRUOV_security 3 +#define QRUOV_q 31 +#define QRUOV_L 3 +#define QRUOV_v 246 +#define QRUOV_m 87 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_5q31L3) +#define QRUOV_security 5 +#define QRUOV_q 31 +#define QRUOV_L 3 +#define QRUOV_v 324 +#define QRUOV_m 114 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_1q31L10) +#define QRUOV_security 1 +#define QRUOV_q 31 +#define QRUOV_L 10 +#define QRUOV_v 600 +#define QRUOV_m 70 +#define QRUOV_fc 5 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if defined(QRUOV_PARAM_3q31L10) +#define QRUOV_security 3 +#define QRUOV_q 31 +#define QRUOV_L 10 +#define QRUOV_v 890 +#define QRUOV_m 100 +#define QRUOV_fc 5 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if defined(QRUOV_PARAM_5q31L10) +#define QRUOV_security 5 +#define QRUOV_q 31 +#define QRUOV_L 10 +#define QRUOV_v 1120 +#define QRUOV_m 120 +#define QRUOV_fc 5 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if defined(QRUOV_PARAM_1q127L3) +#define QRUOV_security 1 +#define QRUOV_q 127 +#define QRUOV_L 3 +#define QRUOV_v 156 +#define QRUOV_m 54 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_1q127L10) +#define QRUOV_security 1 +#define QRUOV_q 127 +#define QRUOV_L 10 +#define QRUOV_v 540 +#define QRUOV_m 60 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if defined(QRUOV_PARAM_3q127L3) +#define QRUOV_security 3 +#define QRUOV_q 127 +#define QRUOV_L 3 +#define QRUOV_v 228 +#define QRUOV_m 78 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_3q127L10) +#define QRUOV_security 3 +#define QRUOV_q 127 +#define QRUOV_L 10 +#define QRUOV_v 820 +#define QRUOV_m 90 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if defined(QRUOV_PARAM_5q127L3) +#define QRUOV_security 5 +#define QRUOV_q 127 +#define QRUOV_L 3 +#define QRUOV_v 306 +#define QRUOV_m 105 +#define QRUOV_fc 1 +#define QRUOV_fc0 1 +#define QRUOV_fe 1 +#endif + +#if defined(QRUOV_PARAM_5q127L10) +#define QRUOV_security 5 +#define QRUOV_q 127 +#define QRUOV_L 10 +#define QRUOV_v 1040 +#define QRUOV_m 110 +#define QRUOV_fc 2 +#define QRUOV_fc0 1 +#define QRUOV_fe 3 +#endif + +#if QRUOV_q == 127 +#define QRUOV_delta 2 +#elif QRUOV_q == 31 +#define QRUOV_delta 3 +#elif QRUOV_q == 7 +#define QRUOV_delta 4 +#else +#error "Unsupported QRUOV_q" +#endif // QRUOV_q + +#if QRUOV_delta < 0 || QRUOV_delta > QRUOV_m +#error "Invalid QRUOV_delta" +#endif // QRUOV_delta < 0 || QRUOV_delta > QRUOV_m + +#endif // QRUOV_PARAM_H diff --git a/src/sig/qruov/qruov_qruov_common/qruov_tau.h b/src/sig/qruov/qruov_qruov_common/qruov_tau.h new file mode 100644 index 0000000000..bd0223bd88 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/qruov_tau.h @@ -0,0 +1,89 @@ +#ifndef QRUOV_TAU_H +#define QRUOV_TAU_H + + +#if (QRUOV_q == 127) && (QRUOV_L == 3) && (QRUOV_v == 156) && (QRUOV_m == 54) +#define QRUOV_tau_n1 4267 +#define QRUOV_tau_n2 2916 +#define QRUOV_tau_v 192 +#define QRUOV_tau_m 82 +#elif (QRUOV_q == 127) && (QRUOV_L == 10) && (QRUOV_v == 540) && (QRUOV_m == 60) +#define QRUOV_tau_n1 15135 +#define QRUOV_tau_n2 3357 +#define QRUOV_tau_v 594 +#define QRUOV_tau_m 89 +#elif (QRUOV_q == 31) && (QRUOV_L == 3) && (QRUOV_v == 165) && (QRUOV_m == 60) +#define QRUOV_tau_n1 4959 +#define QRUOV_tau_n2 3571 +#define QRUOV_tau_v 226 +#define QRUOV_tau_m 104 +#elif (QRUOV_q == 31) && (QRUOV_L == 10) && (QRUOV_v == 600) && (QRUOV_m == 70) +#define QRUOV_tau_n1 19242 +#define QRUOV_tau_n2 4518 +#define QRUOV_tau_v 704 +#define QRUOV_tau_m 116 +#elif (QRUOV_q == 7) && (QRUOV_L == 10) && (QRUOV_v == 740) && (QRUOV_m == 100) +#define QRUOV_tau_n1 32629 +#define QRUOV_tau_n2 8947 +#define QRUOV_tau_v 1024 +#define QRUOV_tau_m 201 +#elif (QRUOV_q == 127) && (QRUOV_L == 3) && (QRUOV_v == 228) && (QRUOV_m == 78) +#define QRUOV_tau_n1 9020 +#define QRUOV_tau_n2 6123 +#define QRUOV_tau_v 283 +#define QRUOV_tau_m 120 +#elif (QRUOV_q == 127) && (QRUOV_L == 10) && (QRUOV_v == 820) && (QRUOV_m == 90) +#define QRUOV_tau_n1 34603 +#define QRUOV_tau_n2 7600 +#define QRUOV_tau_v 902 +#define QRUOV_tau_m 134 +#elif (QRUOV_q == 31) && (QRUOV_L == 3) && (QRUOV_v == 246) && (QRUOV_m == 87) +#define QRUOV_tau_n1 10878 +#define QRUOV_tau_n2 7655 +#define QRUOV_tau_v 338 +#define QRUOV_tau_m 154 +#elif (QRUOV_q == 31) && (QRUOV_L == 10) && (QRUOV_v == 890) && (QRUOV_m == 100) +#define QRUOV_tau_n1 41974 +#define QRUOV_tau_n2 9507 +#define QRUOV_tau_v 1046 +#define QRUOV_tau_m 169 +#elif (QRUOV_q == 7) && (QRUOV_L == 10) && (QRUOV_v == 1100) && (QRUOV_m == 140) +#define QRUOV_tau_n1 71432 +#define QRUOV_tau_n2 18461 +#define QRUOV_tau_v 1526 +#define QRUOV_tau_m 289 +#elif (QRUOV_q == 127) && (QRUOV_L == 3) && (QRUOV_v == 306) && (QRUOV_m == 105) +#define QRUOV_tau_n1 16144 +#define QRUOV_tau_n2 11018 +#define QRUOV_tau_v 380 +#define QRUOV_tau_m 162 +#elif (QRUOV_q == 127) && (QRUOV_L == 10) && (QRUOV_v == 1110) && (QRUOV_m == 120) +#define QRUOV_tau_n1 63119 +#define QRUOV_tau_n2 13669 +#define QRUOV_tau_v 1220 +#define QRUOV_tau_m 179 +#elif (QRUOV_q == 127) && (QRUOV_L == 10) && (QRUOV_v == 1040) && (QRUOV_m == 110) +#define QRUOV_tau_n1 55473 +#define QRUOV_tau_n2 11760 +#define QRUOV_tau_v 1148 +#define QRUOV_tau_m 168 +#elif (QRUOV_q == 31) && (QRUOV_L == 3) && (QRUOV_v == 324) && (QRUOV_m == 114) +#define QRUOV_tau_n1 18738 +#define QRUOV_tau_n2 13145 +#define QRUOV_tau_v 447 +#define QRUOV_tau_m 203 +#elif (QRUOV_q == 31) && (QRUOV_L == 10) && (QRUOV_v == 1120) && (QRUOV_m == 120) +#define QRUOV_tau_n1 66236 +#define QRUOV_tau_n2 14326 +#define QRUOV_tau_v 1324 +#define QRUOV_tau_m 210 +#elif (QRUOV_q == 7) && (QRUOV_L == 10) && (QRUOV_v == 1490) && (QRUOV_m == 190) +#define QRUOV_tau_n1 130305 +#define QRUOV_tau_n2 33694 +#define QRUOV_tau_v 2065 +#define QRUOV_tau_m 391 +#else +#error "Unknown QR-UOV parameter tuple for tau table" +#endif + +#endif // QRUOV_TAU_H diff --git a/src/sig/qruov/qruov_qruov_common/randombytes.c b/src/sig/qruov/qruov_qruov_common/randombytes.c new file mode 100644 index 0000000000..4adb016629 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/randombytes.c @@ -0,0 +1,6 @@ +#include + +void randombytes(unsigned char *x, unsigned long long xlen) +{ + OQS_randombytes(x, xlen); +} diff --git a/src/sig/qruov/qruov_qruov_common/rng.h b/src/sig/qruov/qruov_qruov_common/rng.h new file mode 100644 index 0000000000..df13295233 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/rng.h @@ -0,0 +1,56 @@ +/* +NIST-developed software is provided by NIST as a public service. You may use, copy, and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify, and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software. + +NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. + +You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States. +*/ + +#ifndef rng_h +#define rng_h + +#include + +#define RNG_SUCCESS 0 +#define RNG_BAD_MAXLEN -1 +#define RNG_BAD_OUTBUF -2 +#define RNG_BAD_REQ_LEN -3 + +typedef struct { + unsigned char buffer[16]; + int buffer_pos; + unsigned long length_remaining; + unsigned char key[32]; + unsigned char ctr[16]; +} AES_XOF_struct; + +typedef struct { + unsigned char Key[32]; + unsigned char V[16]; + int reseed_counter; +} AES256_CTR_DRBG_struct; + + +void +AES256_CTR_DRBG_Update(unsigned char *provided_data, + unsigned char *Key, + unsigned char *V); + +int +seedexpander_init(AES_XOF_struct *ctx, + unsigned char *seed, + unsigned char *diversifier, + unsigned long maxlen); + +int +seedexpander(AES_XOF_struct *ctx, unsigned char *x, unsigned long xlen); + +void +randombytes_init(unsigned char *entropy_input, + unsigned char *personalization_string, + int security_strength); + +void +randombytes(unsigned char *x, unsigned long long xlen); + +#endif /* rng_h */ diff --git a/src/sig/qruov/qruov_qruov_common/sign.c b/src/sig/qruov/qruov_qruov_common/sign.c new file mode 100644 index 0000000000..5b65738c73 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/sign.c @@ -0,0 +1,70 @@ +#include +#include "qruov.h" +#include "qrop.h" +#include "util.h" +#include "rng.h" + +int crypto_sign_keypair(unsigned char *pk, unsigned char *sk) +{ + SEED_PK seed_pk; + SEED_SK seed_sk; + randombytes(seed_sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + qruov_init(); + memcpy(pk, seed_pk, SEED_PK_LEN); + qruov_keygen(seed_pk, seed_sk, pk + SEED_PK_LEN); + memcpy(sk, seed_sk, SEED_SK_LEN); + secure_zero(seed_sk, sizeof(seed_sk)); + return 0; +} + +int crypto_sign(unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen, const unsigned char *sk) +{ + int ret = -1; + SEED_PK seed_pk; + SEED_SK seed_sk, seed_y, seed_r, seed_sol; + SALT sig_r; + SIG_S sig_s; + *smlen = 0; + memcpy(seed_sk, sk, SEED_SK_LEN); + prepare_seed_pk_from_seed(seed_pk, seed_sk); + randombytes(seed_y, SEED_SK_LEN); + randombytes(seed_r, SEED_SK_LEN); + randombytes(seed_sol, SEED_SK_LEN); + qruov_init(); + if (qruov_sign(seed_pk, seed_sk, seed_y, seed_r, seed_sol, m, mlen, sig_r, sig_s) != 0) goto cleanup; + memmove(sm + QRUOV_SIG_LEN, m, mlen); + memcpy(sm, sig_r, SALT_LEN); + store_fq(sm + SALT_LEN, sig_s, SIG_S_COEFF_LEN); + *smlen = QRUOV_SIG_LEN + mlen; + ret = 0; +cleanup: + secure_zero(seed_sk, sizeof(seed_sk)); + secure_zero(seed_y, sizeof(seed_y)); + secure_zero(seed_r, sizeof(seed_r)); + secure_zero(seed_sol, sizeof(seed_sol)); + return ret; +} + +int crypto_sign_open(unsigned char *m, unsigned long long *mlen, const unsigned char *sm, unsigned long long smlen, const unsigned char *pk) +{ + SEED_PK seed_pk; + SALT sig_r; + SIG_S sig_s; + *mlen = 0; + if (smlen < QRUOV_SIG_LEN) { + return -1; + } + memcpy(seed_pk, pk, SEED_PK_LEN); + memcpy(sig_r, sm, SALT_LEN); + if (!load_fq_checked(sig_s, sm + SALT_LEN, SIG_S_COEFF_LEN)) { + return -1; + } + qruov_init(); + if (!qruov_verify(seed_pk, pk + SEED_PK_LEN, sm + QRUOV_SIG_LEN, smlen - QRUOV_SIG_LEN, sig_r, sig_s)) { + return -1; + } + *mlen = smlen - QRUOV_SIG_LEN; + memmove(m, sm + QRUOV_SIG_LEN, *mlen); + return 0; +} diff --git a/src/sig/qruov/qruov_qruov_common/util.h b/src/sig/qruov/qruov_qruov_common/util.h new file mode 100644 index 0000000000..6f8d153589 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_common/util.h @@ -0,0 +1,41 @@ +#ifndef UTIL_H +#define UTIL_H + +#include +#include +#include + +#define ROUND_UP4(x) (((x) + 3) & ~3) +#define ROUND_UP16(x) (((x) + 15) & ~15) + +static inline void store_u16_be(uint8_t out[2], uint16_t x) +{ + out[0] = (uint8_t)(x >> 8); + out[1] = (uint8_t)x; +} + +static inline void store_u64_be(uint8_t out[8], uint64_t x) +{ + out[0] = (uint8_t)(x >> 56); + out[1] = (uint8_t)(x >> 48); + out[2] = (uint8_t)(x >> 40); + out[3] = (uint8_t)(x >> 32); + out[4] = (uint8_t)(x >> 24); + out[5] = (uint8_t)(x >> 16); + out[6] = (uint8_t)(x >> 8); + out[7] = (uint8_t)x; +} + +static inline void secure_zero(void *ptr, size_t len) +{ +#if defined(__APPLE__) + (void)memset_s(ptr, len, 0, len); +#elif defined(__GLIBC__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + explicit_bzero(ptr, len); +#else + static void *(*const volatile memset_ptr)(void *, int, size_t) = memset; + memset_ptr(ptr, 0, len); +#endif +} + +#endif // UTIL_H diff --git a/src/sig/qruov/qruov_qruov_opt/emi_transform.c b/src/sig/qruov/qruov_qruov_opt/emi_transform.c new file mode 100644 index 0000000000..d2b01ec0a0 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_opt/emi_transform.c @@ -0,0 +1,159 @@ +#include "emi_transform.h" + +#if QRUOV_q == 31 && QRUOV_L == 3 +void reevaluate_scalar_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_scalar_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 127 && QRUOV_L == 3 +void reevaluate_scalar_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_scalar_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 31 && QRUOV_L == 10 +void reevaluate_scalar_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_scalar_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 7 && QRUOV_L == 10 +void evaluate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#elif QRUOV_q == 127 && QRUOV_L == 10 +void reevaluate_scalar_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate_scalar_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +#else +#error "Unsupported (q, L) for OPT EMI transform" +#endif + +#if QRUOV_L == 3 && (QRUOV_q == 31 || QRUOV_q == 127) +static inline uint8_t subq_if_greater(int val) +{ + if (val >= QRUOV_q) { + val -= QRUOV_q; + } + return (uint8_t)val; +} + +static void evaluate_specialized_L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + const int a0 = (int)input[0 * plane_in + i]; + const int a1 = (int)input[1 * plane_in + i]; + const int a2 = (int)input[2 * plane_in + i]; + const int a0a2 = subq_if_greater(a0 + a2); + const int a2d = subq_if_greater(a2 + a2); + const int a1a2d = subq_if_greater(a1 + a2d); + const int a1da2q = subq_if_greater(a1a2d + a1a2d); + + output[0 * plane_out + i] = (uint8_t)a0; + output[1 * plane_out + i] = subq_if_greater(a1 + a0a2); + output[2 * plane_out + i] = subq_if_greater((QRUOV_q - a1) + a0a2); + output[3 * plane_out + i] = subq_if_greater(a0 + a1da2q); + output[4 * plane_out + i] = (uint8_t)a2; + } +} +#endif + +#if QRUOV_L == 10 && (QRUOV_q == 7 || QRUOV_q == 31 || QRUOV_q == 127) +static void evaluate_specialized_L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ +#if QRUOV_q == 7 + /* q7/L10 uses a 23x10 packed matrix, not base-field evaluation points. */ + evaluate_scalar_q7L10(output, plane_out, input, plane_in, size); +#else + for (int i = 0; i < size; i++) { + const int a0 = (int)input[0 * plane_in + i]; + const int a1 = (int)input[1 * plane_in + i]; + const int a2 = (int)input[2 * plane_in + i]; + const int a3 = (int)input[3 * plane_in + i]; + const int a4 = (int)input[4 * plane_in + i]; + const int a5 = (int)input[5 * plane_in + i]; + const int a6 = (int)input[6 * plane_in + i]; + const int a7 = (int)input[7 * plane_in + i]; + const int a8 = (int)input[8 * plane_in + i]; + const int a9 = (int)input[9 * plane_in + i]; + +#define EVALUATE_PAIR(x, idx_pos, idx_neg) do { \ + const int even = a0 + QRUOV_POW2(x) * a2 + QRUOV_POW4(x) * a4 + QRUOV_POW6(x) * a6 + QRUOV_POW8(x) * a8; \ + const int odd = QRUOV_POW1(x) * a1 + QRUOV_POW3(x) * a3 + QRUOV_POW5(x) * a5 + QRUOV_POW7(x) * a7 + QRUOV_POW9(x) * a9; \ + int val = even + odd; \ + output[(idx_pos) * plane_out + i] = (uint8_t)(val % QRUOV_q); \ + val = even - odd; \ + val %= QRUOV_q; \ + if (val < 0) val += QRUOV_q; \ + output[(idx_neg) * plane_out + i] = (uint8_t)val; \ + } while (0) + +#define EVALUATE_AT(x, idx) do { \ + int val = 0; \ + val += QRUOV_POW0(x) * a0; \ + val += QRUOV_POW1(x) * a1; \ + val += QRUOV_POW2(x) * a2; \ + val += QRUOV_POW3(x) * a3; \ + val += QRUOV_POW4(x) * a4; \ + val += QRUOV_POW5(x) * a5; \ + val += QRUOV_POW6(x) * a6; \ + val += QRUOV_POW7(x) * a7; \ + val += QRUOV_POW8(x) * a8; \ + val += QRUOV_POW9(x) * a9; \ + output[(idx) * plane_out + i] = (uint8_t)(val % QRUOV_q); \ + } while (0) + + output[0 * plane_out + i] = (uint8_t)a0; + EVALUATE_PAIR(1, 1, 2); + EVALUATE_PAIR(2, 3, 4); + EVALUATE_PAIR(3, 5, 6); + EVALUATE_PAIR(4, 7, 8); + EVALUATE_PAIR(5, 9, 10); + EVALUATE_PAIR(6, 11, 12); + EVALUATE_PAIR(7, 13, 14); + EVALUATE_PAIR(8, 15, 16); + EVALUATE_AT(9, 17); + output[18 * plane_out + i] = (uint8_t)a9; + +#undef EVALUATE_AT +#undef EVALUATE_PAIR + } +#endif +} +#endif + +void evaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ +#if QRUOV_q == 31 && QRUOV_L == 3 + evaluate_specialized_L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + evaluate_specialized_L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + evaluate_specialized_L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 7 && QRUOV_L == 10 + evaluate_specialized_L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + evaluate_specialized_L10(output, plane_out, input, plane_in, size); +#endif +} + +void reevaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ +#if QRUOV_q == 31 && QRUOV_L == 3 + reevaluate_scalar_q31L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + reevaluate_scalar_q127L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + reevaluate_scalar_q31L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 7 && QRUOV_L == 10 + reevaluate_scalar_q7L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + reevaluate_scalar_q127L10(output, plane_out, input, plane_in, size); +#endif +} + +void interpolate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ +#if QRUOV_q == 31 && QRUOV_L == 3 + interpolate_scalar_q31L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 3 + interpolate_scalar_q127L3(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 31 && QRUOV_L == 10 + interpolate_scalar_q31L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 7 && QRUOV_L == 10 + interpolate_scalar_q7L10(output, plane_out, input, plane_in, size); +#elif QRUOV_q == 127 && QRUOV_L == 10 + interpolate_scalar_q127L10(output, plane_out, input, plane_in, size); +#endif +} diff --git a/src/sig/qruov/qruov_qruov_opt/emi_transform.h b/src/sig/qruov/qruov_qruov_opt/emi_transform.h new file mode 100644 index 0000000000..54a4d889e6 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_opt/emi_transform.h @@ -0,0 +1,25 @@ +// auto generated by genmat.py +#ifndef EMI_TRANSFORM_H +#define EMI_TRANSFORM_H + +#include "qruov.h" + +#if QRUOV_q == 31 && QRUOV_L == 3 +#define QRUOV_LL 5 +#elif QRUOV_q == 127 && QRUOV_L == 3 +#define QRUOV_LL 5 +#elif QRUOV_q == 31 && QRUOV_L == 10 +#define QRUOV_LL 19 +#elif QRUOV_q == 7 && QRUOV_L == 10 +#define QRUOV_LL 23 +#elif QRUOV_q == 127 && QRUOV_L == 10 +#define QRUOV_LL 19 +#else +#error "Unsupported (q, L) for EMI tables" +#endif + +void evaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void reevaluate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); +void interpolate(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size); + +#endif // EMI_TRANSFORM_H diff --git a/src/sig/qruov/qruov_qruov_opt/emi_transform_gen.c b/src/sig/qruov/qruov_qruov_opt/emi_transform_gen.c new file mode 100644 index 0000000000..dfb27f05cc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_opt/emi_transform_gen.c @@ -0,0 +1,2584 @@ +// auto generated by genmat.py +#include "emi_transform.h" + +#if QRUOV_q == 31 && QRUOV_L == 3 +void reevaluate_scalar_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 17 * (int)input[0 * plane_in + i]; + val += 15 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 26 * (int)input[3 * plane_in + i]; + val += 29 * (int)input[4 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 16 * (int)input[0 * plane_in + i]; + val += 16 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 26 * (int)input[3 * plane_in + i]; + val += 30 * (int)input[4 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 16 * (int)input[0 * plane_in + i]; + val += 15 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 26 * (int)input[3 * plane_in + i]; + val += 28 * (int)input[4 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 13 * (int)input[0 * plane_in + i]; + val += 18 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 26 * (int)input[3 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 30 * (int)input[0 * plane_in + i]; + val += 16 * (int)input[1 * plane_in + i]; + val += 16 * (int)input[2 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void interpolate_scalar_q31L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 17 * (int)input[0 * plane_in + i]; + val += 15 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 26 * (int)input[3 * plane_in + i]; + val += 29 * (int)input[4 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 16 * (int)input[1 * plane_in + i]; + val += 15 * (int)input[2 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 30 * (int)input[0 * plane_in + i]; + val += 16 * (int)input[1 * plane_in + i]; + val += 16 * (int)input[2 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +#elif QRUOV_q == 127 && QRUOV_L == 3 +void reevaluate_scalar_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 65 * (int)input[0 * plane_in + i]; + val += 63 * (int)input[1 * plane_in + i]; + val += 21 * (int)input[2 * plane_in + i]; + val += 106 * (int)input[3 * plane_in + i]; + val += 125 * (int)input[4 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 64 * (int)input[0 * plane_in + i]; + val += 64 * (int)input[1 * plane_in + i]; + val += 21 * (int)input[2 * plane_in + i]; + val += 106 * (int)input[3 * plane_in + i]; + val += 126 * (int)input[4 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 64 * (int)input[0 * plane_in + i]; + val += 63 * (int)input[1 * plane_in + i]; + val += 22 * (int)input[2 * plane_in + i]; + val += 106 * (int)input[3 * plane_in + i]; + val += 124 * (int)input[4 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 61 * (int)input[0 * plane_in + i]; + val += 66 * (int)input[1 * plane_in + i]; + val += 22 * (int)input[2 * plane_in + i]; + val += 106 * (int)input[3 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 126 * (int)input[0 * plane_in + i]; + val += 64 * (int)input[1 * plane_in + i]; + val += 64 * (int)input[2 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void interpolate_scalar_q127L3(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 65 * (int)input[0 * plane_in + i]; + val += 63 * (int)input[1 * plane_in + i]; + val += 21 * (int)input[2 * plane_in + i]; + val += 106 * (int)input[3 * plane_in + i]; + val += 125 * (int)input[4 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 64 * (int)input[1 * plane_in + i]; + val += 63 * (int)input[2 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 126 * (int)input[0 * plane_in + i]; + val += 64 * (int)input[1 * plane_in + i]; + val += 64 * (int)input[2 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +#elif QRUOV_q == 31 && QRUOV_L == 10 +void reevaluate_scalar_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 20 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 19 * (int)input[3 * plane_in + i]; + val += 25 * (int)input[4 * plane_in + i]; + val += 17 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 30 * (int)input[7 * plane_in + i]; + val += 7 * (int)input[8 * plane_in + i]; + val += 9 * (int)input[9 * plane_in + i]; + val += (int)input[10 * plane_in + i]; + val += 30 * (int)input[11 * plane_in + i]; + val += 9 * (int)input[12 * plane_in + i]; + val += 29 * (int)input[13 * plane_in + i]; + val += 21 * (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += 27 * (int)input[16 * plane_in + i]; + val += 17 * (int)input[17 * plane_in + i]; + val += 3 * (int)input[18 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 12 * (int)input[0 * plane_in + i]; + val += 14 * (int)input[1 * plane_in + i]; + val += 25 * (int)input[2 * plane_in + i]; + val += 13 * (int)input[3 * plane_in + i]; + val += 26 * (int)input[4 * plane_in + i]; + val += 26 * (int)input[5 * plane_in + i]; + val += 21 * (int)input[6 * plane_in + i]; + val += 22 * (int)input[7 * plane_in + i]; + val += 19 * (int)input[8 * plane_in + i]; + val += 14 * (int)input[9 * plane_in + i]; + val += 10 * (int)input[10 * plane_in + i]; + val += (int)input[11 * plane_in + i]; + val += 11 * (int)input[12 * plane_in + i]; + val += 13 * (int)input[13 * plane_in + i]; + val += 14 * (int)input[14 * plane_in + i]; + val += 30 * (int)input[15 * plane_in + i]; + val += 10 * (int)input[16 * plane_in + i]; + val += 30 * (int)input[17 * plane_in + i]; + val += 29 * (int)input[18 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 28 * (int)input[0 * plane_in + i]; + val += 23 * (int)input[1 * plane_in + i]; + val += 23 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 17 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 30 * (int)input[7 * plane_in + i]; + val += 9 * (int)input[8 * plane_in + i]; + val += 11 * (int)input[9 * plane_in + i]; + val += 25 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[12 * plane_in + i]; + val += 25 * (int)input[13 * plane_in + i]; + val += 13 * (int)input[14 * plane_in + i]; + val += 15 * (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += 15 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 20 * (int)input[0 * plane_in + i]; + val += 25 * (int)input[1 * plane_in + i]; + val += 16 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 26 * (int)input[4 * plane_in + i]; + val += 20 * (int)input[5 * plane_in + i]; + val += 19 * (int)input[6 * plane_in + i]; + val += 22 * (int)input[7 * plane_in + i]; + val += 17 * (int)input[8 * plane_in + i]; + val += 23 * (int)input[9 * plane_in + i]; + val += 29 * (int)input[10 * plane_in + i]; + val += 26 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 28 * (int)input[13 * plane_in + i]; + val += 15 * (int)input[14 * plane_in + i]; + val += 24 * (int)input[15 * plane_in + i]; + val += 7 * (int)input[16 * plane_in + i]; + val += 22 * (int)input[17 * plane_in + i]; + val += 22 * (int)input[18 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[1 * plane_in + i]; + val += 21 * (int)input[2 * plane_in + i]; + val += 30 * (int)input[3 * plane_in + i]; + val += 10 * (int)input[4 * plane_in + i]; + val += 23 * (int)input[5 * plane_in + i]; + val += 8 * (int)input[6 * plane_in + i]; + val += 15 * (int)input[7 * plane_in + i]; + val += 21 * (int)input[8 * plane_in + i]; + val += 24 * (int)input[9 * plane_in + i]; + val += 19 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 16 * (int)input[12 * plane_in + i]; + val += 20 * (int)input[13 * plane_in + i]; + val += 27 * (int)input[14 * plane_in + i]; + val += 25 * (int)input[15 * plane_in + i]; + val += 10 * (int)input[16 * plane_in + i]; + val += 26 * (int)input[17 * plane_in + i]; + val += 20 * (int)input[18 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 30 * (int)input[0 * plane_in + i]; + val += 20 * (int)input[1 * plane_in + i]; + val += 22 * (int)input[2 * plane_in + i]; + val += 8 * (int)input[3 * plane_in + i]; + val += 15 * (int)input[4 * plane_in + i]; + val += 11 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 15 * (int)input[7 * plane_in + i]; + val += 26 * (int)input[8 * plane_in + i]; + val += 27 * (int)input[9 * plane_in + i]; + val += 15 * (int)input[10 * plane_in + i]; + val += 5 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 13 * (int)input[13 * plane_in + i]; + val += 19 * (int)input[14 * plane_in + i]; + val += 23 * (int)input[15 * plane_in + i]; + val += 11 * (int)input[16 * plane_in + i]; + val += 12 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 23 * (int)input[0 * plane_in + i]; + val += 27 * (int)input[1 * plane_in + i]; + val += 26 * (int)input[2 * plane_in + i]; + val += 29 * (int)input[3 * plane_in + i]; + val += 17 * (int)input[4 * plane_in + i]; + val += 12 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 18 * (int)input[7 * plane_in + i]; + val += 15 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + val += 25 * (int)input[10 * plane_in + i]; + val += 7 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 29 * (int)input[13 * plane_in + i]; + val += 22 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 14 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 16 * (int)input[18 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 5 * (int)input[0 * plane_in + i]; + val += 22 * (int)input[1 * plane_in + i]; + val += 7 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 8 * (int)input[4 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += 14 * (int)input[6 * plane_in + i]; + val += 7 * (int)input[7 * plane_in + i]; + val += 14 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + val += 4 * (int)input[10 * plane_in + i]; + val += 25 * (int)input[11 * plane_in + i]; + val += 27 * (int)input[12 * plane_in + i]; + val += 8 * (int)input[13 * plane_in + i]; + val += 12 * (int)input[14 * plane_in + i]; + val += 20 * (int)input[15 * plane_in + i]; + val += 27 * (int)input[16 * plane_in + i]; + val += 7 * (int)input[17 * plane_in + i]; + val += 12 * (int)input[18 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 29 * (int)input[0 * plane_in + i]; + val += 25 * (int)input[1 * plane_in + i]; + val += 15 * (int)input[2 * plane_in + i]; + val += 10 * (int)input[3 * plane_in + i]; + val += 18 * (int)input[4 * plane_in + i]; + val += 20 * (int)input[5 * plane_in + i]; + val += 11 * (int)input[6 * plane_in + i]; + val += 7 * (int)input[7 * plane_in + i]; + val += 11 * (int)input[8 * plane_in + i]; + val += 19 * (int)input[9 * plane_in + i]; + val += 25 * (int)input[10 * plane_in + i]; + val += 29 * (int)input[11 * plane_in + i]; + val += 17 * (int)input[12 * plane_in + i]; + val += 17 * (int)input[13 * plane_in + i]; + val += 26 * (int)input[14 * plane_in + i]; + val += 16 * (int)input[15 * plane_in + i]; + val += 8 * (int)input[16 * plane_in + i]; + val += 8 * (int)input[17 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 21 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[1 * plane_in + i]; + val += 7 * (int)input[2 * plane_in + i]; + val += 5 * (int)input[3 * plane_in + i]; + val += 18 * (int)input[4 * plane_in + i]; + val += 14 * (int)input[5 * plane_in + i]; + val += 20 * (int)input[6 * plane_in + i]; + val += 11 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 14 * (int)input[9 * plane_in + i]; + val += 4 * (int)input[10 * plane_in + i]; + val += 29 * (int)input[11 * plane_in + i]; + val += 24 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 12 * (int)input[14 * plane_in + i]; + val += 7 * (int)input[15 * plane_in + i]; + val += 12 * (int)input[16 * plane_in + i]; + val += 17 * (int)input[18 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[0 * plane_in + i]; + val += 23 * (int)input[1 * plane_in + i]; + val += 16 * (int)input[2 * plane_in + i]; + val += 11 * (int)input[3 * plane_in + i]; + val += 20 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 12 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += 22 * (int)input[8 * plane_in + i]; + val += 29 * (int)input[9 * plane_in + i]; + val += 9 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += 23 * (int)input[14 * plane_in + i]; + val += 10 * (int)input[15 * plane_in + i]; + val += 26 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 22 * (int)input[18 * plane_in + i]; + output[10 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 26 * (int)input[1 * plane_in + i]; + val += 13 * (int)input[3 * plane_in + i]; + val += 10 * (int)input[4 * plane_in + i]; + val += 14 * (int)input[5 * plane_in + i]; + val += 21 * (int)input[6 * plane_in + i]; + val += 30 * (int)input[7 * plane_in + i]; + val += 20 * (int)input[8 * plane_in + i]; + val += 14 * (int)input[9 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += 22 * (int)input[11 * plane_in + i]; + val += 15 * (int)input[12 * plane_in + i]; + val += 13 * (int)input[13 * plane_in + i]; + val += 10 * (int)input[14 * plane_in + i]; + val += 4 * (int)input[15 * plane_in + i]; + val += 18 * (int)input[16 * plane_in + i]; + val += 11 * (int)input[17 * plane_in + i]; + val += 17 * (int)input[18 * plane_in + i]; + output[11 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 23 * (int)input[0 * plane_in + i]; + val += 24 * (int)input[1 * plane_in + i]; + val += 19 * (int)input[2 * plane_in + i]; + val += 15 * (int)input[3 * plane_in + i]; + val += 22 * (int)input[4 * plane_in + i]; + val += 26 * (int)input[5 * plane_in + i]; + val += 13 * (int)input[6 * plane_in + i]; + val += 11 * (int)input[7 * plane_in + i]; + val += 15 * (int)input[8 * plane_in + i]; + val += 13 * (int)input[9 * plane_in + i]; + val += 17 * (int)input[10 * plane_in + i]; + val += 16 * (int)input[11 * plane_in + i]; + val += 14 * (int)input[12 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += 16 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 29 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 30 * (int)input[18 * plane_in + i]; + output[12 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 17 * (int)input[0 * plane_in + i]; + val += 19 * (int)input[1 * plane_in + i]; + val += 28 * (int)input[2 * plane_in + i]; + val += 25 * (int)input[3 * plane_in + i]; + val += 14 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 7 * (int)input[6 * plane_in + i]; + val += 26 * (int)input[7 * plane_in + i]; + val += 2 * (int)input[8 * plane_in + i]; + val += 15 * (int)input[9 * plane_in + i]; + val += 19 * (int)input[10 * plane_in + i]; + val += 21 * (int)input[11 * plane_in + i]; + val += 15 * (int)input[12 * plane_in + i]; + val += 27 * (int)input[13 * plane_in + i]; + val += 2 * (int)input[14 * plane_in + i]; + val += 14 * (int)input[15 * plane_in + i]; + val += 15 * (int)input[16 * plane_in + i]; + val += 11 * (int)input[17 * plane_in + i]; + val += 9 * (int)input[18 * plane_in + i]; + output[13 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[0 * plane_in + i]; + val += 16 * (int)input[1 * plane_in + i]; + val += 20 * (int)input[2 * plane_in + i]; + val += 16 * (int)input[3 * plane_in + i]; + val += 20 * (int)input[4 * plane_in + i]; + val += 30 * (int)input[5 * plane_in + i]; + val += 23 * (int)input[6 * plane_in + i]; + val += 27 * (int)input[7 * plane_in + i]; + val += 24 * (int)input[8 * plane_in + i]; + val += 13 * (int)input[9 * plane_in + i]; + val += 7 * (int)input[10 * plane_in + i]; + val += 11 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 30 * (int)input[13 * plane_in + i]; + val += 6 * (int)input[15 * plane_in + i]; + val += 19 * (int)input[16 * plane_in + i]; + val += 13 * (int)input[17 * plane_in + i]; + val += 10 * (int)input[18 * plane_in + i]; + output[14 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 30 * (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 24 * (int)input[2 * plane_in + i]; + val += 11 * (int)input[3 * plane_in + i]; + val += 25 * (int)input[4 * plane_in + i]; + val += 27 * (int)input[5 * plane_in + i]; + val += 21 * (int)input[6 * plane_in + i]; + val += 22 * (int)input[7 * plane_in + i]; + val += 29 * (int)input[8 * plane_in + i]; + val += 30 * (int)input[9 * plane_in + i]; + val += 25 * (int)input[10 * plane_in + i]; + val += 14 * (int)input[11 * plane_in + i]; + val += 24 * (int)input[12 * plane_in + i]; + val += 20 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 16 * (int)input[15 * plane_in + i]; + val += 13 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 24 * (int)input[18 * plane_in + i]; + output[15 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 29 * (int)input[0 * plane_in + i]; + val += 30 * (int)input[1 * plane_in + i]; + val += 30 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 16 * (int)input[4 * plane_in + i]; + val += 15 * (int)input[5 * plane_in + i]; + val += 12 * (int)input[6 * plane_in + i]; + val += 19 * (int)input[7 * plane_in + i]; + val += 17 * (int)input[8 * plane_in + i]; + val += 7 * (int)input[9 * plane_in + i]; + val += 11 * (int)input[10 * plane_in + i]; + val += 14 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += 21 * (int)input[13 * plane_in + i]; + val += 15 * (int)input[14 * plane_in + i]; + val += 27 * (int)input[15 * plane_in + i]; + val += 30 * (int)input[16 * plane_in + i]; + val += 12 * (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + output[16 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 29 * (int)input[0 * plane_in + i]; + val += 8 * (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 30 * (int)input[3 * plane_in + i]; + val += 11 * (int)input[4 * plane_in + i]; + val += 24 * (int)input[5 * plane_in + i]; + val += 11 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += 27 * (int)input[8 * plane_in + i]; + val += 9 * (int)input[10 * plane_in + i]; + val += 30 * (int)input[11 * plane_in + i]; + val += 17 * (int)input[12 * plane_in + i]; + val += 23 * (int)input[13 * plane_in + i]; + val += 2 * (int)input[14 * plane_in + i]; + val += 16 * (int)input[15 * plane_in + i]; + val += 30 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 21 * (int)input[18 * plane_in + i]; + output[17 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 7 * (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += 11 * (int)input[2 * plane_in + i]; + val += 25 * (int)input[3 * plane_in + i]; + val += 15 * (int)input[4 * plane_in + i]; + val += 17 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 13 * (int)input[7 * plane_in + i]; + val += 17 * (int)input[9 * plane_in + i]; + val += 18 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += 22 * (int)input[12 * plane_in + i]; + val += 3 * (int)input[13 * plane_in + i]; + val += 14 * (int)input[14 * plane_in + i]; + val += 18 * (int)input[15 * plane_in + i]; + val += 28 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + output[18 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void interpolate_scalar_q31L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 20 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 19 * (int)input[3 * plane_in + i]; + val += 25 * (int)input[4 * plane_in + i]; + val += 17 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 30 * (int)input[7 * plane_in + i]; + val += 7 * (int)input[8 * plane_in + i]; + val += 9 * (int)input[9 * plane_in + i]; + val += (int)input[10 * plane_in + i]; + val += 30 * (int)input[11 * plane_in + i]; + val += 9 * (int)input[12 * plane_in + i]; + val += 29 * (int)input[13 * plane_in + i]; + val += 21 * (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += 27 * (int)input[16 * plane_in + i]; + val += 17 * (int)input[17 * plane_in + i]; + val += 3 * (int)input[18 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 14 * (int)input[0 * plane_in + i]; + val += 30 * (int)input[1 * plane_in + i]; + val += 13 * (int)input[2 * plane_in + i]; + val += 17 * (int)input[3 * plane_in + i]; + val += 25 * (int)input[4 * plane_in + i]; + val += 10 * (int)input[5 * plane_in + i]; + val += 12 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 26 * (int)input[8 * plane_in + i]; + val += 24 * (int)input[9 * plane_in + i]; + val += 28 * (int)input[10 * plane_in + i]; + val += 13 * (int)input[11 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += 14 * (int)input[14 * plane_in + i]; + val += 23 * (int)input[15 * plane_in + i]; + val += 19 * (int)input[16 * plane_in + i]; + val += 8 * (int)input[17 * plane_in + i]; + val += 13 * (int)input[18 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 23 * (int)input[0 * plane_in + i]; + val += 13 * (int)input[1 * plane_in + i]; + val += 13 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 26 * (int)input[5 * plane_in + i]; + val += 26 * (int)input[6 * plane_in + i]; + val += 23 * (int)input[7 * plane_in + i]; + val += 23 * (int)input[8 * plane_in + i]; + val += 16 * (int)input[9 * plane_in + i]; + val += 16 * (int)input[10 * plane_in + i]; + val += 15 * (int)input[11 * plane_in + i]; + val += 15 * (int)input[12 * plane_in + i]; + val += 13 * (int)input[13 * plane_in + i]; + val += 13 * (int)input[14 * plane_in + i]; + val += 16 * (int)input[15 * plane_in + i]; + val += 16 * (int)input[16 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 27 * (int)input[0 * plane_in + i]; + val += 24 * (int)input[1 * plane_in + i]; + val += 22 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 14 * (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 20 * (int)input[7 * plane_in + i]; + val += 29 * (int)input[8 * plane_in + i]; + val += 17 * (int)input[9 * plane_in + i]; + val += 24 * (int)input[10 * plane_in + i]; + val += 16 * (int)input[11 * plane_in + i]; + val += 14 * (int)input[12 * plane_in + i]; + val += 25 * (int)input[13 * plane_in + i]; + val += 6 * (int)input[14 * plane_in + i]; + val += 25 * (int)input[15 * plane_in + i]; + val += 14 * (int)input[16 * plane_in + i]; + val += 24 * (int)input[17 * plane_in + i]; + val += 16 * (int)input[18 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 11 * (int)input[0 * plane_in + i]; + val += 20 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 15 * (int)input[3 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + val += 16 * (int)input[5 * plane_in + i]; + val += 16 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += 12 * (int)input[8 * plane_in + i]; + val += 25 * (int)input[9 * plane_in + i]; + val += 28 * (int)input[10 * plane_in + i]; + val += 30 * (int)input[11 * plane_in + i]; + val += 17 * (int)input[12 * plane_in + i]; + val += 29 * (int)input[13 * plane_in + i]; + val += 17 * (int)input[14 * plane_in + i]; + val += 11 * (int)input[15 * plane_in + i]; + val += 24 * (int)input[16 * plane_in + i]; + val += 29 * (int)input[17 * plane_in + i]; + val += 16 * (int)input[18 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 10 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[2 * plane_in + i]; + val += 24 * (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 14 * (int)input[7 * plane_in + i]; + val += 8 * (int)input[8 * plane_in + i]; + val += 20 * (int)input[9 * plane_in + i]; + val += 22 * (int)input[10 * plane_in + i]; + val += 28 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 25 * (int)input[13 * plane_in + i]; + val += 16 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 25 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 18 * (int)input[18 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 10 * (int)input[1 * plane_in + i]; + val += 13 * (int)input[2 * plane_in + i]; + val += 27 * (int)input[3 * plane_in + i]; + val += 30 * (int)input[4 * plane_in + i]; + val += 18 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 24 * (int)input[7 * plane_in + i]; + val += 8 * (int)input[8 * plane_in + i]; + val += 12 * (int)input[9 * plane_in + i]; + val += 19 * (int)input[10 * plane_in + i]; + val += 19 * (int)input[11 * plane_in + i]; + val += 23 * (int)input[12 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += 4 * (int)input[14 * plane_in + i]; + val += 29 * (int)input[15 * plane_in + i]; + val += 10 * (int)input[16 * plane_in + i]; + val += 19 * (int)input[17 * plane_in + i]; + val += 22 * (int)input[18 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 27 * (int)input[0 * plane_in + i]; + val += 16 * (int)input[1 * plane_in + i]; + val += 7 * (int)input[2 * plane_in + i]; + val += 8 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 29 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 9 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + val += 9 * (int)input[10 * plane_in + i]; + val += 19 * (int)input[11 * plane_in + i]; + val += 24 * (int)input[12 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += 28 * (int)input[14 * plane_in + i]; + val += 17 * (int)input[15 * plane_in + i]; + val += 26 * (int)input[16 * plane_in + i]; + val += 16 * (int)input[17 * plane_in + i]; + val += 7 * (int)input[18 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 22 * (int)input[0 * plane_in + i]; + val += 12 * (int)input[1 * plane_in + i]; + val += 21 * (int)input[2 * plane_in + i]; + val += 18 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 15 * (int)input[5 * plane_in + i]; + val += 7 * (int)input[6 * plane_in + i]; + val += 8 * (int)input[7 * plane_in + i]; + val += 26 * (int)input[8 * plane_in + i]; + val += 28 * (int)input[9 * plane_in + i]; + val += 15 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += 8 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 10 * (int)input[15 * plane_in + i]; + val += 7 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 16 * (int)input[18 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 7 * (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += 11 * (int)input[2 * plane_in + i]; + val += 25 * (int)input[3 * plane_in + i]; + val += 15 * (int)input[4 * plane_in + i]; + val += 17 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 13 * (int)input[7 * plane_in + i]; + val += 17 * (int)input[9 * plane_in + i]; + val += 18 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += 22 * (int)input[12 * plane_in + i]; + val += 3 * (int)input[13 * plane_in + i]; + val += 14 * (int)input[14 * plane_in + i]; + val += 18 * (int)input[15 * plane_in + i]; + val += 28 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +#elif QRUOV_q == 7 && QRUOV_L == 10 +void evaluate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 2 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 5 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += (int)input[6 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + output[10 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 5 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + output[11 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + output[12 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + output[13 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + output[14 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[15 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[16 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + output[17 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 5 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + output[18 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + output[19 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + output[20 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 4 * (int)input[9 * plane_in + i]; + output[21 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + output[22 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void reevaluate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 4 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 5 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 3 * (int)input[14 * plane_in + i]; + val += 5 * (int)input[15 * plane_in + i]; + val += 2 * (int)input[16 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 4 * (int)input[21 * plane_in + i]; + val += (int)input[22 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 2 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += 5 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += (int)input[19 * plane_in + i]; + val += 6 * (int)input[20 * plane_in + i]; + val += (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 2 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 6 * (int)input[15 * plane_in + i]; + val += 6 * (int)input[16 * plane_in + i]; + val += 3 * (int)input[17 * plane_in + i]; + val += 2 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 5 * (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + val += 3 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 3 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += 3 * (int)input[21 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 3 * (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 2 * (int)input[18 * plane_in + i]; + val += 5 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += 2 * (int)input[8 * plane_in + i]; + val += 4 * (int)input[9 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[15 * plane_in + i]; + val += 5 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 5 * (int)input[21 * plane_in + i]; + val += 4 * (int)input[22 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += 5 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 2 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 5 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 5 * (int)input[3 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 2 * (int)input[14 * plane_in + i]; + val += (int)input[15 * plane_in + i]; + val += 2 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 6 * (int)input[20 * plane_in + i]; + val += 4 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 5 * (int)input[15 * plane_in + i]; + val += 4 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + val += 5 * (int)input[21 * plane_in + i]; + val += 6 * (int)input[22 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 3 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 3 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 3 * (int)input[20 * plane_in + i]; + val += 3 * (int)input[21 * plane_in + i]; + val += 6 * (int)input[22 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 3 * (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += (int)input[22 * plane_in + i]; + output[10 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 2 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 2 * (int)input[10 * plane_in + i]; + val += 5 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += 2 * (int)input[14 * plane_in + i]; + val += 6 * (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += 3 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[11 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[12 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += 4 * (int)input[16 * plane_in + i]; + val += 6 * (int)input[19 * plane_in + i]; + val += (int)input[20 * plane_in + i]; + val += 2 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[12 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 6 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + val += 3 * (int)input[21 * plane_in + i]; + val += 3 * (int)input[22 * plane_in + i]; + output[13 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 4 * (int)input[9 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += 6 * (int)input[14 * plane_in + i]; + val += (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += (int)input[18 * plane_in + i]; + val += 3 * (int)input[19 * plane_in + i]; + val += 3 * (int)input[20 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[14 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 4 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 6 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 4 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += 4 * (int)input[14 * plane_in + i]; + val += 6 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 2 * (int)input[18 * plane_in + i]; + val += 2 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += 4 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[15 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 5 * (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += 2 * (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 3 * (int)input[17 * plane_in + i]; + val += 2 * (int)input[18 * plane_in + i]; + val += 6 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + output[16 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 4 * (int)input[5 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += 3 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += (int)input[21 * plane_in + i]; + val += 6 * (int)input[22 * plane_in + i]; + output[17 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[2 * plane_in + i]; + val += 5 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + val += 4 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += 3 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[16 * plane_in + i]; + val += 3 * (int)input[18 * plane_in + i]; + val += 5 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 2 * (int)input[21 * plane_in + i]; + val += 6 * (int)input[22 * plane_in + i]; + output[18 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 2 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += 4 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += (int)input[19 * plane_in + i]; + val += 3 * (int)input[21 * plane_in + i]; + val += 3 * (int)input[22 * plane_in + i]; + output[19 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 5 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 5 * (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 5 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[21 * plane_in + i]; + val += (int)input[22 * plane_in + i]; + output[20 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 5 * (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + val += (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 3 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += 2 * (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[21 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 3 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 5 * (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += (int)input[11 * plane_in + i]; + val += 2 * (int)input[12 * plane_in + i]; + val += 3 * (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += 5 * (int)input[17 * plane_in + i]; + val += 2 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[22 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void interpolate_scalar_q7L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 4 * (int)input[0 * plane_in + i]; + val += 6 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 6 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += (int)input[11 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 6 * (int)input[14 * plane_in + i]; + val += 4 * (int)input[15 * plane_in + i]; + val += 6 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 5 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 3 * (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 5 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 3 * (int)input[14 * plane_in + i]; + val += 4 * (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 3 * (int)input[20 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += 6 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += 3 * (int)input[12 * plane_in + i]; + val += 3 * (int)input[13 * plane_in + i]; + val += 5 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[16 * plane_in + i]; + val += 2 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 3 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += (int)input[21 * plane_in + i]; + val += (int)input[22 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += (int)input[1 * plane_in + i]; + val += 5 * (int)input[2 * plane_in + i]; + val += 3 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 2 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + val += 4 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += 6 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 4 * (int)input[16 * plane_in + i]; + val += 6 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 5 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + val += 3 * (int)input[21 * plane_in + i]; + val += 5 * (int)input[22 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 6 * (int)input[6 * plane_in + i]; + val += (int)input[7 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 2 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 4 * (int)input[14 * plane_in + i]; + val += 4 * (int)input[15 * plane_in + i]; + val += 4 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 5 * (int)input[20 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += 6 * (int)input[3 * plane_in + i]; + val += 3 * (int)input[4 * plane_in + i]; + val += (int)input[5 * plane_in + i]; + val += 2 * (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 4 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + val += 3 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += 4 * (int)input[13 * plane_in + i]; + val += 3 * (int)input[15 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[22 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 3 * (int)input[1 * plane_in + i]; + val += (int)input[2 * plane_in + i]; + val += 2 * (int)input[3 * plane_in + i]; + val += (int)input[4 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += 4 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[8 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 2 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 6 * (int)input[14 * plane_in + i]; + val += (int)input[16 * plane_in + i]; + val += 4 * (int)input[17 * plane_in + i]; + val += (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 4 * (int)input[20 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += 4 * (int)input[22 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 3 * (int)input[1 * plane_in + i]; + val += 5 * (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 3 * (int)input[6 * plane_in + i]; + val += 3 * (int)input[7 * plane_in + i]; + val += (int)input[8 * plane_in + i]; + val += 6 * (int)input[9 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += 6 * (int)input[13 * plane_in + i]; + val += 4 * (int)input[14 * plane_in + i]; + val += (int)input[15 * plane_in + i]; + val += 3 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 6 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 5 * (int)input[21 * plane_in + i]; + val += (int)input[22 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 4 * (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 4 * (int)input[2 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 5 * (int)input[5 * plane_in + i]; + val += (int)input[6 * plane_in + i]; + val += 2 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += (int)input[9 * plane_in + i]; + val += 6 * (int)input[10 * plane_in + i]; + val += 6 * (int)input[11 * plane_in + i]; + val += 4 * (int)input[12 * plane_in + i]; + val += (int)input[13 * plane_in + i]; + val += (int)input[14 * plane_in + i]; + val += (int)input[15 * plane_in + i]; + val += 5 * (int)input[16 * plane_in + i]; + val += 3 * (int)input[17 * plane_in + i]; + val += 4 * (int)input[18 * plane_in + i]; + val += 4 * (int)input[19 * plane_in + i]; + val += 6 * (int)input[21 * plane_in + i]; + val += 2 * (int)input[22 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 2 * (int)input[0 * plane_in + i]; + val += 2 * (int)input[1 * plane_in + i]; + val += (int)input[3 * plane_in + i]; + val += 5 * (int)input[4 * plane_in + i]; + val += 3 * (int)input[5 * plane_in + i]; + val += 5 * (int)input[6 * plane_in + i]; + val += 4 * (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 3 * (int)input[9 * plane_in + i]; + val += (int)input[10 * plane_in + i]; + val += 6 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 6 * (int)input[18 * plane_in + i]; + val += 3 * (int)input[19 * plane_in + i]; + val += 2 * (int)input[20 * plane_in + i]; + val += 4 * (int)input[21 * plane_in + i]; + val += 4 * (int)input[22 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +#elif QRUOV_q == 127 && QRUOV_L == 10 +void reevaluate_scalar_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 98 * (int)input[0 * plane_in + i]; + val += 124 * (int)input[1 * plane_in + i]; + val += 68 * (int)input[2 * plane_in + i]; + val += 76 * (int)input[3 * plane_in + i]; + val += 42 * (int)input[4 * plane_in + i]; + val += 85 * (int)input[5 * plane_in + i]; + val += 83 * (int)input[6 * plane_in + i]; + val += 97 * (int)input[7 * plane_in + i]; + val += 108 * (int)input[8 * plane_in + i]; + val += 35 * (int)input[9 * plane_in + i]; + val += 114 * (int)input[10 * plane_in + i]; + val += 29 * (int)input[11 * plane_in + i]; + val += 85 * (int)input[12 * plane_in + i]; + val += 21 * (int)input[13 * plane_in + i]; + val += 104 * (int)input[14 * plane_in + i]; + val += 66 * (int)input[15 * plane_in + i]; + val += 105 * (int)input[16 * plane_in + i]; + val += 58 * (int)input[17 * plane_in + i]; + val += 23 * (int)input[18 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 6 * (int)input[0 * plane_in + i]; + val += 17 * (int)input[1 * plane_in + i]; + val += 91 * (int)input[2 * plane_in + i]; + val += 96 * (int)input[3 * plane_in + i]; + val += 27 * (int)input[4 * plane_in + i]; + val += 21 * (int)input[5 * plane_in + i]; + val += 56 * (int)input[6 * plane_in + i]; + val += 125 * (int)input[7 * plane_in + i]; + val += 104 * (int)input[8 * plane_in + i]; + val += 65 * (int)input[9 * plane_in + i]; + val += 31 * (int)input[10 * plane_in + i]; + val += 82 * (int)input[11 * plane_in + i]; + val += 75 * (int)input[12 * plane_in + i]; + val += 30 * (int)input[13 * plane_in + i]; + val += 29 * (int)input[14 * plane_in + i]; + val += 103 * (int)input[15 * plane_in + i]; + val += 110 * (int)input[16 * plane_in + i]; + val += 76 * (int)input[17 * plane_in + i]; + val += 26 * (int)input[18 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 43 * (int)input[0 * plane_in + i]; + val += 45 * (int)input[1 * plane_in + i]; + val += 91 * (int)input[2 * plane_in + i]; + val += 71 * (int)input[3 * plane_in + i]; + val += 11 * (int)input[4 * plane_in + i]; + val += 76 * (int)input[5 * plane_in + i]; + val += 119 * (int)input[6 * plane_in + i]; + val += 119 * (int)input[7 * plane_in + i]; + val += 54 * (int)input[8 * plane_in + i]; + val += 28 * (int)input[9 * plane_in + i]; + val += 59 * (int)input[10 * plane_in + i]; + val += 38 * (int)input[11 * plane_in + i]; + val += 61 * (int)input[12 * plane_in + i]; + val += 113 * (int)input[13 * plane_in + i]; + val += 34 * (int)input[14 * plane_in + i]; + val += 53 * (int)input[15 * plane_in + i]; + val += 31 * (int)input[16 * plane_in + i]; + val += 98 * (int)input[17 * plane_in + i]; + val += 55 * (int)input[18 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 93 * (int)input[0 * plane_in + i]; + val += 95 * (int)input[1 * plane_in + i]; + val += 2 * (int)input[2 * plane_in + i]; + val += 105 * (int)input[3 * plane_in + i]; + val += 118 * (int)input[4 * plane_in + i]; + val += 106 * (int)input[5 * plane_in + i]; + val += 121 * (int)input[6 * plane_in + i]; + val += 39 * (int)input[7 * plane_in + i]; + val += 56 * (int)input[8 * plane_in + i]; + val += 103 * (int)input[9 * plane_in + i]; + val += 64 * (int)input[10 * plane_in + i]; + val += 110 * (int)input[11 * plane_in + i]; + val += 5 * (int)input[12 * plane_in + i]; + val += 15 * (int)input[13 * plane_in + i]; + val += 68 * (int)input[14 * plane_in + i]; + val += 56 * (int)input[15 * plane_in + i]; + val += 14 * (int)input[16 * plane_in + i]; + val += 101 * (int)input[17 * plane_in + i]; + val += 95 * (int)input[18 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 71 * (int)input[0 * plane_in + i]; + val += 18 * (int)input[1 * plane_in + i]; + val += 28 * (int)input[2 * plane_in + i]; + val += 18 * (int)input[3 * plane_in + i]; + val += 123 * (int)input[4 * plane_in + i]; + val += 77 * (int)input[5 * plane_in + i]; + val += 38 * (int)input[6 * plane_in + i]; + val += 45 * (int)input[7 * plane_in + i]; + val += 34 * (int)input[8 * plane_in + i]; + val += 74 * (int)input[9 * plane_in + i]; + val += 108 * (int)input[10 * plane_in + i]; + val += 36 * (int)input[11 * plane_in + i]; + val += 28 * (int)input[12 * plane_in + i]; + val += 37 * (int)input[13 * plane_in + i]; + val += 108 * (int)input[14 * plane_in + i]; + val += 6 * (int)input[15 * plane_in + i]; + val += 52 * (int)input[16 * plane_in + i]; + val += 116 * (int)input[17 * plane_in + i]; + val += 29 * (int)input[18 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 16 * (int)input[0 * plane_in + i]; + val += 4 * (int)input[1 * plane_in + i]; + val += 113 * (int)input[2 * plane_in + i]; + val += 12 * (int)input[3 * plane_in + i]; + val += 22 * (int)input[4 * plane_in + i]; + val += 90 * (int)input[5 * plane_in + i]; + val += 113 * (int)input[6 * plane_in + i]; + val += 13 * (int)input[7 * plane_in + i]; + val += 15 * (int)input[8 * plane_in + i]; + val += 88 * (int)input[9 * plane_in + i]; + val += 122 * (int)input[10 * plane_in + i]; + val += 105 * (int)input[11 * plane_in + i]; + val += 11 * (int)input[12 * plane_in + i]; + val += 77 * (int)input[13 * plane_in + i]; + val += 58 * (int)input[14 * plane_in + i]; + val += 89 * (int)input[15 * plane_in + i]; + val += 69 * (int)input[17 * plane_in + i]; + val += 100 * (int)input[18 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 40 * (int)input[0 * plane_in + i]; + val += 37 * (int)input[1 * plane_in + i]; + val += 26 * (int)input[2 * plane_in + i]; + val += 89 * (int)input[3 * plane_in + i]; + val += 49 * (int)input[4 * plane_in + i]; + val += 7 * (int)input[5 * plane_in + i]; + val += 75 * (int)input[6 * plane_in + i]; + val += 119 * (int)input[7 * plane_in + i]; + val += 38 * (int)input[8 * plane_in + i]; + val += 70 * (int)input[9 * plane_in + i]; + val += 82 * (int)input[10 * plane_in + i]; + val += 26 * (int)input[11 * plane_in + i]; + val += 9 * (int)input[12 * plane_in + i]; + val += 7 * (int)input[13 * plane_in + i]; + val += 106 * (int)input[14 * plane_in + i]; + val += 108 * (int)input[15 * plane_in + i]; + val += 71 * (int)input[16 * plane_in + i]; + val += 58 * (int)input[17 * plane_in + i]; + val += 81 * (int)input[18 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 50 * (int)input[0 * plane_in + i]; + val += 83 * (int)input[1 * plane_in + i]; + val += 90 * (int)input[2 * plane_in + i]; + val += 93 * (int)input[3 * plane_in + i]; + val += 88 * (int)input[4 * plane_in + i]; + val += 41 * (int)input[5 * plane_in + i]; + val += 70 * (int)input[6 * plane_in + i]; + val += 99 * (int)input[7 * plane_in + i]; + val += 87 * (int)input[8 * plane_in + i]; + val += 120 * (int)input[9 * plane_in + i]; + val += 33 * (int)input[10 * plane_in + i]; + val += 42 * (int)input[11 * plane_in + i]; + val += 14 * (int)input[12 * plane_in + i]; + val += 98 * (int)input[13 * plane_in + i]; + val += 27 * (int)input[14 * plane_in + i]; + val += 31 * (int)input[15 * plane_in + i]; + val += 51 * (int)input[16 * plane_in + i]; + val += 27 * (int)input[17 * plane_in + i]; + val += 24 * (int)input[18 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 29 * (int)input[0 * plane_in + i]; + val += 66 * (int)input[1 * plane_in + i]; + val += 82 * (int)input[2 * plane_in + i]; + val += 79 * (int)input[3 * plane_in + i]; + val += 69 * (int)input[4 * plane_in + i]; + val += 86 * (int)input[5 * plane_in + i]; + val += 13 * (int)input[6 * plane_in + i]; + val += 77 * (int)input[7 * plane_in + i]; + val += 21 * (int)input[8 * plane_in + i]; + val += 106 * (int)input[9 * plane_in + i]; + val += 125 * (int)input[10 * plane_in + i]; + val += 45 * (int)input[11 * plane_in + i]; + val += 22 * (int)input[12 * plane_in + i]; + val += 84 * (int)input[13 * plane_in + i]; + val += 62 * (int)input[14 * plane_in + i]; + val += 45 * (int)input[15 * plane_in + i]; + val += 55 * (int)input[16 * plane_in + i]; + val += 78 * (int)input[17 * plane_in + i]; + val += 100 * (int)input[18 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 44 * (int)input[0 * plane_in + i]; + val += 68 * (int)input[1 * plane_in + i]; + val += 9 * (int)input[2 * plane_in + i]; + val += 89 * (int)input[3 * plane_in + i]; + val += 79 * (int)input[4 * plane_in + i]; + val += 116 * (int)input[5 * plane_in + i]; + val += 81 * (int)input[6 * plane_in + i]; + val += 51 * (int)input[7 * plane_in + i]; + val += 97 * (int)input[8 * plane_in + i]; + val += 106 * (int)input[9 * plane_in + i]; + val += 8 * (int)input[10 * plane_in + i]; + val += 33 * (int)input[11 * plane_in + i]; + val += 77 * (int)input[12 * plane_in + i]; + val += 58 * (int)input[13 * plane_in + i]; + val += 71 * (int)input[14 * plane_in + i]; + val += 61 * (int)input[15 * plane_in + i]; + val += 5 * (int)input[16 * plane_in + i]; + val += 91 * (int)input[17 * plane_in + i]; + val += 33 * (int)input[18 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 54 * (int)input[0 * plane_in + i]; + val += 123 * (int)input[1 * plane_in + i]; + val += 70 * (int)input[2 * plane_in + i]; + val += 119 * (int)input[3 * plane_in + i]; + val += 102 * (int)input[4 * plane_in + i]; + val += 114 * (int)input[5 * plane_in + i]; + val += 107 * (int)input[6 * plane_in + i]; + val += 8 * (int)input[7 * plane_in + i]; + val += 5 * (int)input[8 * plane_in + i]; + val += 113 * (int)input[9 * plane_in + i]; + val += 31 * (int)input[11 * plane_in + i]; + val += 13 * (int)input[12 * plane_in + i]; + val += 58 * (int)input[13 * plane_in + i]; + val += 105 * (int)input[14 * plane_in + i]; + val += 37 * (int)input[15 * plane_in + i]; + val += 90 * (int)input[16 * plane_in + i]; + val += 122 * (int)input[17 * plane_in + i]; + val += 30 * (int)input[18 * plane_in + i]; + output[10 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 43 * (int)input[0 * plane_in + i]; + val += 110 * (int)input[1 * plane_in + i]; + val += 111 * (int)input[2 * plane_in + i]; + val += 87 * (int)input[3 * plane_in + i]; + val += 122 * (int)input[4 * plane_in + i]; + val += 113 * (int)input[5 * plane_in + i]; + val += 117 * (int)input[6 * plane_in + i]; + val += 80 * (int)input[7 * plane_in + i]; + val += 123 * (int)input[8 * plane_in + i]; + val += 86 * (int)input[9 * plane_in + i]; + val += 44 * (int)input[10 * plane_in + i]; + val += 81 * (int)input[11 * plane_in + i]; + val += 95 * (int)input[12 * plane_in + i]; + val += 19 * (int)input[13 * plane_in + i]; + val += 86 * (int)input[14 * plane_in + i]; + val += 84 * (int)input[15 * plane_in + i]; + val += 107 * (int)input[16 * plane_in + i]; + val += 17 * (int)input[17 * plane_in + i]; + val += 43 * (int)input[18 * plane_in + i]; + output[11 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 29 * (int)input[0 * plane_in + i]; + val += 103 * (int)input[1 * plane_in + i]; + val += 40 * (int)input[2 * plane_in + i]; + val += 81 * (int)input[3 * plane_in + i]; + val += 78 * (int)input[4 * plane_in + i]; + val += 12 * (int)input[5 * plane_in + i]; + val += 15 * (int)input[6 * plane_in + i]; + val += 82 * (int)input[7 * plane_in + i]; + val += 16 * (int)input[8 * plane_in + i]; + val += 90 * (int)input[9 * plane_in + i]; + val += 17 * (int)input[10 * plane_in + i]; + val += 54 * (int)input[11 * plane_in + i]; + val += 98 * (int)input[12 * plane_in + i]; + val += 7 * (int)input[13 * plane_in + i]; + val += 4 * (int)input[14 * plane_in + i]; + val += 47 * (int)input[15 * plane_in + i]; + val += 21 * (int)input[16 * plane_in + i]; + val += 96 * (int)input[17 * plane_in + i]; + val += 26 * (int)input[18 * plane_in + i]; + output[12 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 106 * (int)input[0 * plane_in + i]; + val += 15 * (int)input[1 * plane_in + i]; + val += 31 * (int)input[2 * plane_in + i]; + val += 41 * (int)input[3 * plane_in + i]; + val += 123 * (int)input[4 * plane_in + i]; + val += 91 * (int)input[5 * plane_in + i]; + val += 122 * (int)input[6 * plane_in + i]; + val += 8 * (int)input[7 * plane_in + i]; + val += 20 * (int)input[8 * plane_in + i]; + val += 52 * (int)input[9 * plane_in + i]; + val += 61 * (int)input[10 * plane_in + i]; + val += 126 * (int)input[11 * plane_in + i]; + val += 124 * (int)input[12 * plane_in + i]; + val += 5 * (int)input[13 * plane_in + i]; + val += 11 * (int)input[14 * plane_in + i]; + val += 17 * (int)input[15 * plane_in + i]; + val += 63 * (int)input[16 * plane_in + i]; + val += (int)input[17 * plane_in + i]; + val += 53 * (int)input[18 * plane_in + i]; + output[13 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 109 * (int)input[0 * plane_in + i]; + val += 77 * (int)input[1 * plane_in + i]; + val += 25 * (int)input[2 * plane_in + i]; + val += 124 * (int)input[3 * plane_in + i]; + val += 36 * (int)input[4 * plane_in + i]; + val += 110 * (int)input[5 * plane_in + i]; + val += 49 * (int)input[6 * plane_in + i]; + val += 58 * (int)input[7 * plane_in + i]; + val += 20 * (int)input[8 * plane_in + i]; + val += 57 * (int)input[9 * plane_in + i]; + val += 52 * (int)input[10 * plane_in + i]; + val += 73 * (int)input[11 * plane_in + i]; + val += 96 * (int)input[12 * plane_in + i]; + val += 19 * (int)input[13 * plane_in + i]; + val += 49 * (int)input[14 * plane_in + i]; + val += 47 * (int)input[15 * plane_in + i]; + val += 75 * (int)input[16 * plane_in + i]; + val += 68 * (int)input[17 * plane_in + i]; + val += 99 * (int)input[18 * plane_in + i]; + output[14 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 95 * (int)input[0 * plane_in + i]; + val += 75 * (int)input[1 * plane_in + i]; + val += 69 * (int)input[2 * plane_in + i]; + val += 17 * (int)input[3 * plane_in + i]; + val += 83 * (int)input[4 * plane_in + i]; + val += 44 * (int)input[5 * plane_in + i]; + val += 83 * (int)input[6 * plane_in + i]; + val += 106 * (int)input[7 * plane_in + i]; + val += 119 * (int)input[8 * plane_in + i]; + val += 37 * (int)input[9 * plane_in + i]; + val += 19 * (int)input[10 * plane_in + i]; + val += 41 * (int)input[11 * plane_in + i]; + val += 76 * (int)input[12 * plane_in + i]; + val += 116 * (int)input[13 * plane_in + i]; + val += 109 * (int)input[14 * plane_in + i]; + val += 2 * (int)input[15 * plane_in + i]; + val += 7 * (int)input[16 * plane_in + i]; + val += 46 * (int)input[17 * plane_in + i]; + val += 37 * (int)input[18 * plane_in + i]; + output[15 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 126 * (int)input[0 * plane_in + i]; + val += 61 * (int)input[1 * plane_in + i]; + val += 86 * (int)input[2 * plane_in + i]; + val += 76 * (int)input[3 * plane_in + i]; + val += 4 * (int)input[4 * plane_in + i]; + val += 79 * (int)input[6 * plane_in + i]; + val += 9 * (int)input[7 * plane_in + i]; + val += 75 * (int)input[8 * plane_in + i]; + val += 126 * (int)input[9 * plane_in + i]; + val += 101 * (int)input[10 * plane_in + i]; + val += 99 * (int)input[11 * plane_in + i]; + val += 87 * (int)input[12 * plane_in + i]; + val += 26 * (int)input[13 * plane_in + i]; + val += 115 * (int)input[14 * plane_in + i]; + val += 43 * (int)input[15 * plane_in + i]; + val += 12 * (int)input[16 * plane_in + i]; + val += 19 * (int)input[17 * plane_in + i]; + val += 59 * (int)input[18 * plane_in + i]; + output[16 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 86 * (int)input[0 * plane_in + i]; + val += 40 * (int)input[1 * plane_in + i]; + val += 59 * (int)input[2 * plane_in + i]; + val += 21 * (int)input[3 * plane_in + i]; + val += 125 * (int)input[4 * plane_in + i]; + val += 67 * (int)input[5 * plane_in + i]; + val += 7 * (int)input[6 * plane_in + i]; + val += 124 * (int)input[7 * plane_in + i]; + val += 10 * (int)input[8 * plane_in + i]; + val += 114 * (int)input[9 * plane_in + i]; + val += 124 * (int)input[10 * plane_in + i]; + val += 17 * (int)input[11 * plane_in + i]; + val += 56 * (int)input[12 * plane_in + i]; + val += 108 * (int)input[13 * plane_in + i]; + val += 14 * (int)input[14 * plane_in + i]; + val += 23 * (int)input[15 * plane_in + i]; + val += 68 * (int)input[16 * plane_in + i]; + val += 81 * (int)input[17 * plane_in + i]; + val += 50 * (int)input[18 * plane_in + i]; + output[17 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 82 * (int)input[0 * plane_in + i]; + val += 42 * (int)input[1 * plane_in + i]; + val += 95 * (int)input[2 * plane_in + i]; + val += 116 * (int)input[3 * plane_in + i]; + val += 124 * (int)input[4 * plane_in + i]; + val += 47 * (int)input[5 * plane_in + i]; + val += 28 * (int)input[6 * plane_in + i]; + val += 111 * (int)input[7 * plane_in + i]; + val += 116 * (int)input[8 * plane_in + i]; + val += 8 * (int)input[9 * plane_in + i]; + val += 108 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 91 * (int)input[12 * plane_in + i]; + val += 54 * (int)input[13 * plane_in + i]; + val += 70 * (int)input[14 * plane_in + i]; + val += 111 * (int)input[15 * plane_in + i]; + val += 17 * (int)input[16 * plane_in + i]; + val += 46 * (int)input[17 * plane_in + i]; + val += 112 * (int)input[18 * plane_in + i]; + output[18 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +void interpolate_scalar_q127L10(uint8_t *output, int plane_out, const uint8_t *input, int plane_in, int size) +{ + for (int i = 0; i < size; i++) { + { + int val = 0; + val += 98 * (int)input[0 * plane_in + i]; + val += 124 * (int)input[1 * plane_in + i]; + val += 68 * (int)input[2 * plane_in + i]; + val += 76 * (int)input[3 * plane_in + i]; + val += 42 * (int)input[4 * plane_in + i]; + val += 85 * (int)input[5 * plane_in + i]; + val += 83 * (int)input[6 * plane_in + i]; + val += 97 * (int)input[7 * plane_in + i]; + val += 108 * (int)input[8 * plane_in + i]; + val += 35 * (int)input[9 * plane_in + i]; + val += 114 * (int)input[10 * plane_in + i]; + val += 29 * (int)input[11 * plane_in + i]; + val += 85 * (int)input[12 * plane_in + i]; + val += 21 * (int)input[13 * plane_in + i]; + val += 104 * (int)input[14 * plane_in + i]; + val += 66 * (int)input[15 * plane_in + i]; + val += 105 * (int)input[16 * plane_in + i]; + val += 58 * (int)input[17 * plane_in + i]; + val += 23 * (int)input[18 * plane_in + i]; + output[0 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 85 * (int)input[0 * plane_in + i]; + val += 95 * (int)input[1 * plane_in + i]; + val += 6 * (int)input[2 * plane_in + i]; + val += 75 * (int)input[3 * plane_in + i]; + val += 94 * (int)input[4 * plane_in + i]; + val += 105 * (int)input[5 * plane_in + i]; + val += 61 * (int)input[6 * plane_in + i]; + val += 59 * (int)input[7 * plane_in + i]; + val += 50 * (int)input[8 * plane_in + i]; + val += 94 * (int)input[9 * plane_in + i]; + val += 112 * (int)input[10 * plane_in + i]; + val += 96 * (int)input[11 * plane_in + i]; + val += 120 * (int)input[12 * plane_in + i]; + val += 118 * (int)input[13 * plane_in + i]; + val += 32 * (int)input[14 * plane_in + i]; + val += 81 * (int)input[15 * plane_in + i]; + val += 118 * (int)input[16 * plane_in + i]; + val += 123 * (int)input[17 * plane_in + i]; + val += 12 * (int)input[18 * plane_in + i]; + output[1 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 25 * (int)input[0 * plane_in + i]; + val += 53 * (int)input[1 * plane_in + i]; + val += 53 * (int)input[2 * plane_in + i]; + val += 67 * (int)input[3 * plane_in + i]; + val += 67 * (int)input[4 * plane_in + i]; + val += 111 * (int)input[5 * plane_in + i]; + val += 111 * (int)input[6 * plane_in + i]; + val += 18 * (int)input[7 * plane_in + i]; + val += 18 * (int)input[8 * plane_in + i]; + val += 94 * (int)input[9 * plane_in + i]; + val += 94 * (int)input[10 * plane_in + i]; + val += 113 * (int)input[11 * plane_in + i]; + val += 113 * (int)input[12 * plane_in + i]; + val += 22 * (int)input[13 * plane_in + i]; + val += 22 * (int)input[14 * plane_in + i]; + val += 81 * (int)input[15 * plane_in + i]; + val += 81 * (int)input[16 * plane_in + i]; + val += 13 * (int)input[18 * plane_in + i]; + output[2 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 36 * (int)input[0 * plane_in + i]; + val += 72 * (int)input[1 * plane_in + i]; + val += 63 * (int)input[2 * plane_in + i]; + val += 112 * (int)input[3 * plane_in + i]; + val += 28 * (int)input[4 * plane_in + i]; + val += 65 * (int)input[5 * plane_in + i]; + val += 73 * (int)input[6 * plane_in + i]; + val += 93 * (int)input[7 * plane_in + i]; + val += 86 * (int)input[8 * plane_in + i]; + val += 90 * (int)input[9 * plane_in + i]; + val += 100 * (int)input[10 * plane_in + i]; + val += 7 * (int)input[11 * plane_in + i]; + val += 72 * (int)input[12 * plane_in + i]; + val += 68 * (int)input[13 * plane_in + i]; + val += 75 * (int)input[14 * plane_in + i]; + val += 92 * (int)input[15 * plane_in + i]; + val += 31 * (int)input[16 * plane_in + i]; + val += 107 * (int)input[17 * plane_in + i]; + val += 5 * (int)input[18 * plane_in + i]; + output[3 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 69 * (int)input[0 * plane_in + i]; + val += 108 * (int)input[1 * plane_in + i]; + val += 86 * (int)input[2 * plane_in + i]; + val += 67 * (int)input[3 * plane_in + i]; + val += 106 * (int)input[4 * plane_in + i]; + val += 17 * (int)input[5 * plane_in + i]; + val += 105 * (int)input[6 * plane_in + i]; + val += 25 * (int)input[7 * plane_in + i]; + val += 34 * (int)input[8 * plane_in + i]; + val += 37 * (int)input[9 * plane_in + i]; + val += 29 * (int)input[10 * plane_in + i]; + val += 42 * (int)input[11 * plane_in + i]; + val += (int)input[12 * plane_in + i]; + val += 39 * (int)input[13 * plane_in + i]; + val += 65 * (int)input[14 * plane_in + i]; + val += 46 * (int)input[15 * plane_in + i]; + val += 66 * (int)input[16 * plane_in + i]; + val += 74 * (int)input[17 * plane_in + i]; + val += 7 * (int)input[18 * plane_in + i]; + output[4 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 103 * (int)input[0 * plane_in + i]; + val += 50 * (int)input[1 * plane_in + i]; + val += 62 * (int)input[2 * plane_in + i]; + val += 44 * (int)input[3 * plane_in + i]; + val += 50 * (int)input[4 * plane_in + i]; + val += 32 * (int)input[5 * plane_in + i]; + val += 100 * (int)input[6 * plane_in + i]; + val += 44 * (int)input[7 * plane_in + i]; + val += 82 * (int)input[8 * plane_in + i]; + val += 29 * (int)input[9 * plane_in + i]; + val += 86 * (int)input[10 * plane_in + i]; + val += 20 * (int)input[11 * plane_in + i]; + val += 120 * (int)input[12 * plane_in + i]; + val += 36 * (int)input[13 * plane_in + i]; + val += 30 * (int)input[14 * plane_in + i]; + val += 56 * (int)input[15 * plane_in + i]; + val += 72 * (int)input[17 * plane_in + i]; + val += 24 * (int)input[18 * plane_in + i]; + output[5 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 82 * (int)input[0 * plane_in + i]; + val += 26 * (int)input[1 * plane_in + i]; + val += 8 * (int)input[2 * plane_in + i]; + val += 57 * (int)input[3 * plane_in + i]; + val += 22 * (int)input[4 * plane_in + i]; + val += 42 * (int)input[5 * plane_in + i]; + val += 78 * (int)input[6 * plane_in + i]; + val += 31 * (int)input[7 * plane_in + i]; + val += 6 * (int)input[8 * plane_in + i]; + val += 27 * (int)input[9 * plane_in + i]; + val += 111 * (int)input[10 * plane_in + i]; + val += 89 * (int)input[11 * plane_in + i]; + val += 56 * (int)input[12 * plane_in + i]; + val += 34 * (int)input[13 * plane_in + i]; + val += 42 * (int)input[14 * plane_in + i]; + val += 111 * (int)input[15 * plane_in + i]; + val += 91 * (int)input[16 * plane_in + i]; + val += 103 * (int)input[17 * plane_in + i]; + val += 80 * (int)input[18 * plane_in + i]; + output[6 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 120 * (int)input[0 * plane_in + i]; + val += 108 * (int)input[1 * plane_in + i]; + val += 28 * (int)input[2 * plane_in + i]; + val += 110 * (int)input[3 * plane_in + i]; + val += 93 * (int)input[4 * plane_in + i]; + val += 41 * (int)input[5 * plane_in + i]; + val += 24 * (int)input[6 * plane_in + i]; + val += 77 * (int)input[7 * plane_in + i]; + val += 72 * (int)input[8 * plane_in + i]; + val += 115 * (int)input[9 * plane_in + i]; + val += 88 * (int)input[10 * plane_in + i]; + val += 22 * (int)input[11 * plane_in + i]; + val += 112 * (int)input[12 * plane_in + i]; + val += 108 * (int)input[14 * plane_in + i]; + val += 66 * (int)input[15 * plane_in + i]; + val += 64 * (int)input[16 * plane_in + i]; + val += 22 * (int)input[17 * plane_in + i]; + val += 23 * (int)input[18 * plane_in + i]; + output[7 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 68 * (int)input[0 * plane_in + i]; + val += 101 * (int)input[1 * plane_in + i]; + val += 3 * (int)input[2 * plane_in + i]; + val += 7 * (int)input[3 * plane_in + i]; + val += 36 * (int)input[4 * plane_in + i]; + val += 111 * (int)input[5 * plane_in + i]; + val += 28 * (int)input[6 * plane_in + i]; + val += 78 * (int)input[7 * plane_in + i]; + val += 40 * (int)input[8 * plane_in + i]; + val += 44 * (int)input[9 * plane_in + i]; + val += 78 * (int)input[10 * plane_in + i]; + val += 41 * (int)input[11 * plane_in + i]; + val += 67 * (int)input[12 * plane_in + i]; + val += 19 * (int)input[13 * plane_in + i]; + val += 116 * (int)input[14 * plane_in + i]; + val += 28 * (int)input[15 * plane_in + i]; + val += 45 * (int)input[16 * plane_in + i]; + val += 106 * (int)input[17 * plane_in + i]; + val += 108 * (int)input[18 * plane_in + i]; + output[8 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + { + int val = 0; + val += 82 * (int)input[0 * plane_in + i]; + val += 42 * (int)input[1 * plane_in + i]; + val += 95 * (int)input[2 * plane_in + i]; + val += 116 * (int)input[3 * plane_in + i]; + val += 124 * (int)input[4 * plane_in + i]; + val += 47 * (int)input[5 * plane_in + i]; + val += 28 * (int)input[6 * plane_in + i]; + val += 111 * (int)input[7 * plane_in + i]; + val += 116 * (int)input[8 * plane_in + i]; + val += 8 * (int)input[9 * plane_in + i]; + val += 108 * (int)input[10 * plane_in + i]; + val += 4 * (int)input[11 * plane_in + i]; + val += 91 * (int)input[12 * plane_in + i]; + val += 54 * (int)input[13 * plane_in + i]; + val += 70 * (int)input[14 * plane_in + i]; + val += 111 * (int)input[15 * plane_in + i]; + val += 17 * (int)input[16 * plane_in + i]; + val += 46 * (int)input[17 * plane_in + i]; + val += 112 * (int)input[18 * plane_in + i]; + output[9 * plane_out + i] = (uint8_t)(val % QRUOV_q); + } + } +} +#endif diff --git a/src/sig/qruov/qruov_qruov_opt/fastop.h b/src/sig/qruov/qruov_qruov_opt/fastop.h new file mode 100644 index 0000000000..c13efe3871 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_opt/fastop.h @@ -0,0 +1,162 @@ +#ifndef FASTOP_H +#define FASTOP_H + +#include +#include +#include "qruov.h" + +static inline void fastop_rejection_sample(uint8_t *dst, int tau, int length) +{ + for (int i = 0; i < tau; i++) { + dst[i] &= QRUOV_q; + } + const uint8_t *aux = dst + length; + const uint8_t *aux_end = dst + tau; + while (aux < aux_end && *aux == QRUOV_q) aux++; + for (int i = 0; i < length; i++) { + if (*dst == QRUOV_q) { + if (aux < aux_end) { + *dst = *aux++; + while (aux < aux_end && *aux == QRUOV_q) aux++; + } else { + *dst = 0; + } + } + dst++; + } +} + +static inline uint8_t fastop_rejection_dotprod(unsigned int length, unsigned int tau, + uint8_t *src, const uint8_t *vec) +{ + uint32_t sum = 0; + // src is scratch input here; only the returned dot product is used. + for (unsigned int i = 0; i < tau; i++) { + src[i] &= QRUOV_q; + } + const uint8_t *aux = src + length; + const uint8_t *aux_end = src + tau; + while (aux < aux_end && *aux == QRUOV_q) aux++; + for (unsigned int i = 0; i < length; i++) { + uint8_t v = src[i]; + if (v == QRUOV_q) { + if (aux < aux_end) { + v = *aux++; + while (aux < aux_end && *aux == QRUOV_q) aux++; + } else { + v = 0; + } + } + sum += (uint32_t)v * vec[i]; + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline uint8_t fastop_dotprod(unsigned int length, const uint8_t *a, const uint8_t *b) +{ + uint32_t sum = 0; + for (unsigned int i = 0; i < length; i++) { + sum += (uint32_t)a[i] * b[i]; + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline void fastop_row_elim(uint8_t *dst, const uint8_t *pivot, uint8_t m_mul, int len) +{ + for (int t = 0; t < len; t++) { + dst[t] = (uint8_t)(((uint32_t)dst[t] + (uint32_t)m_mul * pivot[t]) % QRUOV_q); + } +} + +static inline void fastop_store_fq(uint8_t *dst, const uint8_t *src, size_t src_len) +{ + size_t out = 0; + uint32_t acc = 0; + unsigned bits = 0; + for (size_t i = 0; i < src_len; i++) { + acc |= (uint32_t)src[i] << bits; + bits += QRUOV_q_LOG; + while (bits >= 8) { + dst[out++] = (uint8_t)acc; + acc >>= 8; + bits -= 8; + } + } + if (bits > 0) dst[out] = (uint8_t)acc; +} + +static inline void fastop_load_fq(uint8_t *dst, const uint8_t *src, size_t dst_len) +{ + size_t i = 0; + size_t in = 0; + uint32_t acc = 0; + unsigned bits = 0; + +#if QRUOV_q_LOG == 3 + while (dst_len - i >= 8) { + uint32_t packed = (uint32_t)src[in] | + ((uint32_t)src[in + 1] << 8) | + ((uint32_t)src[in + 2] << 16); + dst[i + 0] = (uint8_t)(packed & QRUOV_q); + dst[i + 1] = (uint8_t)((packed >> 3) & QRUOV_q); + dst[i + 2] = (uint8_t)((packed >> 6) & QRUOV_q); + dst[i + 3] = (uint8_t)((packed >> 9) & QRUOV_q); + dst[i + 4] = (uint8_t)((packed >> 12) & QRUOV_q); + dst[i + 5] = (uint8_t)((packed >> 15) & QRUOV_q); + dst[i + 6] = (uint8_t)((packed >> 18) & QRUOV_q); + dst[i + 7] = (uint8_t)((packed >> 21) & QRUOV_q); + i += 8; + in += 3; + } +#elif QRUOV_q_LOG == 5 + while (dst_len - i >= 8) { + uint64_t packed = (uint64_t)src[in] | + ((uint64_t)src[in + 1] << 8) | + ((uint64_t)src[in + 2] << 16) | + ((uint64_t)src[in + 3] << 24) | + ((uint64_t)src[in + 4] << 32); + dst[i + 0] = (uint8_t)(packed & QRUOV_q); + dst[i + 1] = (uint8_t)((packed >> 5) & QRUOV_q); + dst[i + 2] = (uint8_t)((packed >> 10) & QRUOV_q); + dst[i + 3] = (uint8_t)((packed >> 15) & QRUOV_q); + dst[i + 4] = (uint8_t)((packed >> 20) & QRUOV_q); + dst[i + 5] = (uint8_t)((packed >> 25) & QRUOV_q); + dst[i + 6] = (uint8_t)((packed >> 30) & QRUOV_q); + dst[i + 7] = (uint8_t)((packed >> 35) & QRUOV_q); + i += 8; + in += 5; + } +#elif QRUOV_q_LOG == 7 + while (dst_len - i >= 8) { + uint64_t packed = (uint64_t)src[in] | + ((uint64_t)src[in + 1] << 8) | + ((uint64_t)src[in + 2] << 16) | + ((uint64_t)src[in + 3] << 24) | + ((uint64_t)src[in + 4] << 32) | + ((uint64_t)src[in + 5] << 40) | + ((uint64_t)src[in + 6] << 48); + dst[i + 0] = (uint8_t)(packed & QRUOV_q); + dst[i + 1] = (uint8_t)((packed >> 7) & QRUOV_q); + dst[i + 2] = (uint8_t)((packed >> 14) & QRUOV_q); + dst[i + 3] = (uint8_t)((packed >> 21) & QRUOV_q); + dst[i + 4] = (uint8_t)((packed >> 28) & QRUOV_q); + dst[i + 5] = (uint8_t)((packed >> 35) & QRUOV_q); + dst[i + 6] = (uint8_t)((packed >> 42) & QRUOV_q); + dst[i + 7] = (uint8_t)((packed >> 49) & QRUOV_q); + i += 8; + in += 7; + } +#endif + + for (; i < dst_len; i++) { + while (bits < QRUOV_q_LOG) { + acc |= ((uint32_t)src[in++]) << bits; + bits += 8; + } + dst[i] = (uint8_t)(acc & QRUOV_q); + acc >>= QRUOV_q_LOG; + bits -= QRUOV_q_LOG; + } +} + +#endif // FASTOP_H diff --git a/src/sig/qruov/qruov_qruov_opt/qruov.c b/src/sig/qruov/qruov_qruov_opt/qruov.c new file mode 100644 index 0000000000..75b05c6e38 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_opt/qruov.c @@ -0,0 +1,236 @@ +#include +#include "qruov.h" +#include "qrop.h" +#include "prg.h" +#include "util.h" +#include "linsys.h" +#include "gf.h" +#include "emi_transform.h" +#include "fql.h" +#include "qruov_common.h" + +void qruov_init(void) +{ +} + +// Convert AoS [rows][cols][L] to SoA [L][rows][cols]. +static void fql_aos_to_soa(uint8_t *dst_soa, const uint8_t *src_aos, int rows, int cols) +{ + int n = rows * cols; + for (int i = 0; i < n; i++) { + for (int l = 0; l < QRUOV_L; l++) { + dst_soa[l * n + i] = src_aos[i * QRUOV_L + l]; + } + } +} + +// Convert SoA [L][rows][cols] to AoS [rows][cols][L]. +static void fql_soa_to_aos(uint8_t *dst_aos, const uint8_t *src_soa, int rows, int cols) +{ + int n = rows * cols; + for (int l = 0; l < QRUOV_L; l++) { + for (int i = 0; i < n; i++) { + dst_aos[i * QRUOV_L + l] = src_soa[l * n + i]; + } + } +} + +// Convert AoS [rows][cols][L] to eval-domain SoA [LL][rows][cols]. +static void fql_aos_to_eval(uint8_t *dst_eval, const uint8_t *src_aos, int rows, int cols) +{ + const int plane = rows * cols; + uint8_t src_soa[QRUOV_L * plane]; + fql_aos_to_soa(src_soa, src_aos, rows, cols); + evaluate(dst_eval, plane, src_soa, plane, plane); +} + +// Transpose plane-major matrix [planes][rows][cols] -> [planes][cols][rows]. +static void fq_transpose_planes(uint8_t *dst, const uint8_t *src, int planes, int rows, int cols) +{ + for (int p = 0; p < planes; p++) { + const uint8_t *sp = &src[p * rows * cols]; + uint8_t *dp = &dst[p * rows * cols]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + dp[j * rows + i] = sp[i * cols + j]; + } + } + } +} + +// C[planes][M][N] = A[planes][M][K] * B^T[planes][N][K] over F_q. +static void fq_matmul_transposed_planes(uint8_t *restrict C, const uint8_t *restrict A, + const uint8_t *restrict BT, int planes, int M, int N, int K) +{ + for (int p = 0; p < planes; p++) { + const uint8_t *Ap = &A[p * M * K]; + const uint8_t *BTp = &BT[p * N * K]; + uint8_t *Cp = &C[p * M * N]; + for (int i = 0; i < M; i++) { + const uint8_t *Ai = &Ap[i * K]; + uint8_t *Ci = &Cp[i * N]; + + int j = 0; + for (; j + 1 < N; j += 2) { + const uint8_t *BTj0 = &BTp[j * K]; + const uint8_t *BTj1 = BTj0 + K; + uint32_t sum0 = 0; + uint32_t sum1 = 0; + for (int k = 0; k < K; k++) { + uint32_t aik = Ai[k]; + sum0 += aik * BTj0[k]; + sum1 += aik * BTj1[k]; + } + Ci[j] = gf_reduce(sum0); + Ci[j + 1] = gf_reduce(sum1); + } + + if (j < N) { + const uint8_t *BTj = &BTp[j * K]; + Ci[j] = fastop_dotprod((unsigned int)K, Ai, BTj); + } + } + } +} + +static void fq_minus_a_plus_b_plus_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, const uint8_t *c, size_t len) +{ + for (size_t i = 0; i < len; i++) { + uint32_t sum = (uint32_t)(QRUOV_q - a[i]) + b[i] + c[i]; + dst[i] = gf_reduce(sum); + } +} + +static void sigmap_sym_features(uint8_t *dst, const uint8_t *vec, int len) +{ + size_t idx = 0; + for (int i = 0; i < len; i++) { + for (int j = i; j < len; j++) { + uint8_t prod[QRUOV_L]; + fql_mul(prod, &vec[i * QRUOV_L], &vec[j * QRUOV_L]); + if (i != j) { + fql_add(prod, prod, prod); + } + fql_perm(&dst[idx], prod); + idx += QRUOV_L; + } + } +} + +static void sigmap_rect_features(uint8_t *dst, const uint8_t *a, int rows, const uint8_t *b, int cols) +{ + size_t idx = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + uint8_t prod[QRUOV_L]; + fql_mul(prod, &a[i * QRUOV_L], &b[j * QRUOV_L]); + fql_perm(&dst[idx], prod); + idx += QRUOV_L; + } + } +} + +void qruov_keygen(const SEED_PK seed_pk, const SEED_SK seed_sk, uint8_t pk_p3[P3_SERIALIZED_LEN]) +{ + uint8_t sdt[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t sdt_eval[QRUOV_LL * QRUOV_M * QRUOV_V]; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + int chunk_eqs = 0; + size_t p3_offset = 0; + prepare_sdt_from_seed(sdt, seed_sk); + fql_aos_to_eval(sdt_eval, sdt, QRUOV_M, QRUOV_V); + prg pk_prg; + prg_init(&pk_prg, seed_pk); + for (int eq = 0; eq < QRUOV_m; eq++) { + uint8_t pi1[QRUOV_V * QRUOV_V * QRUOV_L]; + uint8_t pi2t[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t pi1_eval[QRUOV_LL * QRUOV_V * QRUOV_V]; + uint8_t pi2t_eval[QRUOV_LL * QRUOV_M * QRUOV_V]; + uint8_t sdt_pi1_eval[QRUOV_LL * QRUOV_M * QRUOV_V]; + uint8_t sdt_pi1_reval[QRUOV_LL * QRUOV_M * QRUOV_V]; + uint8_t sdt_pi2_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t pi2t_sd_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t pi3_eval[QRUOV_LL * QRUOV_M * QRUOV_M]; + uint8_t pi3_soa[QRUOV_L * QRUOV_M * QRUOV_M]; + uint8_t pi3[QRUOV_M * QRUOV_M * QRUOV_L]; + prepare_pi1_from_prg(pi1, &pk_prg, (uint16_t)eq); + prepare_pi2t_from_prg(pi2t, &pk_prg, (uint16_t)eq); + + fql_aos_to_eval(pi1_eval, pi1, QRUOV_V, QRUOV_V); + fql_aos_to_eval(pi2t_eval, pi2t, QRUOV_M, QRUOV_V); + + fq_matmul_transposed_planes(sdt_pi2_eval, sdt_eval, pi2t_eval, QRUOV_LL, QRUOV_M, QRUOV_M, QRUOV_V); + fq_transpose_planes(pi2t_sd_eval, sdt_pi2_eval, QRUOV_LL, QRUOV_M, QRUOV_M); + + fq_matmul_transposed_planes(sdt_pi1_eval, sdt_eval, pi1_eval, QRUOV_LL, QRUOV_M, QRUOV_V, QRUOV_V); + reevaluate(sdt_pi1_reval, QRUOV_M * QRUOV_V, sdt_pi1_eval, QRUOV_M * QRUOV_V, QRUOV_M * QRUOV_V); + fq_matmul_transposed_planes(pi3_eval, sdt_pi1_reval, sdt_eval, QRUOV_LL, QRUOV_M, QRUOV_M, QRUOV_V); + fq_minus_a_plus_b_plus_c(pi3_eval, pi3_eval, pi2t_sd_eval, sdt_pi2_eval, sizeof(pi3_eval)); + + interpolate(pi3_soa, QRUOV_M * QRUOV_M, pi3_eval, QRUOV_M * QRUOV_M, QRUOV_M * QRUOV_M); + fql_soa_to_aos(pi3, pi3_soa, QRUOV_M, QRUOV_M); + p3_store_upper_MxM(&p3_chunk[chunk_eqs * P3_EQ_COEFF_LEN], pi3); + chunk_eqs++; + if (chunk_eqs == P3_CHUNK_EQS) { + store_fq(pk_p3 + p3_offset, p3_chunk, P3_CHUNK_COEFF_LEN); + p3_offset += BITS2BYTE(QRUOV_q_LOG * P3_CHUNK_COEFF_LEN); + chunk_eqs = 0; + } + } + if (chunk_eqs > 0) { + store_fq(pk_p3 + p3_offset, p3_chunk, (size_t)chunk_eqs * P3_EQ_COEFF_LEN); + } + prg_free(&pk_prg); + secure_zero(sdt, sizeof(sdt)); + secure_zero(sdt_eval, sizeof(sdt_eval)); +} + +int qruov_sign(const SEED_PK seed_pk, const SEED_SK seed_sk, const SEED_SK seed_y, const SEED_SK seed_r, const SEED_SK seed_sol, const uint8_t msg[], size_t msg_len, SALT sig_r, SIG_S sig_s) +{ + return qruov_common_sign_scalar(seed_pk, seed_sk, seed_y, seed_r, seed_sol, + msg, msg_len, sig_r, sig_s); +} + +int qruov_verify(const SEED_PK seed_pk, const uint8_t pk_p3[P3_SERIALIZED_LEN], const uint8_t msg[], size_t msg_len, const SALT sig_r, const SIG_S sig_s) +{ + uint8_t t[QRUOV_m]; + const uint8_t *vinegar = sig_s; + const uint8_t *oil = sig_s + QRUOV_V * QRUOV_L; + uint8_t s11[QRUOV_n1]; + uint8_t s12[QRUOV_n2]; + uint8_t s22[P3_EQ_COEFF_LEN]; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + prg pk_prg; + if (!qruov_common_is_canonical_s(sig_s)) return 0; + compute_mu_and_hash(t, seed_pk, msg, msg_len, sig_r); + sigmap_sym_features(s11, vinegar, QRUOV_V); + sigmap_rect_features(s12, vinegar, QRUOV_V, oil, QRUOV_M); + sigmap_sym_features(s22, oil, QRUOV_M); + prg_init(&pk_prg, seed_pk); + int ok = 1; + size_t p3_offset = 0; + for (int eq_base = 0; eq_base < QRUOV_m; eq_base += P3_CHUNK_EQS) { + int chunk_eqs = QRUOV_m - eq_base; + if (chunk_eqs > P3_CHUNK_EQS) chunk_eqs = P3_CHUNK_EQS; + size_t chunk_coeffs = (size_t)chunk_eqs * P3_EQ_COEFF_LEN; + if (!load_fq_checked(p3_chunk, pk_p3 + p3_offset, chunk_coeffs)) { + ok = 0; + memset(p3_chunk, 0, chunk_coeffs); + } + p3_offset += BITS2BYTE(QRUOV_q_LOG * chunk_coeffs); + for (int chunk_eq = 0; chunk_eq < chunk_eqs; chunk_eq++) { + int eq = eq_base + chunk_eq; + uint8_t pi1_raw[QRUOV_tau_n1]; + uint8_t pi2_raw[QRUOV_tau_n2]; + uint32_t sum = 0; + prepare_pi1_raw_from_prg(pi1_raw, &pk_prg, (uint16_t)eq); + sum += fastop_rejection_dotprod(QRUOV_n1, QRUOV_tau_n1, pi1_raw, s11); + prepare_pi2_raw_from_prg(pi2_raw, &pk_prg, (uint16_t)eq); + sum += 2u * fastop_rejection_dotprod(QRUOV_n2, QRUOV_tau_n2, pi2_raw, s12); + sum += fastop_dotprod(P3_EQ_COEFF_LEN, s22, &p3_chunk[chunk_eq * P3_EQ_COEFF_LEN]); + ok &= (gf_reduce(sum) == t[eq]); + } + } + prg_free(&pk_prg); + return ok; +} diff --git a/src/sig/qruov/qruov_qruov_ref/fastop.h b/src/sig/qruov/qruov_qruov_ref/fastop.h new file mode 100644 index 0000000000..d73ac34497 --- /dev/null +++ b/src/sig/qruov/qruov_qruov_ref/fastop.h @@ -0,0 +1,90 @@ +#ifndef FASTOP_H +#define FASTOP_H + +#include +#include +#include "qruov.h" + +static inline void fastop_rejection_sample(uint8_t *dst, int tau, int length) +{ + for (int i = 0; i < tau; i++) { + dst[i] &= QRUOV_q; + } + const uint8_t *aux = dst + length; + const uint8_t *aux_end = dst + tau; + while (aux < aux_end && *aux == QRUOV_q) aux++; + for (int i = 0; i < length; i++) { + if (*dst == QRUOV_q) { + if (aux < aux_end) { + *dst = *aux++; + while (aux < aux_end && *aux == QRUOV_q) aux++; + } else { + *dst = 0; + } + } + dst++; + } +} + +static inline uint8_t fastop_rejection_dotprod(unsigned int length, unsigned int tau, + uint8_t *src, const uint8_t *vec) +{ + uint32_t sum = 0; + fastop_rejection_sample(src, (int)tau, (int)length); + for (unsigned int i = 0; i < length; i++) { + sum += (uint32_t)src[i] * vec[i]; + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline uint8_t fastop_dotprod(unsigned int length, const uint8_t *a, const uint8_t *b) +{ + uint32_t sum = 0; + for (unsigned int i = 0; i < length; i++) { + sum += (uint32_t)a[i] * b[i]; + } + return (uint8_t)(sum % QRUOV_q); +} + +static inline void fastop_row_elim(uint8_t *dst, const uint8_t *pivot, uint8_t m_mul, int len) +{ + for (int t = 0; t < len; t++) { + dst[t] = (uint8_t)(((uint32_t)dst[t] + (uint32_t)m_mul * pivot[t]) % QRUOV_q); + } +} + +static inline void fastop_store_fq(uint8_t *dst, const uint8_t *src, size_t src_len) +{ + size_t out = 0; + uint32_t acc = 0; + unsigned bits = 0; + for (size_t i = 0; i < src_len; i++) { + acc |= (uint32_t)src[i] << bits; + bits += QRUOV_q_LOG; + while (bits >= 8) { + dst[out++] = (uint8_t)acc; + acc >>= 8; + bits -= 8; + } + } + if (bits > 0) dst[out] = (uint8_t)acc; +} + +static inline void fastop_load_fq(uint8_t *dst, const uint8_t *src, size_t dst_len) +{ + size_t in = 0; + uint32_t acc = 0; + unsigned bits = 0; + const uint32_t mask = (1u << QRUOV_q_LOG) - 1u; + for (size_t i = 0; i < dst_len; i++) { + while (bits < QRUOV_q_LOG) { + acc |= ((uint32_t)src[in++]) << bits; + bits += 8; + } + dst[i] = (uint8_t)(acc & mask); + acc >>= QRUOV_q_LOG; + bits -= QRUOV_q_LOG; + } +} + +#endif // FASTOP_H diff --git a/src/sig/qruov/qruov_qruov_ref/qruov.c b/src/sig/qruov/qruov_qruov_ref/qruov.c new file mode 100644 index 0000000000..34d3844adc --- /dev/null +++ b/src/sig/qruov/qruov_qruov_ref/qruov.c @@ -0,0 +1,136 @@ +#include "qruov.h" +#include "qrop.h" +#include "prg.h" +#include "util.h" +#include "linsys.h" +#include "gf.h" +#include "fql.h" +#include "qruov_common.h" + +void qruov_init(void) +{ +} + +static void fql_neg_upper_mul_MxV_MxVt(uint8_t *pi3, const uint8_t *A_MxV, const uint8_t *B_MxV) +{ + uint8_t zero[QRUOV_L]; + fql_zero(zero); + // Only the upper triangle of pi3 is defined in ref keygen. + for (int i = 0; i < QRUOV_M; i++) { + for (int j = i; j < QRUOV_M; j++) { + uint8_t tmp[QRUOV_L]; + fql_dot_V(tmp, &A_MxV[i * QRUOV_V * QRUOV_L], &B_MxV[j * QRUOV_V * QRUOV_L]); + fql_sub(&pi3[(i * QRUOV_M + j) * QRUOV_L], zero, tmp); + } + } +} + +static void fql_add_upper_symmetrized_MxM(uint8_t *pi3, const uint8_t *src) +{ + for (int i = 0; i < QRUOV_M; i++) { + for (int j = i; j < QRUOV_M; j++) { + uint8_t symm[QRUOV_L]; + fql_add(symm, &src[(i * QRUOV_M + j) * QRUOV_L], &src[(j * QRUOV_M + i) * QRUOV_L]); + fql_add(&pi3[(i * QRUOV_M + j) * QRUOV_L], &pi3[(i * QRUOV_M + j) * QRUOV_L], symm); + } + } +} + +void qruov_keygen(const SEED_PK seed_pk, const SEED_SK seed_sk, uint8_t pk_p3[P3_SERIALIZED_LEN]) +{ + uint8_t sdt[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t pi1[QRUOV_V * QRUOV_V * QRUOV_L]; + uint8_t pi2t[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t sdt_pi1[QRUOV_M * QRUOV_V * QRUOV_L]; + uint8_t sdt_pi2[QRUOV_M * QRUOV_M * QRUOV_L]; + uint8_t pi3[QRUOV_M * QRUOV_M * QRUOV_L]; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + int chunk_eqs = 0; + size_t p3_offset = 0; + prepare_sdt_from_seed(sdt, seed_sk); + prg pk_prg; + prg_init(&pk_prg, seed_pk); + for (int eq = 0; eq < QRUOV_m; eq++) { + prepare_pi1_from_prg(pi1, &pk_prg, (uint16_t)eq); + prepare_pi2t_from_prg(pi2t, &pk_prg, (uint16_t)eq); + fql_mul_MxV_VxVt(sdt_pi1, sdt, pi1); + // The lower triangle is intentionally left uninitialized: the helpers + // below update only the upper triangle, and only that upper triangle is packed. + fql_neg_upper_mul_MxV_MxVt(pi3, sdt_pi1, sdt); + fql_mul_MxV_MxVt(sdt_pi2, sdt, pi2t); + fql_add_upper_symmetrized_MxM(pi3, sdt_pi2); + p3_store_upper_MxM(&p3_chunk[chunk_eqs * P3_EQ_COEFF_LEN], pi3); + chunk_eqs++; + if (chunk_eqs == P3_CHUNK_EQS) { + store_fq(pk_p3 + p3_offset, p3_chunk, P3_CHUNK_COEFF_LEN); + p3_offset += BITS2BYTE(QRUOV_q_LOG * P3_CHUNK_COEFF_LEN); + chunk_eqs = 0; + } + } + if (chunk_eqs > 0) { + store_fq(pk_p3 + p3_offset, p3_chunk, (size_t)chunk_eqs * P3_EQ_COEFF_LEN); + } + prg_free(&pk_prg); + secure_zero(sdt, sizeof(sdt)); + secure_zero(sdt_pi1, sizeof(sdt_pi1)); + secure_zero(sdt_pi2, sizeof(sdt_pi2)); +} + +int qruov_sign(const SEED_PK seed_pk, const SEED_SK seed_sk, const SEED_SK seed_y, const SEED_SK seed_r, const SEED_SK seed_sol, const uint8_t msg[], size_t msg_len, SALT sig_r, SIG_S sig_s) +{ + return qruov_common_sign_scalar(seed_pk, seed_sk, seed_y, seed_r, seed_sol, + msg, msg_len, sig_r, sig_s); +} + +int qruov_verify(const SEED_PK seed_pk, const uint8_t pk_p3[P3_SERIALIZED_LEN], const uint8_t msg[], size_t msg_len, const SALT sig_r, const SIG_S sig_s) +{ + uint8_t t[QRUOV_m]; + const int perm0 = QRUOV_perm(0); + const uint8_t *vinegar = sig_s; + const uint8_t *oil = sig_s + QRUOV_V * QRUOV_L; + uint8_t p3_chunk[P3_CHUNK_COEFF_LEN]; + prg pk_prg; + if (!qruov_common_is_canonical_s(sig_s)) return 0; + compute_mu_and_hash(t, seed_pk, msg, msg_len, sig_r); + prg_init(&pk_prg, seed_pk); + int ok = 1; + size_t p3_offset = 0; + for (int eq_base = 0; eq_base < QRUOV_m; eq_base += P3_CHUNK_EQS) { + int chunk_eqs = QRUOV_m - eq_base; + if (chunk_eqs > P3_CHUNK_EQS) chunk_eqs = P3_CHUNK_EQS; + size_t chunk_coeffs = (size_t)chunk_eqs * P3_EQ_COEFF_LEN; + if (!load_fq_checked(p3_chunk, pk_p3 + p3_offset, chunk_coeffs)) { + ok = 0; + memset(p3_chunk, 0, chunk_coeffs); + } + p3_offset += BITS2BYTE(QRUOV_q_LOG * chunk_coeffs); + for (int chunk_eq = 0; chunk_eq < chunk_eqs; chunk_eq++) { + int eq = eq_base + chunk_eq; + uint8_t pi1[QRUOV_V * QRUOV_V * QRUOV_L]; + uint8_t pi2[QRUOV_tau_n2]; + uint8_t pi3[QRUOV_M * QRUOV_M * QRUOV_L]; + uint8_t pi1_v[QRUOV_V * QRUOV_L]; + uint8_t pi2_o[QRUOV_V * QRUOV_L]; + uint8_t pi3_o[QRUOV_M * QRUOV_L]; + uint8_t v_pi1_v[QRUOV_L]; + uint8_t v_pi2_o[QRUOV_L]; + uint8_t o_pi3_o[QRUOV_L]; + uint8_t lhs[QRUOV_L]; + prepare_pi1_from_prg(pi1, &pk_prg, (uint16_t)eq); + prepare_pi2_coeffs_from_prg(pi2, &pk_prg, (uint16_t)eq); + fql_mul_VxV_V(pi1_v, pi1, vinegar); + fql_dot_V(v_pi1_v, vinegar, pi1_v); + fql_mul_VxM_M(pi2_o, pi2, oil); + fql_dot_V(v_pi2_o, vinegar, pi2_o); + unpack_upper_to_symm_MxM(pi3, &p3_chunk[chunk_eq * P3_EQ_COEFF_LEN]); + fql_mul_MxM_M(pi3_o, pi3, oil); + fql_dot_M(o_pi3_o, oil, pi3_o); + fql_add(lhs, v_pi1_v, v_pi2_o); + fql_add(lhs, lhs, v_pi2_o); + fql_add(lhs, lhs, o_pi3_o); + ok &= (lhs[perm0] == t[eq]); + } + } + prg_free(&pk_prg); + return ok; +} diff --git a/src/sig/qruov/sig_qruov.h b/src/sig/qruov/sig_qruov.h new file mode 100644 index 0000000000..4efb47a50a --- /dev/null +++ b/src/sig/qruov/sig_qruov.h @@ -0,0 +1,398 @@ +// SPDX-License-Identifier: MIT + +#ifndef OQS_SIG_QRUOV_H +#define OQS_SIG_QRUOV_H + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes) +#define OQS_SIG_qruov_1q7L10aes_length_public_key 20641 +#define OQS_SIG_qruov_1q7L10aes_length_secret_key 32 +#define OQS_SIG_qruov_1q7L10aes_length_signature 331 + +OQS_SIG *OQS_SIG_qruov_1q7L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake) +#define OQS_SIG_qruov_1q7L10shake_length_public_key 20641 +#define OQS_SIG_qruov_1q7L10shake_length_secret_key 32 +#define OQS_SIG_qruov_1q7L10shake_length_signature 331 + +OQS_SIG *OQS_SIG_qruov_1q7L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes) +#define OQS_SIG_qruov_1q31L3aes_length_public_key 23641 +#define OQS_SIG_qruov_1q31L3aes_length_secret_key 32 +#define OQS_SIG_qruov_1q31L3aes_length_signature 157 + +OQS_SIG *OQS_SIG_qruov_1q31L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake) +#define OQS_SIG_qruov_1q31L3shake_length_public_key 23641 +#define OQS_SIG_qruov_1q31L3shake_length_secret_key 32 +#define OQS_SIG_qruov_1q31L3shake_length_signature 157 + +OQS_SIG *OQS_SIG_qruov_1q31L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes) +#define OQS_SIG_qruov_1q31L10aes_length_public_key 12266 +#define OQS_SIG_qruov_1q31L10aes_length_secret_key 32 +#define OQS_SIG_qruov_1q31L10aes_length_signature 435 + +OQS_SIG *OQS_SIG_qruov_1q31L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake) +#define OQS_SIG_qruov_1q31L10shake_length_public_key 12266 +#define OQS_SIG_qruov_1q31L10shake_length_secret_key 32 +#define OQS_SIG_qruov_1q31L10shake_length_signature 435 + +OQS_SIG *OQS_SIG_qruov_1q31L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes) +#define OQS_SIG_qruov_1q127L3aes_length_public_key 24256 +#define OQS_SIG_qruov_1q127L3aes_length_secret_key 32 +#define OQS_SIG_qruov_1q127L3aes_length_signature 200 + +OQS_SIG *OQS_SIG_qruov_1q127L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake) +#define OQS_SIG_qruov_1q127L3shake_length_public_key 24256 +#define OQS_SIG_qruov_1q127L3shake_length_secret_key 32 +#define OQS_SIG_qruov_1q127L3shake_length_signature 200 + +OQS_SIG *OQS_SIG_qruov_1q127L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes) +#define OQS_SIG_qruov_1q127L10aes_length_public_key 11041 +#define OQS_SIG_qruov_1q127L10aes_length_secret_key 32 +#define OQS_SIG_qruov_1q127L10aes_length_signature 541 + +OQS_SIG *OQS_SIG_qruov_1q127L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake) +#define OQS_SIG_qruov_1q127L10shake_length_public_key 11041 +#define OQS_SIG_qruov_1q127L10shake_length_secret_key 32 +#define OQS_SIG_qruov_1q127L10shake_length_signature 541 + +OQS_SIG *OQS_SIG_qruov_1q127L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes) +#define OQS_SIG_qruov_3q7L10aes_length_public_key 55141 +#define OQS_SIG_qruov_3q7L10aes_length_secret_key 32 +#define OQS_SIG_qruov_3q7L10aes_length_signature 489 + +OQS_SIG *OQS_SIG_qruov_3q7L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake) +#define OQS_SIG_qruov_3q7L10shake_length_public_key 55141 +#define OQS_SIG_qruov_3q7L10shake_length_secret_key 32 +#define OQS_SIG_qruov_3q7L10shake_length_signature 489 + +OQS_SIG *OQS_SIG_qruov_3q7L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes) +#define OQS_SIG_qruov_3q31L3aes_length_public_key 70976 +#define OQS_SIG_qruov_3q31L3aes_length_secret_key 32 +#define OQS_SIG_qruov_3q31L3aes_length_signature 233 + +OQS_SIG *OQS_SIG_qruov_3q31L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake) +#define OQS_SIG_qruov_3q31L3shake_length_public_key 70976 +#define OQS_SIG_qruov_3q31L3shake_length_secret_key 32 +#define OQS_SIG_qruov_3q31L3shake_length_signature 233 + +OQS_SIG *OQS_SIG_qruov_3q31L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes) +#define OQS_SIG_qruov_3q31L10aes_length_public_key 34391 +#define OQS_SIG_qruov_3q31L10aes_length_secret_key 32 +#define OQS_SIG_qruov_3q31L10aes_length_signature 643 + +OQS_SIG *OQS_SIG_qruov_3q31L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake) +#define OQS_SIG_qruov_3q31L10shake_length_public_key 34391 +#define OQS_SIG_qruov_3q31L10shake_length_secret_key 32 +#define OQS_SIG_qruov_3q31L10shake_length_signature 643 + +OQS_SIG *OQS_SIG_qruov_3q31L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes) +#define OQS_SIG_qruov_3q127L3aes_length_public_key 71884 +#define OQS_SIG_qruov_3q127L3aes_length_secret_key 32 +#define OQS_SIG_qruov_3q127L3aes_length_signature 292 + +OQS_SIG *OQS_SIG_qruov_3q127L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake) +#define OQS_SIG_qruov_3q127L3shake_length_public_key 71884 +#define OQS_SIG_qruov_3q127L3shake_length_secret_key 32 +#define OQS_SIG_qruov_3q127L3shake_length_signature 292 + +OQS_SIG *OQS_SIG_qruov_3q127L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes) +#define OQS_SIG_qruov_3q127L10aes_length_public_key 35454 +#define OQS_SIG_qruov_3q127L10aes_length_secret_key 32 +#define OQS_SIG_qruov_3q127L10aes_length_signature 821 + +OQS_SIG *OQS_SIG_qruov_3q127L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake) +#define OQS_SIG_qruov_3q127L10shake_length_public_key 35454 +#define OQS_SIG_qruov_3q127L10shake_length_secret_key 32 +#define OQS_SIG_qruov_3q127L10shake_length_signature 821 + +OQS_SIG *OQS_SIG_qruov_3q127L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes) +#define OQS_SIG_qruov_5q7L10aes_length_public_key 135391 +#define OQS_SIG_qruov_5q7L10aes_length_secret_key 32 +#define OQS_SIG_qruov_5q7L10aes_length_signature 662 + +OQS_SIG *OQS_SIG_qruov_5q7L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake) +#define OQS_SIG_qruov_5q7L10shake_length_public_key 135391 +#define OQS_SIG_qruov_5q7L10shake_length_secret_key 32 +#define OQS_SIG_qruov_5q7L10shake_length_signature 662 + +OQS_SIG *OQS_SIG_qruov_5q7L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes) +#define OQS_SIG_qruov_5q31L3aes_length_public_key 158405 +#define OQS_SIG_qruov_5q31L3aes_length_secret_key 32 +#define OQS_SIG_qruov_5q31L3aes_length_signature 306 + +OQS_SIG *OQS_SIG_qruov_5q31L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake) +#define OQS_SIG_qruov_5q31L3shake_length_public_key 158405 +#define OQS_SIG_qruov_5q31L3shake_length_secret_key 32 +#define OQS_SIG_qruov_5q31L3shake_length_signature 306 + +OQS_SIG *OQS_SIG_qruov_5q31L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes) +#define OQS_SIG_qruov_5q31L10aes_length_public_key 58516 +#define OQS_SIG_qruov_5q31L10aes_length_secret_key 32 +#define OQS_SIG_qruov_5q31L10aes_length_signature 807 + +OQS_SIG *OQS_SIG_qruov_5q31L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake) +#define OQS_SIG_qruov_5q31L10shake_length_public_key 58516 +#define OQS_SIG_qruov_5q31L10shake_length_secret_key 32 +#define OQS_SIG_qruov_5q31L10shake_length_signature 807 + +OQS_SIG *OQS_SIG_qruov_5q31L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes) +#define OQS_SIG_qruov_5q127L3aes_length_public_key 173660 +#define OQS_SIG_qruov_5q127L3aes_length_secret_key 32 +#define OQS_SIG_qruov_5q127L3aes_length_signature 392 + +OQS_SIG *OQS_SIG_qruov_5q127L3aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake) +#define OQS_SIG_qruov_5q127L3shake_length_public_key 173660 +#define OQS_SIG_qruov_5q127L3shake_length_secret_key 32 +#define OQS_SIG_qruov_5q127L3shake_length_signature 392 + +OQS_SIG *OQS_SIG_qruov_5q127L3shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes) +#define OQS_SIG_qruov_5q127L10aes_length_public_key 63541 +#define OQS_SIG_qruov_5q127L10aes_length_secret_key 32 +#define OQS_SIG_qruov_5q127L10aes_length_signature 1039 + +OQS_SIG *OQS_SIG_qruov_5q127L10aes_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake) +#define OQS_SIG_qruov_5q127L10shake_length_public_key 63541 +#define OQS_SIG_qruov_5q127L10shake_length_secret_key 32 +#define OQS_SIG_qruov_5q127L10shake_length_signature 1039 + +OQS_SIG *OQS_SIG_qruov_5q127L10shake_new(void); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +#endif + +#endif diff --git a/src/sig/qruov/sig_qruov_1q127L10aes.c b/src/sig/qruov/sig_qruov_1q127L10aes.c new file mode 100644 index 0000000000..5e5a730827 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q127L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes) +OQS_SIG *OQS_SIG_qruov_1q127L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q127L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q127L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q127L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q127L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_1q127L10aes_keypair; + sig->sign = OQS_SIG_qruov_1q127L10aes_sign; + sig->verify = OQS_SIG_qruov_1q127L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q127L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q127L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q127L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes_opt) +extern int qruov_1q127L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2) +extern int qruov_1q127L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes_opt) + return (OQS_STATUS) qruov_1q127L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes_opt) + return (OQS_STATUS) qruov_1q127L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10aes_opt) + return (OQS_STATUS) qruov_1q127L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q127L10shake.c b/src/sig/qruov/sig_qruov_1q127L10shake.c new file mode 100644 index 0000000000..5a5cd01623 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q127L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake) +OQS_SIG *OQS_SIG_qruov_1q127L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q127L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q127L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q127L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q127L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_1q127L10shake_keypair; + sig->sign = OQS_SIG_qruov_1q127L10shake_sign; + sig->verify = OQS_SIG_qruov_1q127L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q127L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q127L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q127L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake_opt) +extern int qruov_1q127L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2) +extern int qruov_1q127L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake_opt) + return (OQS_STATUS) qruov_1q127L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake_opt) + return (OQS_STATUS) qruov_1q127L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L10shake_opt) + return (OQS_STATUS) qruov_1q127L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q127L3aes.c b/src/sig/qruov/sig_qruov_1q127L3aes.c new file mode 100644 index 0000000000..d0cf3ad452 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q127L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes) +OQS_SIG *OQS_SIG_qruov_1q127L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q127L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q127L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q127L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q127L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_1q127L3aes_keypair; + sig->sign = OQS_SIG_qruov_1q127L3aes_sign; + sig->verify = OQS_SIG_qruov_1q127L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q127L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q127L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q127L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes_opt) +extern int qruov_1q127L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2) +extern int qruov_1q127L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes_opt) + return (OQS_STATUS) qruov_1q127L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes_opt) + return (OQS_STATUS) qruov_1q127L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3aes_opt) + return (OQS_STATUS) qruov_1q127L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q127L3shake.c b/src/sig/qruov/sig_qruov_1q127L3shake.c new file mode 100644 index 0000000000..1d39108d63 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q127L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake) +OQS_SIG *OQS_SIG_qruov_1q127L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q127L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q127L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q127L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q127L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_1q127L3shake_keypair; + sig->sign = OQS_SIG_qruov_1q127L3shake_sign; + sig->verify = OQS_SIG_qruov_1q127L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q127L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q127L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q127L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake_opt) +extern int qruov_1q127L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2) +extern int qruov_1q127L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q127L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q127L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake_opt) + return (OQS_STATUS) qruov_1q127L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake_opt) + return (OQS_STATUS) qruov_1q127L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q127L3shake_opt) + return (OQS_STATUS) qruov_1q127L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q127L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q127L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q31L10aes.c b/src/sig/qruov/sig_qruov_1q31L10aes.c new file mode 100644 index 0000000000..28b23df439 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q31L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes) +OQS_SIG *OQS_SIG_qruov_1q31L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q31L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q31L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q31L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q31L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_1q31L10aes_keypair; + sig->sign = OQS_SIG_qruov_1q31L10aes_sign; + sig->verify = OQS_SIG_qruov_1q31L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q31L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q31L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q31L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes_opt) +extern int qruov_1q31L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2) +extern int qruov_1q31L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes_opt) + return (OQS_STATUS) qruov_1q31L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes_opt) + return (OQS_STATUS) qruov_1q31L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10aes_opt) + return (OQS_STATUS) qruov_1q31L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q31L10shake.c b/src/sig/qruov/sig_qruov_1q31L10shake.c new file mode 100644 index 0000000000..b7ed261774 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q31L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake) +OQS_SIG *OQS_SIG_qruov_1q31L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q31L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q31L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q31L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q31L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_1q31L10shake_keypair; + sig->sign = OQS_SIG_qruov_1q31L10shake_sign; + sig->verify = OQS_SIG_qruov_1q31L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q31L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q31L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q31L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake_opt) +extern int qruov_1q31L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2) +extern int qruov_1q31L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake_opt) + return (OQS_STATUS) qruov_1q31L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake_opt) + return (OQS_STATUS) qruov_1q31L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L10shake_opt) + return (OQS_STATUS) qruov_1q31L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q31L3aes.c b/src/sig/qruov/sig_qruov_1q31L3aes.c new file mode 100644 index 0000000000..8d9cebebc3 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q31L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes) +OQS_SIG *OQS_SIG_qruov_1q31L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q31L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q31L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q31L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q31L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_1q31L3aes_keypair; + sig->sign = OQS_SIG_qruov_1q31L3aes_sign; + sig->verify = OQS_SIG_qruov_1q31L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q31L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q31L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q31L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes_opt) +extern int qruov_1q31L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2) +extern int qruov_1q31L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes_opt) + return (OQS_STATUS) qruov_1q31L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes_opt) + return (OQS_STATUS) qruov_1q31L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3aes_opt) + return (OQS_STATUS) qruov_1q31L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q31L3shake.c b/src/sig/qruov/sig_qruov_1q31L3shake.c new file mode 100644 index 0000000000..e870448506 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q31L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake) +OQS_SIG *OQS_SIG_qruov_1q31L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q31L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q31L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q31L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q31L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_1q31L3shake_keypair; + sig->sign = OQS_SIG_qruov_1q31L3shake_sign; + sig->verify = OQS_SIG_qruov_1q31L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q31L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q31L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q31L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake_opt) +extern int qruov_1q31L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2) +extern int qruov_1q31L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q31L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q31L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake_opt) + return (OQS_STATUS) qruov_1q31L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake_opt) + return (OQS_STATUS) qruov_1q31L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q31L3shake_opt) + return (OQS_STATUS) qruov_1q31L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q31L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q31L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q7L10aes.c b/src/sig/qruov/sig_qruov_1q7L10aes.c new file mode 100644 index 0000000000..9e53c16bbd --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q7L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes) +OQS_SIG *OQS_SIG_qruov_1q7L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q7L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q7L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q7L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q7L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_1q7L10aes_keypair; + sig->sign = OQS_SIG_qruov_1q7L10aes_sign; + sig->verify = OQS_SIG_qruov_1q7L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q7L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q7L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q7L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes_opt) +extern int qruov_1q7L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2) +extern int qruov_1q7L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes_opt) + return (OQS_STATUS) qruov_1q7L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes_opt) + return (OQS_STATUS) qruov_1q7L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10aes_opt) + return (OQS_STATUS) qruov_1q7L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q7L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q7L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_1q7L10shake.c b/src/sig/qruov/sig_qruov_1q7L10shake.c new file mode 100644 index 0000000000..72b8f4cbd1 --- /dev/null +++ b/src/sig/qruov/sig_qruov_1q7L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake) +OQS_SIG *OQS_SIG_qruov_1q7L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_1q7L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 1; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_1q7L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_1q7L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_1q7L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_1q7L10shake_keypair; + sig->sign = OQS_SIG_qruov_1q7L10shake_sign; + sig->verify = OQS_SIG_qruov_1q7L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_1q7L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_1q7L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_1q7L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake_opt) +extern int qruov_1q7L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2) +extern int qruov_1q7L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_1q7L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_1q7L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake_opt) + return (OQS_STATUS) qruov_1q7L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake_opt) + return (OQS_STATUS) qruov_1q7L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_1q7L10shake_opt) + return (OQS_STATUS) qruov_1q7L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_1q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_1q7L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_1q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q7L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_1q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_1q7L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q127L10aes.c b/src/sig/qruov/sig_qruov_3q127L10aes.c new file mode 100644 index 0000000000..d1ae5fac21 --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q127L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes) +OQS_SIG *OQS_SIG_qruov_3q127L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q127L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q127L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q127L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q127L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_3q127L10aes_keypair; + sig->sign = OQS_SIG_qruov_3q127L10aes_sign; + sig->verify = OQS_SIG_qruov_3q127L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q127L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q127L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q127L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes_opt) +extern int qruov_3q127L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2) +extern int qruov_3q127L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes_opt) + return (OQS_STATUS) qruov_3q127L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes_opt) + return (OQS_STATUS) qruov_3q127L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10aes_opt) + return (OQS_STATUS) qruov_3q127L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q127L10shake.c b/src/sig/qruov/sig_qruov_3q127L10shake.c new file mode 100644 index 0000000000..1b4883e54f --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q127L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake) +OQS_SIG *OQS_SIG_qruov_3q127L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q127L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q127L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q127L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q127L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_3q127L10shake_keypair; + sig->sign = OQS_SIG_qruov_3q127L10shake_sign; + sig->verify = OQS_SIG_qruov_3q127L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q127L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q127L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q127L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake_opt) +extern int qruov_3q127L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2) +extern int qruov_3q127L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake_opt) + return (OQS_STATUS) qruov_3q127L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake_opt) + return (OQS_STATUS) qruov_3q127L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L10shake_opt) + return (OQS_STATUS) qruov_3q127L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q127L3aes.c b/src/sig/qruov/sig_qruov_3q127L3aes.c new file mode 100644 index 0000000000..0302beafb0 --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q127L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes) +OQS_SIG *OQS_SIG_qruov_3q127L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q127L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q127L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q127L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q127L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_3q127L3aes_keypair; + sig->sign = OQS_SIG_qruov_3q127L3aes_sign; + sig->verify = OQS_SIG_qruov_3q127L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q127L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q127L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q127L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes_opt) +extern int qruov_3q127L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2) +extern int qruov_3q127L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes_opt) + return (OQS_STATUS) qruov_3q127L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes_opt) + return (OQS_STATUS) qruov_3q127L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3aes_opt) + return (OQS_STATUS) qruov_3q127L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q127L3shake.c b/src/sig/qruov/sig_qruov_3q127L3shake.c new file mode 100644 index 0000000000..ce5518298c --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q127L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake) +OQS_SIG *OQS_SIG_qruov_3q127L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q127L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q127L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q127L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q127L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_3q127L3shake_keypair; + sig->sign = OQS_SIG_qruov_3q127L3shake_sign; + sig->verify = OQS_SIG_qruov_3q127L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q127L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q127L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q127L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake_opt) +extern int qruov_3q127L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2) +extern int qruov_3q127L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q127L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q127L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake_opt) + return (OQS_STATUS) qruov_3q127L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake_opt) + return (OQS_STATUS) qruov_3q127L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q127L3shake_opt) + return (OQS_STATUS) qruov_3q127L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q127L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q127L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q31L10aes.c b/src/sig/qruov/sig_qruov_3q31L10aes.c new file mode 100644 index 0000000000..86474c8bdf --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q31L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes) +OQS_SIG *OQS_SIG_qruov_3q31L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q31L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q31L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q31L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q31L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_3q31L10aes_keypair; + sig->sign = OQS_SIG_qruov_3q31L10aes_sign; + sig->verify = OQS_SIG_qruov_3q31L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q31L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q31L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q31L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes_opt) +extern int qruov_3q31L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2) +extern int qruov_3q31L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes_opt) + return (OQS_STATUS) qruov_3q31L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes_opt) + return (OQS_STATUS) qruov_3q31L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10aes_opt) + return (OQS_STATUS) qruov_3q31L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q31L10shake.c b/src/sig/qruov/sig_qruov_3q31L10shake.c new file mode 100644 index 0000000000..625fc36ee6 --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q31L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake) +OQS_SIG *OQS_SIG_qruov_3q31L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q31L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q31L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q31L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q31L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_3q31L10shake_keypair; + sig->sign = OQS_SIG_qruov_3q31L10shake_sign; + sig->verify = OQS_SIG_qruov_3q31L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q31L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q31L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q31L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake_opt) +extern int qruov_3q31L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2) +extern int qruov_3q31L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake_opt) + return (OQS_STATUS) qruov_3q31L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake_opt) + return (OQS_STATUS) qruov_3q31L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L10shake_opt) + return (OQS_STATUS) qruov_3q31L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q31L3aes.c b/src/sig/qruov/sig_qruov_3q31L3aes.c new file mode 100644 index 0000000000..0ac35e3f7f --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q31L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes) +OQS_SIG *OQS_SIG_qruov_3q31L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q31L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q31L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q31L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q31L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_3q31L3aes_keypair; + sig->sign = OQS_SIG_qruov_3q31L3aes_sign; + sig->verify = OQS_SIG_qruov_3q31L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q31L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q31L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q31L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes_opt) +extern int qruov_3q31L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2) +extern int qruov_3q31L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes_opt) + return (OQS_STATUS) qruov_3q31L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes_opt) + return (OQS_STATUS) qruov_3q31L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3aes_opt) + return (OQS_STATUS) qruov_3q31L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q31L3shake.c b/src/sig/qruov/sig_qruov_3q31L3shake.c new file mode 100644 index 0000000000..9412a1867a --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q31L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake) +OQS_SIG *OQS_SIG_qruov_3q31L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q31L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q31L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q31L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q31L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_3q31L3shake_keypair; + sig->sign = OQS_SIG_qruov_3q31L3shake_sign; + sig->verify = OQS_SIG_qruov_3q31L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q31L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q31L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q31L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake_opt) +extern int qruov_3q31L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2) +extern int qruov_3q31L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q31L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q31L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake_opt) + return (OQS_STATUS) qruov_3q31L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake_opt) + return (OQS_STATUS) qruov_3q31L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q31L3shake_opt) + return (OQS_STATUS) qruov_3q31L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q31L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q31L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q7L10aes.c b/src/sig/qruov/sig_qruov_3q7L10aes.c new file mode 100644 index 0000000000..df13a0f20a --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q7L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes) +OQS_SIG *OQS_SIG_qruov_3q7L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q7L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q7L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q7L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q7L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_3q7L10aes_keypair; + sig->sign = OQS_SIG_qruov_3q7L10aes_sign; + sig->verify = OQS_SIG_qruov_3q7L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q7L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q7L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q7L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes_opt) +extern int qruov_3q7L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2) +extern int qruov_3q7L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes_opt) + return (OQS_STATUS) qruov_3q7L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes_opt) + return (OQS_STATUS) qruov_3q7L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10aes_opt) + return (OQS_STATUS) qruov_3q7L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q7L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q7L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_3q7L10shake.c b/src/sig/qruov/sig_qruov_3q7L10shake.c new file mode 100644 index 0000000000..1146f23e66 --- /dev/null +++ b/src/sig/qruov/sig_qruov_3q7L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake) +OQS_SIG *OQS_SIG_qruov_3q7L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_3q7L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 3; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_3q7L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_3q7L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_3q7L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_3q7L10shake_keypair; + sig->sign = OQS_SIG_qruov_3q7L10shake_sign; + sig->verify = OQS_SIG_qruov_3q7L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_3q7L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_3q7L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_3q7L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake_opt) +extern int qruov_3q7L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2) +extern int qruov_3q7L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_3q7L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_3q7L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake_opt) + return (OQS_STATUS) qruov_3q7L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake_opt) + return (OQS_STATUS) qruov_3q7L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_3q7L10shake_opt) + return (OQS_STATUS) qruov_3q7L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_3q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_3q7L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_3q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q7L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_3q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_3q7L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q127L10aes.c b/src/sig/qruov/sig_qruov_5q127L10aes.c new file mode 100644 index 0000000000..25f6db72b1 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q127L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes) +OQS_SIG *OQS_SIG_qruov_5q127L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q127L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q127L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q127L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q127L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_5q127L10aes_keypair; + sig->sign = OQS_SIG_qruov_5q127L10aes_sign; + sig->verify = OQS_SIG_qruov_5q127L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q127L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q127L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q127L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes_opt) +extern int qruov_5q127L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2) +extern int qruov_5q127L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes_opt) + return (OQS_STATUS) qruov_5q127L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes_opt) + return (OQS_STATUS) qruov_5q127L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10aes_opt) + return (OQS_STATUS) qruov_5q127L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q127L10shake.c b/src/sig/qruov/sig_qruov_5q127L10shake.c new file mode 100644 index 0000000000..6b2d6b0b35 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q127L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake) +OQS_SIG *OQS_SIG_qruov_5q127L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q127L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q127L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q127L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q127L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_5q127L10shake_keypair; + sig->sign = OQS_SIG_qruov_5q127L10shake_sign; + sig->verify = OQS_SIG_qruov_5q127L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q127L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q127L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q127L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake_opt) +extern int qruov_5q127L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2) +extern int qruov_5q127L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake_opt) + return (OQS_STATUS) qruov_5q127L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake_opt) + return (OQS_STATUS) qruov_5q127L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L10shake_opt) + return (OQS_STATUS) qruov_5q127L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q127L3aes.c b/src/sig/qruov/sig_qruov_5q127L3aes.c new file mode 100644 index 0000000000..0b4d8f4f22 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q127L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes) +OQS_SIG *OQS_SIG_qruov_5q127L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q127L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q127L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q127L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q127L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_5q127L3aes_keypair; + sig->sign = OQS_SIG_qruov_5q127L3aes_sign; + sig->verify = OQS_SIG_qruov_5q127L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q127L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q127L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q127L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes_opt) +extern int qruov_5q127L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2) +extern int qruov_5q127L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes_opt) + return (OQS_STATUS) qruov_5q127L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes_opt) + return (OQS_STATUS) qruov_5q127L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3aes_opt) + return (OQS_STATUS) qruov_5q127L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q127L3shake.c b/src/sig/qruov/sig_qruov_5q127L3shake.c new file mode 100644 index 0000000000..e214515023 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q127L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake) +OQS_SIG *OQS_SIG_qruov_5q127L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q127L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q127L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q127L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q127L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_5q127L3shake_keypair; + sig->sign = OQS_SIG_qruov_5q127L3shake_sign; + sig->verify = OQS_SIG_qruov_5q127L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q127L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q127L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q127L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake_opt) +extern int qruov_5q127L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2) +extern int qruov_5q127L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q127L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q127L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake_opt) + return (OQS_STATUS) qruov_5q127L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake_opt) + return (OQS_STATUS) qruov_5q127L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q127L3shake_opt) + return (OQS_STATUS) qruov_5q127L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q127L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q127L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q127L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q127L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q127L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q31L10aes.c b/src/sig/qruov/sig_qruov_5q31L10aes.c new file mode 100644 index 0000000000..d04f0effa0 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q31L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes) +OQS_SIG *OQS_SIG_qruov_5q31L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q31L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q31L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q31L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q31L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_5q31L10aes_keypair; + sig->sign = OQS_SIG_qruov_5q31L10aes_sign; + sig->verify = OQS_SIG_qruov_5q31L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q31L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q31L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q31L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes_opt) +extern int qruov_5q31L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2) +extern int qruov_5q31L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes_opt) + return (OQS_STATUS) qruov_5q31L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes_opt) + return (OQS_STATUS) qruov_5q31L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10aes_opt) + return (OQS_STATUS) qruov_5q31L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q31L10shake.c b/src/sig/qruov/sig_qruov_5q31L10shake.c new file mode 100644 index 0000000000..96dea00019 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q31L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake) +OQS_SIG *OQS_SIG_qruov_5q31L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q31L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q31L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q31L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q31L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_5q31L10shake_keypair; + sig->sign = OQS_SIG_qruov_5q31L10shake_sign; + sig->verify = OQS_SIG_qruov_5q31L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q31L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q31L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q31L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake_opt) +extern int qruov_5q31L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2) +extern int qruov_5q31L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake_opt) + return (OQS_STATUS) qruov_5q31L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake_opt) + return (OQS_STATUS) qruov_5q31L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L10shake_opt) + return (OQS_STATUS) qruov_5q31L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q31L3aes.c b/src/sig/qruov/sig_qruov_5q31L3aes.c new file mode 100644 index 0000000000..a963e9b6bd --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q31L3aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes) +OQS_SIG *OQS_SIG_qruov_5q31L3aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q31L3aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q31L3aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q31L3aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q31L3aes_length_signature; + + sig->keypair = OQS_SIG_qruov_5q31L3aes_keypair; + sig->sign = OQS_SIG_qruov_5q31L3aes_sign; + sig->verify = OQS_SIG_qruov_5q31L3aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q31L3aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q31L3aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q31L3_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes_opt) +extern int qruov_5q31L3_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2) +extern int qruov_5q31L3_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes_opt) + return (OQS_STATUS) qruov_5q31L3_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes_opt) + return (OQS_STATUS) qruov_5q31L3_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3aes_opt) + return (OQS_STATUS) qruov_5q31L3_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L3aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L3aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q31L3shake.c b/src/sig/qruov/sig_qruov_5q31L3shake.c new file mode 100644 index 0000000000..3e0209610d --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q31L3shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake) +OQS_SIG *OQS_SIG_qruov_5q31L3shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q31L3shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q31L3shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q31L3shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q31L3shake_length_signature; + + sig->keypair = OQS_SIG_qruov_5q31L3shake_keypair; + sig->sign = OQS_SIG_qruov_5q31L3shake_sign; + sig->verify = OQS_SIG_qruov_5q31L3shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q31L3shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q31L3shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q31L3_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake_opt) +extern int qruov_5q31L3_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2) +extern int qruov_5q31L3_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q31L3_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q31L3_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake_opt) + return (OQS_STATUS) qruov_5q31L3_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake_opt) + return (OQS_STATUS) qruov_5q31L3_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q31L3shake_opt) + return (OQS_STATUS) qruov_5q31L3_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q31L3shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q31L3_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q31L3_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L3shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q31L3shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q31L3shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q7L10aes.c b/src/sig/qruov/sig_qruov_5q7L10aes.c new file mode 100644 index 0000000000..9ea9b26c26 --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q7L10aes.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes) +OQS_SIG *OQS_SIG_qruov_5q7L10aes_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q7L10aes; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q7L10aes_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q7L10aes_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q7L10aes_length_signature; + + sig->keypair = OQS_SIG_qruov_5q7L10aes_keypair; + sig->sign = OQS_SIG_qruov_5q7L10aes_sign; + sig->verify = OQS_SIG_qruov_5q7L10aes_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q7L10aes_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q7L10aes_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q7L10_aes_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_aes_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_aes_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes_opt) +extern int qruov_5q7L10_aes_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_aes_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_aes_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2) +extern int qruov_5q7L10_aes_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_aes_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_aes_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes_opt) + return (OQS_STATUS) qruov_5q7L10_aes_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_aes_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes_opt) + return (OQS_STATUS) qruov_5q7L10_aes_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_aes_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10aes_opt) + return (OQS_STATUS) qruov_5q7L10_aes_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10aes_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_aes_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_aes_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q7L10aes_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10aes_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q7L10aes_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/qruov/sig_qruov_5q7L10shake.c b/src/sig/qruov/sig_qruov_5q7L10shake.c new file mode 100644 index 0000000000..3c05dc79be --- /dev/null +++ b/src/sig/qruov/sig_qruov_5q7L10shake.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT + +#include + +#include + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake) +OQS_SIG *OQS_SIG_qruov_5q7L10shake_new(void) { + + OQS_SIG *sig = OQS_MEM_calloc(1, sizeof(OQS_SIG)); + if (sig == NULL) { + return NULL; + } + sig->method_name = OQS_SIG_alg_qruov_5q7L10shake; + sig->alg_version = "Round 3"; + + sig->claimed_nist_level = 5; + sig->euf_cma = true; + sig->suf_cma = false; + sig->sig_with_ctx_support = false; + + sig->length_public_key = OQS_SIG_qruov_5q7L10shake_length_public_key; + sig->length_secret_key = OQS_SIG_qruov_5q7L10shake_length_secret_key; + sig->length_signature = OQS_SIG_qruov_5q7L10shake_length_signature; + + sig->keypair = OQS_SIG_qruov_5q7L10shake_keypair; + sig->sign = OQS_SIG_qruov_5q7L10shake_sign; + sig->verify = OQS_SIG_qruov_5q7L10shake_verify; + sig->sign_with_ctx_str = OQS_SIG_qruov_5q7L10shake_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_qruov_5q7L10shake_verify_with_ctx_str; + + return sig; +} + +extern int qruov_5q7L10_shake_ref_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_shake_ref_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_shake_ref_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake_opt) +extern int qruov_5q7L10_shake_opt_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_shake_opt_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_shake_opt_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2) +extern int qruov_5q7L10_shake_avx2_crypto_sign_keypair(uint8_t *pk, uint8_t *sk); +extern int qruov_5q7L10_shake_avx2_crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); +extern int qruov_5q7L10_shake_avx2_crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); +#endif + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake_opt) + return (OQS_STATUS) qruov_5q7L10_shake_opt_crypto_sign_keypair(public_key, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_shake_avx2_crypto_sign_keypair(public_key, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_keypair(public_key, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake_opt) + return (OQS_STATUS) qruov_5q7L10_shake_opt_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_shake_avx2_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_signature(signature, signature_len, message, message_len, secret_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_qruov_5q7L10shake_opt) + return (OQS_STATUS) qruov_5q7L10_shake_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#elif defined(OQS_ENABLE_SIG_qruov_5q7L10shake_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_BMI2) && OQS_CPU_has_extension(OQS_CPU_EXT_AES)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) qruov_5q7L10_shake_avx2_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) qruov_5q7L10_shake_ref_crypto_sign_verify(signature, signature_len, message, message_len, public_key); +#endif +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q7L10shake_sign(signature, signature_len, message, message_len, secret_key); + } else { + return OQS_ERROR; + } +} + +OQS_API OQS_STATUS OQS_SIG_qruov_5q7L10shake_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (ctx_str == NULL && ctx_str_len == 0) { + return OQS_SIG_qruov_5q7L10shake_verify(message, message_len, signature, signature_len, public_key); + } else { + return OQS_ERROR; + } +} +#endif diff --git a/src/sig/sig.c b/src/sig/sig.c index 7113f81274..2d8bcb30ce 100644 --- a/src/sig/sig.c +++ b/src/sig/sig.c @@ -47,6 +47,36 @@ OQS_API const char *OQS_SIG_alg_identifier(size_t i) { OQS_SIG_alg_cross_rsdpg_256_balanced, OQS_SIG_alg_cross_rsdpg_256_fast, OQS_SIG_alg_cross_rsdpg_256_small, + OQS_SIG_alg_qruov_1q7L10aes, + OQS_SIG_alg_qruov_1q7L10shake, + OQS_SIG_alg_qruov_1q31L3aes, + OQS_SIG_alg_qruov_1q31L3shake, + OQS_SIG_alg_qruov_1q31L10aes, + OQS_SIG_alg_qruov_1q31L10shake, + OQS_SIG_alg_qruov_1q127L3aes, + OQS_SIG_alg_qruov_1q127L3shake, + OQS_SIG_alg_qruov_1q127L10aes, + OQS_SIG_alg_qruov_1q127L10shake, + OQS_SIG_alg_qruov_3q7L10aes, + OQS_SIG_alg_qruov_3q7L10shake, + OQS_SIG_alg_qruov_3q31L3aes, + OQS_SIG_alg_qruov_3q31L3shake, + OQS_SIG_alg_qruov_3q31L10aes, + OQS_SIG_alg_qruov_3q31L10shake, + OQS_SIG_alg_qruov_3q127L3aes, + OQS_SIG_alg_qruov_3q127L3shake, + OQS_SIG_alg_qruov_3q127L10aes, + OQS_SIG_alg_qruov_3q127L10shake, + OQS_SIG_alg_qruov_5q7L10aes, + OQS_SIG_alg_qruov_5q7L10shake, + OQS_SIG_alg_qruov_5q31L3aes, + OQS_SIG_alg_qruov_5q31L3shake, + OQS_SIG_alg_qruov_5q31L10aes, + OQS_SIG_alg_qruov_5q31L10shake, + OQS_SIG_alg_qruov_5q127L3aes, + OQS_SIG_alg_qruov_5q127L3shake, + OQS_SIG_alg_qruov_5q127L10aes, + OQS_SIG_alg_qruov_5q127L10shake, OQS_SIG_alg_uov_ov_Is, OQS_SIG_alg_uov_ov_Ip, OQS_SIG_alg_uov_ov_III, @@ -495,6 +525,216 @@ OQS_API int OQS_SIG_alg_is_enabled(const char *method_name) { return 0; #endif + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q7L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q7L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q7L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q7L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q7L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q7L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L10shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L3aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L3shake + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L10aes + return 1; +#else + return 0; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L10shake + return 1; +#else + return 0; +#endif + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_uov_ov_Is)) { #ifdef OQS_ENABLE_SIG_uov_ov_Is return 1; @@ -2004,6 +2244,216 @@ OQS_API OQS_SIG *OQS_SIG_new(const char *method_name) { return NULL; #endif + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q7L10aes + return OQS_SIG_qruov_1q7L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q7L10shake + return OQS_SIG_qruov_1q7L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L3aes + return OQS_SIG_qruov_1q31L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L3shake + return OQS_SIG_qruov_1q31L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L10aes + return OQS_SIG_qruov_1q31L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q31L10shake + return OQS_SIG_qruov_1q31L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L3aes + return OQS_SIG_qruov_1q127L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L3shake + return OQS_SIG_qruov_1q127L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L10aes + return OQS_SIG_qruov_1q127L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_1q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_1q127L10shake + return OQS_SIG_qruov_1q127L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q7L10aes + return OQS_SIG_qruov_3q7L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q7L10shake + return OQS_SIG_qruov_3q7L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L3aes + return OQS_SIG_qruov_3q31L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L3shake + return OQS_SIG_qruov_3q31L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L10aes + return OQS_SIG_qruov_3q31L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q31L10shake + return OQS_SIG_qruov_3q31L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L3aes + return OQS_SIG_qruov_3q127L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L3shake + return OQS_SIG_qruov_3q127L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L10aes + return OQS_SIG_qruov_3q127L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_3q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_3q127L10shake + return OQS_SIG_qruov_3q127L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q7L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q7L10aes + return OQS_SIG_qruov_5q7L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q7L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q7L10shake + return OQS_SIG_qruov_5q7L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L3aes + return OQS_SIG_qruov_5q31L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L3shake + return OQS_SIG_qruov_5q31L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L10aes + return OQS_SIG_qruov_5q31L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q31L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q31L10shake + return OQS_SIG_qruov_5q31L10shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L3aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L3aes + return OQS_SIG_qruov_5q127L3aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L3shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L3shake + return OQS_SIG_qruov_5q127L3shake_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L10aes)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L10aes + return OQS_SIG_qruov_5q127L10aes_new(); +#else + return NULL; +#endif + + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_qruov_5q127L10shake)) { +#ifdef OQS_ENABLE_SIG_qruov_5q127L10shake + return OQS_SIG_qruov_5q127L10shake_new(); +#else + return NULL; +#endif + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_uov_ov_Is)) { #ifdef OQS_ENABLE_SIG_uov_ov_Is return OQS_SIG_uov_ov_Is_new(); diff --git a/src/sig/sig.h b/src/sig/sig.h index 327c0f2fd9..8aec30bc8c 100644 --- a/src/sig/sig.h +++ b/src/sig/sig.h @@ -96,6 +96,66 @@ extern "C" { #define OQS_SIG_alg_cross_rsdpg_256_fast "cross-rsdpg-256-fast" /** Algorithm identifier for cross-rsdpg-256-small */ #define OQS_SIG_alg_cross_rsdpg_256_small "cross-rsdpg-256-small" +/** Algorithm identifier for QRUOV-1q7L10-aes */ +#define OQS_SIG_alg_qruov_1q7L10aes "QRUOV-1q7L10-aes" +/** Algorithm identifier for QRUOV-1q7L10-shake */ +#define OQS_SIG_alg_qruov_1q7L10shake "QRUOV-1q7L10-shake" +/** Algorithm identifier for QRUOV-1q31L3-aes */ +#define OQS_SIG_alg_qruov_1q31L3aes "QRUOV-1q31L3-aes" +/** Algorithm identifier for QRUOV-1q31L3-shake */ +#define OQS_SIG_alg_qruov_1q31L3shake "QRUOV-1q31L3-shake" +/** Algorithm identifier for QRUOV-1q31L10-aes */ +#define OQS_SIG_alg_qruov_1q31L10aes "QRUOV-1q31L10-aes" +/** Algorithm identifier for QRUOV-1q31L10-shake */ +#define OQS_SIG_alg_qruov_1q31L10shake "QRUOV-1q31L10-shake" +/** Algorithm identifier for QRUOV-1q127L3-aes */ +#define OQS_SIG_alg_qruov_1q127L3aes "QRUOV-1q127L3-aes" +/** Algorithm identifier for QRUOV-1q127L3-shake */ +#define OQS_SIG_alg_qruov_1q127L3shake "QRUOV-1q127L3-shake" +/** Algorithm identifier for QRUOV-1q127L10-aes */ +#define OQS_SIG_alg_qruov_1q127L10aes "QRUOV-1q127L10-aes" +/** Algorithm identifier for QRUOV-1q127L10-shake */ +#define OQS_SIG_alg_qruov_1q127L10shake "QRUOV-1q127L10-shake" +/** Algorithm identifier for QRUOV-3q7L10-aes */ +#define OQS_SIG_alg_qruov_3q7L10aes "QRUOV-3q7L10-aes" +/** Algorithm identifier for QRUOV-3q7L10-shake */ +#define OQS_SIG_alg_qruov_3q7L10shake "QRUOV-3q7L10-shake" +/** Algorithm identifier for QRUOV-3q31L3-aes */ +#define OQS_SIG_alg_qruov_3q31L3aes "QRUOV-3q31L3-aes" +/** Algorithm identifier for QRUOV-3q31L3-shake */ +#define OQS_SIG_alg_qruov_3q31L3shake "QRUOV-3q31L3-shake" +/** Algorithm identifier for QRUOV-3q31L10-aes */ +#define OQS_SIG_alg_qruov_3q31L10aes "QRUOV-3q31L10-aes" +/** Algorithm identifier for QRUOV-3q31L10-shake */ +#define OQS_SIG_alg_qruov_3q31L10shake "QRUOV-3q31L10-shake" +/** Algorithm identifier for QRUOV-3q127L3-aes */ +#define OQS_SIG_alg_qruov_3q127L3aes "QRUOV-3q127L3-aes" +/** Algorithm identifier for QRUOV-3q127L3-shake */ +#define OQS_SIG_alg_qruov_3q127L3shake "QRUOV-3q127L3-shake" +/** Algorithm identifier for QRUOV-3q127L10-aes */ +#define OQS_SIG_alg_qruov_3q127L10aes "QRUOV-3q127L10-aes" +/** Algorithm identifier for QRUOV-3q127L10-shake */ +#define OQS_SIG_alg_qruov_3q127L10shake "QRUOV-3q127L10-shake" +/** Algorithm identifier for QRUOV-5q7L10-aes */ +#define OQS_SIG_alg_qruov_5q7L10aes "QRUOV-5q7L10-aes" +/** Algorithm identifier for QRUOV-5q7L10-shake */ +#define OQS_SIG_alg_qruov_5q7L10shake "QRUOV-5q7L10-shake" +/** Algorithm identifier for QRUOV-5q31L3-aes */ +#define OQS_SIG_alg_qruov_5q31L3aes "QRUOV-5q31L3-aes" +/** Algorithm identifier for QRUOV-5q31L3-shake */ +#define OQS_SIG_alg_qruov_5q31L3shake "QRUOV-5q31L3-shake" +/** Algorithm identifier for QRUOV-5q31L10-aes */ +#define OQS_SIG_alg_qruov_5q31L10aes "QRUOV-5q31L10-aes" +/** Algorithm identifier for QRUOV-5q31L10-shake */ +#define OQS_SIG_alg_qruov_5q31L10shake "QRUOV-5q31L10-shake" +/** Algorithm identifier for QRUOV-5q127L3-aes */ +#define OQS_SIG_alg_qruov_5q127L3aes "QRUOV-5q127L3-aes" +/** Algorithm identifier for QRUOV-5q127L3-shake */ +#define OQS_SIG_alg_qruov_5q127L3shake "QRUOV-5q127L3-shake" +/** Algorithm identifier for QRUOV-5q127L10-aes */ +#define OQS_SIG_alg_qruov_5q127L10aes "QRUOV-5q127L10-aes" +/** Algorithm identifier for QRUOV-5q127L10-shake */ +#define OQS_SIG_alg_qruov_5q127L10shake "QRUOV-5q127L10-shake" /** Algorithm identifier for OV-Is */ #define OQS_SIG_alg_uov_ov_Is "OV-Is" /** Algorithm identifier for OV-Ip */ @@ -516,7 +576,7 @@ extern "C" { ///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALGS_LENGTH_START /** Number of algorithm identifiers above. */ -#define OQS_SIG_algs_length 80 + OQS_SIG_SLH_DSA_algs_length +#define OQS_SIG_algs_length 110 + OQS_SIG_SLH_DSA_algs_length ///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALGS_LENGTH_END /** @@ -776,6 +836,9 @@ OQS_API bool OQS_SIG_supports_ctx_str(const char *alg_name); #ifdef OQS_ENABLE_SIG_CROSS #include #endif /* OQS_ENABLE_SIG_CROSS */ +#ifdef OQS_ENABLE_SIG_QRUOV +#include +#endif /* OQS_ENABLE_SIG_QRUOV */ #ifdef OQS_ENABLE_SIG_UOV #include #endif /* OQS_ENABLE_SIG_UOV */ diff --git a/tests/KATs/sig/kats.json b/tests/KATs/sig/kats.json index 2f5142f188..2df1447f32 100644 --- a/tests/KATs/sig/kats.json +++ b/tests/KATs/sig/kats.json @@ -91,6 +91,126 @@ "all": "31aebc803483ef47be9e0249e9105a08a8f1660bf0d6eca5051221fc04477e05", "single": "38c8e18ffe94cdc331294cb05b0e28b8b0cc7903db5331cee4c88cb84e61450a" }, + "QRUOV-1q127L10-aes": { + "all": "362e942e6785fc1022728e4e139ffd4faec1b208ecd9a35ad9085c05a02b2eee", + "single": "5c52fd986f4707d79962955558823e7814dc155f4d770db35f008a321389d13f" + }, + "QRUOV-1q127L10-shake": { + "all": "7e1edfc9b3753413b8ecfef792e1dcf0d65c59c044091b1cabfd7f374bddcc6f", + "single": "d3cbec7d9dbf2dcbbe6d596fb8d6d4e5a40a23eb59fc9e298fca9c5a551fcbf7" + }, + "QRUOV-1q127L3-aes": { + "all": "7dac7e48ef68fbed6868090fe4ed78744a3e338d4eef2777af95df7f519da260", + "single": "d4ca715e0176de76d477e069559c873b964e2b08b505eca652d60342b2f6ec23" + }, + "QRUOV-1q127L3-shake": { + "all": "30fd0cfa97d00bbcc95c0f716474f8c1b3cd0cfac52063a0c807fe1545f8ec89", + "single": "568404eb31f7e61aea6930c402ec8258127df835dbb291d941ed5aa0fb485963" + }, + "QRUOV-1q31L10-aes": { + "all": "4d2b42deb99fd9dcb029813be5054e2ac8461912ba04f82b87dd9039044f0a27", + "single": "74c24984bd9d8120ded9c671c1b28b39fc73306b2f1825e171ea0c018bd93a1d" + }, + "QRUOV-1q31L10-shake": { + "all": "6fb30ce650a1c3ffe10983cbe043449af34d495a9bfe7524dc7423045d7073f8", + "single": "a8624aaf02565ef7a51bc5488d71d395ee6aad1fce9e634a051cc3a9fb700a2c" + }, + "QRUOV-1q31L3-aes": { + "all": "16835618131c0626e2fadda724d4bf6c28940e73252f8acc25d55094c7eaf88d", + "single": "e84219beba200af1fb0b63e2217e891a62abf6f27d6d3a0262b532b6d31058c1" + }, + "QRUOV-1q31L3-shake": { + "all": "28eac9b8f12cf0f95637fd4e7aec557eaa05501ec07326270af946a21d9c3ce4", + "single": "6fbaae9a77a09a709b5e9931f46f3a6aa10c1006d3dd3c96b26949d28f9f26a5" + }, + "QRUOV-1q7L10-aes": { + "all": "bbb52628070b8cbbabbc750766e287726941321bc34eb6c8a1098e0726a8a2ac", + "single": "e1d8d09223f527c8e26f65e81f7226c3d6798149fb14b6c84cde22756f1d51e7" + }, + "QRUOV-1q7L10-shake": { + "all": "515f60ed1bcc5a3a7bd5b302bde090d3aa13b1c0ba4d9893ea017a64b8307673", + "single": "e92d582bb4940745e8f828c8ae52325f25978d4fcc77ea59d4ffde7756999902" + }, + "QRUOV-3q127L10-aes": { + "all": "20af8880ea03361f85d210c5fc602d642f19f4b51f73a80a0de1a3151147280f", + "single": "baf668a5a8312960cdb9720af9e73c822cd0dc8aa5f45491d06919149bcf2ca7" + }, + "QRUOV-3q127L10-shake": { + "all": "44e2317d8eb17dc487773886281156c9d94ef6c354024d8f7ec3e94805f93e64", + "single": "597c96418f16c23af7d4ff4ec131f911308e83444b43747f2aa6e69ef7e70274" + }, + "QRUOV-3q127L3-aes": { + "all": "f52666ff168a85cd1f2711ac67c32d624b228a836320046ce7f723fc3f953d10", + "single": "0fb1d48025001ce9f0cd3265c193f9878220bcf914ad99d9fe65dc31135c104f" + }, + "QRUOV-3q127L3-shake": { + "all": "537eadd104ba1894092512b479bb290d35877be9f21990cee9b289b0b2b7354d", + "single": "a216627d7c48f1143f03b84d4a8e716e5bbd7dcc29f3c56932c091e8cebe9fb9" + }, + "QRUOV-3q31L10-aes": { + "all": "11d92462834c0f77fb3265d6a2291ea0d1f11173e055b6409575f8b5d31fb01c", + "single": "a9eff2041a9b0ab920673bc4ab7810ed4b8902cbf157dacf75590d7f15dcbdfd" + }, + "QRUOV-3q31L10-shake": { + "all": "f0d5b738787e9cb41bea03e7c45ecd21a35764cf67e5325beaac0397647ed11c", + "single": "ca3d64136457b5ec8e3c2a9167a929c2c97bce0ce7468dac6eac7f78dcb472d6" + }, + "QRUOV-3q31L3-aes": { + "all": "9f0c9341b87dfb12ab46cce13b6ea10860d1ca0e496a5da6e7fa508aed39d638", + "single": "78ab615e2565acfebc476e3974525fe423c9d64f3ab0da7495f4042a81a4ebe8" + }, + "QRUOV-3q31L3-shake": { + "all": "891584468fc15acedd7fce2a9bf3b0bfc310c93fba26e1adf0bbf2d8e1c30495", + "single": "fdc0bbb786585c998c0f02eb5c997a0b8917e6e6431efdc5d1ee8d7e1c7f4291" + }, + "QRUOV-3q7L10-aes": { + "all": "7590a131da5b88cb90215555ba8ff07a7a43fb1385dc6c0e97a8a89c66b629c8", + "single": "5f7e69168531400dd4dc7481f80f072bca72ab73e468d6fe11ff73f1e65e658c" + }, + "QRUOV-3q7L10-shake": { + "all": "20a6c533ba467efc486d61f508a7ed6bbced1c01d662941a988b0d0c05762e6e", + "single": "c980003a6565216fc145aaaf6ae12b3f4e0d7867fc7475bbebc1c3bdbc1268f2" + }, + "QRUOV-5q127L10-aes": { + "all": "52bb279bc3837c4f29fad7cafa4ed825055cc82652d2a72b94138403fb7d7353", + "single": "eaa0d8c32a8d625f8fff87038c76d0fbcffefd2815cf330244375eb8a0f58550" + }, + "QRUOV-5q127L10-shake": { + "all": "9d6ddb46361c8d459c242c6497ab7b64cff378387690195eacc33c759f1a0e59", + "single": "76b68325d1d104612becedb94b9c88629640d2d9ff466f3378513d0b838dcb53" + }, + "QRUOV-5q127L3-aes": { + "all": "bb31c2f1d570fb16c98d61ea8c1e5301e2e66ecdacf29fa3f1f971780616fc4b", + "single": "d2d160bbb6f0f9402ccf284b4a020c03bdc552d1d476e6dd442eb5dd971a7482" + }, + "QRUOV-5q127L3-shake": { + "all": "7433f6bf241f3f8ec6b213dd836b132d074e79a9d4c4504ca2bdcd89c319be62", + "single": "250bfcf69ece8b45ea78db78226288ed2aeba85a7fd9b7a72c3865f744045060" + }, + "QRUOV-5q31L10-aes": { + "all": "fc6271eb47c61f39fd1fcede11cde96d40afe95e22ec9a780cbbd6837f2c99d5", + "single": "12927998b2455092877955800c448e6c364ba993b8c99813543f261a466c7167" + }, + "QRUOV-5q31L10-shake": { + "all": "07cd0afcb350f7fa668ebe04cf338d9ebf8b642ae192dfe1081ce6e63b92a756", + "single": "c956526b7672cb7efc8c6038b9b6085c2de187aaa9269167ca60bf75bf0ee07f" + }, + "QRUOV-5q31L3-aes": { + "all": "b3f185272630aa7e5b873ec7302261adea84d2abc0784035b17ae37423e810a3", + "single": "390662fd5fa14ac7951491a45ff2c226c9e5299112d7b3d6ce7640616e61f6bd" + }, + "QRUOV-5q31L3-shake": { + "all": "92a68015c95059d2b3f5b5da97f8425c6fb50a69b99c9c421b11e90dcba74adb", + "single": "7be273ec6555a551f28b472868fcd821bd85b2325659c26fb66355b33626f31a" + }, + "QRUOV-5q7L10-aes": { + "all": "7b304ac5a9a88ff055b9f2eb0ac7f20f0b7e06420f1d70e5d87dda9f1657d542", + "single": "ac5c6d0f26d4a9320ef2c2806c8ea763623ea3a6f66dbf334d2b1512ff686982" + }, + "QRUOV-5q7L10-shake": { + "all": "97f422568fc3e0f468930f23c82fd89e3822c3b421096db1aeb9b46208ee8448", + "single": "4d23b0b9cb780a2ccbd7c6558b3fc51c3b7ccb9df4c867e36d455524399dc0e7" + }, "SNOVA_III_B": { "all": "e8d7d7facc29e50333a88bb34b027c502b3ac4fd26ac6dbd5d95712bdb8d9d91", "single": "7175ce45fbd3e6b7eca08de8df339a8bb24116531478d1afa2f1e8cf7e59ace9" diff --git a/tests/constant_time/sig/issues.json b/tests/constant_time/sig/issues.json index b28a2c106a..bf749d7f72 100644 --- a/tests/constant_time/sig/issues.json +++ b/tests/constant_time/sig/issues.json @@ -183,5 +183,35 @@ "SLH_DSA_SHAKE_256_PREHASH_SHAKE_192S": ["slh_dsa"], "SLH_DSA_SHAKE_256_PREHASH_SHAKE_192F": ["slh_dsa"], "SLH_DSA_SHAKE_256_PREHASH_SHAKE_256S": ["slh_dsa"], - "SLH_DSA_SHAKE_256_PREHASH_SHAKE_256F": ["slh_dsa"] + "SLH_DSA_SHAKE_256_PREHASH_SHAKE_256F": ["slh_dsa"], + "QRUOV-1q127L10-aes": ["qruov"], + "QRUOV-1q127L10-shake": ["qruov"], + "QRUOV-1q127L3-aes": ["qruov"], + "QRUOV-1q127L3-shake": ["qruov"], + "QRUOV-1q31L10-aes": ["qruov"], + "QRUOV-1q31L10-shake": ["qruov"], + "QRUOV-1q31L3-aes": ["qruov"], + "QRUOV-1q31L3-shake": ["qruov"], + "QRUOV-1q7L10-aes": ["qruov"], + "QRUOV-1q7L10-shake": ["qruov"], + "QRUOV-3q127L10-aes": ["qruov"], + "QRUOV-3q127L10-shake": ["qruov"], + "QRUOV-3q127L3-aes": ["qruov"], + "QRUOV-3q127L3-shake": ["qruov"], + "QRUOV-3q31L10-aes": ["qruov"], + "QRUOV-3q31L10-shake": ["qruov"], + "QRUOV-3q31L3-aes": ["qruov"], + "QRUOV-3q31L3-shake": ["qruov"], + "QRUOV-3q7L10-aes": ["qruov"], + "QRUOV-3q7L10-shake": ["qruov"], + "QRUOV-5q127L10-aes": ["qruov"], + "QRUOV-5q127L10-shake": ["qruov"], + "QRUOV-5q127L3-aes": ["qruov"], + "QRUOV-5q127L3-shake": ["qruov"], + "QRUOV-5q31L10-aes": ["qruov"], + "QRUOV-5q31L10-shake": ["qruov"], + "QRUOV-5q31L3-aes": ["qruov"], + "QRUOV-5q31L3-shake": ["qruov"], + "QRUOV-5q7L10-aes": ["qruov"], + "QRUOV-5q7L10-shake": ["qruov"] } diff --git a/tests/constant_time/sig/issues/qruov b/tests/constant_time/sig/issues/qruov new file mode 100644 index 0000000000..e1e8103522 --- /dev/null +++ b/tests/constant_time/sig/issues/qruov @@ -0,0 +1,42 @@ +# Valgrind suppression file for QR-UOV (all parameter sets, ref implementation). +# QR-UOV does not claim constant-time signing (see docs/algorithms/sig/qruov.yml, +# no-secret-dependent-branching-claimed: false). These are the secret-dependent +# operations that valgrind reports, recorded so they are tracked rather than +# silenced. + +# The pivot search branches on the zero pattern of a matrix derived from the +# secret key, which leaks pivot positions and rank. +{ + Pivot search in the LU decomposition of a secret-derived matrix + Memcheck:Cond + src:linsys.c:38 +} + +# A cache-timing channel, although the table is small (q bytes). +{ + Field inversion by table lookup indexed by a secret-derived pivot + Memcheck:Value8 + src:gf.h:53 +} + +# The branch is on the signature vector s, which is published in canonical +# form, but whether it was negated reveals one bit about the value computed +# before canonicalisation. Believed harmless; recorded here rather than in +# passes until that is confirmed. +{ + Canonicalisation of the signature vector s + Memcheck:Cond + src:qruov_common.c:22 +} + +{ + Canonicalisation of the signature vector s + Memcheck:Cond + src:qruov_common.c:31 +} + +{ + Canonicalisation of the signature vector s + Memcheck:Cond + src:qruov_common.c:33 +} diff --git a/tests/constant_time/sig/passes.json b/tests/constant_time/sig/passes.json index 94e38d58e2..db9ea4c171 100644 --- a/tests/constant_time/sig/passes.json +++ b/tests/constant_time/sig/passes.json @@ -155,5 +155,35 @@ "SNOVA_V_B": ["snova"], "SNOVA_V_B_AES": ["snova"], "SNOVA_V_S": ["snova"], - "SNOVA_V_S_AES": ["snova"] + "SNOVA_V_S_AES": ["snova"], + "QRUOV-1q127L10-aes": ["qruov"], + "QRUOV-1q127L10-shake": ["qruov"], + "QRUOV-1q127L3-aes": ["qruov"], + "QRUOV-1q127L3-shake": ["qruov"], + "QRUOV-1q31L10-aes": ["qruov"], + "QRUOV-1q31L10-shake": ["qruov"], + "QRUOV-1q31L3-aes": ["qruov"], + "QRUOV-1q31L3-shake": ["qruov"], + "QRUOV-1q7L10-aes": ["qruov"], + "QRUOV-1q7L10-shake": ["qruov"], + "QRUOV-3q127L10-aes": ["qruov"], + "QRUOV-3q127L10-shake": ["qruov"], + "QRUOV-3q127L3-aes": ["qruov"], + "QRUOV-3q127L3-shake": ["qruov"], + "QRUOV-3q31L10-aes": ["qruov"], + "QRUOV-3q31L10-shake": ["qruov"], + "QRUOV-3q31L3-aes": ["qruov"], + "QRUOV-3q31L3-shake": ["qruov"], + "QRUOV-3q7L10-aes": ["qruov"], + "QRUOV-3q7L10-shake": ["qruov"], + "QRUOV-5q127L10-aes": ["qruov"], + "QRUOV-5q127L10-shake": ["qruov"], + "QRUOV-5q127L3-aes": ["qruov"], + "QRUOV-5q127L3-shake": ["qruov"], + "QRUOV-5q31L10-aes": ["qruov"], + "QRUOV-5q31L10-shake": ["qruov"], + "QRUOV-5q31L3-aes": ["qruov"], + "QRUOV-5q31L3-shake": ["qruov"], + "QRUOV-5q7L10-aes": ["qruov"], + "QRUOV-5q7L10-shake": ["qruov"] } diff --git a/tests/constant_time/sig/passes/qruov b/tests/constant_time/sig/passes/qruov new file mode 100644 index 0000000000..510fba66c0 --- /dev/null +++ b/tests/constant_time/sig/passes/qruov @@ -0,0 +1,31 @@ +# Valgrind suppression file for QR-UOV (all parameter sets, ref implementation). +# Each entry below branches only on data that is discarded or published. + +# Rejection sampling branches on whether a PRG byte equals q. Rejected bytes +# are discarded, so this reveals which positions were resampled, not the +# values that were kept. +{ + Rejection sampling of PRG output + Memcheck:Cond + src:fastop.h:15 +} + +{ + Rejection sampling of PRG output + Memcheck:Cond + src:fastop.h:17 +} + +{ + Rejection sampling of PRG output + Memcheck:Cond + src:fastop.h:20 +} + +# An inconsistent linear system is discarded and signing retries with fresh +# randomness, so this reveals only that a discarded attempt was retried. +{ + Consistency check of the prepared linear system before a retry + Memcheck:Cond + src:linsys.c:140 +} diff --git a/tests/kat_sig.c b/tests/kat_sig.c index 4327fd33e8..0a3b51092f 100644 --- a/tests/kat_sig.c +++ b/tests/kat_sig.c @@ -342,6 +342,306 @@ OQS_STATUS combine_message_signature(uint8_t **signed_msg, size_t *signed_msg_le memcpy(*signed_msg, msg, msg_len); memcpy(*signed_msg + msg_len, signature, signature_len); return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q7L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q7L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q31L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q31L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q31L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q31L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q127L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q127L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q127L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-1q127L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q7L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q7L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q31L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q31L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q31L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q31L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q127L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q127L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q127L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-3q127L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q7L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q7L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q31L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q31L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q31L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q31L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q127L3-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q127L3-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q127L10-aes")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; + } else if (0 == strcmp(sig->method_name, "QRUOV-5q127L10-shake")) { + // signed_msg = signature || msg + *signed_msg_len = signature_len + msg_len; + *signed_msg = OQS_MEM_malloc(*signed_msg_len); + if (*signed_msg == NULL) { + return OQS_ERROR; + } + memcpy(*signed_msg, signature, signature_len); + memcpy(*signed_msg + signature_len, msg, msg_len); + return OQS_SUCCESS; } else if (0 == strcmp(sig->method_name, "OV-Is")) { // signed_msg = msg || signature *signed_msg_len = msg_len + signature_len; diff --git a/tests/test_binary.py b/tests/test_binary.py index 91c1945e3f..a9d59b4b67 100644 --- a/tests/test_binary.py +++ b/tests/test_binary.py @@ -34,7 +34,7 @@ def test_namespace(): symbols.append(line) # ideally this would be just ['oqs', 'pqclean'], but contains exceptions (e.g., providing compat implementations of unavailable platform functions) - namespaces = ['oqs', 'pqclean', 'keccak', 'pqcrystals', 'pqmayo', 'init', 'fini', 'seedexpander', '__x86.get_pc_thunk', 'libjade', 'jade', '__jade', '__jasmin_syscall', 'pqcp', 'pqov', '_snova', 'sha3', 'slh', 'sha2', 'shake', 'hash', 'openssh', 'hqc', 'pqchqc'] + namespaces = ['oqs', 'pqclean', 'keccak', 'pqcrystals', 'pqmayo', 'init', 'fini', 'seedexpander', '__x86.get_pc_thunk', 'libjade', 'jade', '__jade', '__jasmin_syscall', 'pqcp', 'pqov', 'qruov', '_snova', 'sha3', 'slh', 'sha2', 'shake', 'hash', 'openssh', 'hqc', 'pqchqc'] non_namespaced = [] for symbolstr in symbols: diff --git a/tests/test_cmake_option_coverage.py b/tests/test_cmake_option_coverage.py new file mode 100644 index 0000000000..4e0d043a2b --- /dev/null +++ b/tests/test_cmake_option_coverage.py @@ -0,0 +1,272 @@ +# SPDX-License-Identifier: MIT +"""Checks that every build option a CMakeLists tests can actually be set. + +A family's `CMakeLists.txt` selects sources with +`if(OQS_ENABLE_SIG__)`. If no option of that name is ever +declared in `.CMake/alg_support.cmake`, the condition is false in every +configuration, so those sources are shipped in the tarball, reviewed, and +never compiled anywhere. Nothing else in the tree notices: the build +succeeds, and the KATs pass on whichever implementation did get selected, +because the implementations of one scheme agree on their vectors. + +Scope, so the name is not read as broader than the check: this compares the +options a CMakeLists *references* against the options `alg_support.cmake` +*declares*. Sources that ship under `src/` and are referenced by no +CMakeLists at all are a different problem and are not covered here. Libjade +uses `OQS_ENABLE_LIBJADE_*`, which is outside the pattern on both sides. + +Whether an option can exist at all is decided by +`scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg_conditional.fragment`, +which emits a per-implementation option only for an implementation that is +not the family default and that declares either a supported platform or +`memory_optimized`. So the set of implementations that cannot be enabled is +derivable from `docs/algorithms/*/*.yml` rather than listed here, and it +stays correct when parameter sets are added or renamed. What this module +does keep is a reason for each one, because shipping sources nothing can +build should be a recorded decision rather than an accident. + +This reads metadata and CMake text only. It does not configure or build, so +it costs nothing and runs on every platform. +""" + +import glob +import os +import re + +import pytest + +LIBOQS_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +ALG_SUPPORT = os.path.join(LIBOQS_ROOT, ".CMake", "alg_support.cmake") +OQSCONFIG = os.path.join(LIBOQS_ROOT, "src", "oqsconfig.h.cmake") + +OPTION_DECLARATION = re.compile( + r"(?:cmake_dependent_option|option)\s*\(\s*(OQS_ENABLE_(?:SIG|KEM)_[A-Za-z0-9_]+)" +) +OPTION_REFERENCE = re.compile(r"\b(OQS_ENABLE_(?:SIG|KEM)_[A-Za-z0-9_]+)\b") +CMAKEDEFINE = re.compile( + r"^\s*#cmakedefine\s+(OQS_ENABLE_(?:SIG|KEM)_[A-Za-z0-9_]+)", re.M +) +# CMake bracket comments `#[[ ... ]]` and bracket arguments `[[ ... ]]`, with +# any number of `=` between the brackets. +BRACKET = re.compile(r"#?\[(=*)\[.*?\]\1\]", re.S) + +# Why a shipped implementation is not selectable, keyed by (family, +# implementation). An implementation that the metadata says cannot be +# enabled, and that is not recorded here, fails: the point is that the +# decision is visible. +WITHHELD_REASONS = { + ("qruov", "opt"): ( + "QR-UOV opt is withheld pending an ARM64 investigation: making it " + "selectable produced reproducible SIGBUS crashes in 8 of the 30 " + "variants during test_sig, reported in open-quantum-safe/liboqs#2582. " + "ref is the default and avx2 is the optimised x86-64 path. Note that " + "the generated wrapper selects with `#if _opt / #elif _avx2`, so " + "whenever opt does become selectable that ordering has to change in " + "the same commit, or enabling opt will silently drop AVX2." + ), +} + + +def strip_cmake_comments(text): + """Drop comments so commented-out code is not read as live, and vice versa. + + `src/sig_stfl/lms/CMakeLists.txt` has a commented-out guard on an option + that does not exist, so without this the check would report it. + + Bracket forms are removed first, because handling only `#` to end of line + gets both directions wrong: the body of a `#[[ ... ]]` block comment would + be read as live code, and a `#` inside a `[[ ... ]]` bracket argument + would truncate a line that is live. Newlines are preserved so that line + numbering is unchanged. + + Remaining limitation, since this decides whether a real finding is + reported: a quoted argument spanning several lines resets the quote state + at each newline. Nothing in the files read here does that. + """ + text = BRACKET.sub(lambda m: "\n" * m.group(0).count("\n"), text) + + lines = [] + for line in text.splitlines(): + quoted = False + end = len(line) + index = 0 + while index < len(line): + char = line[index] + if char == "\\" and quoted: + index += 2 + continue + if char == '"': + quoted = not quoted + elif char == "#" and not quoted: + end = index + break + index += 1 + lines.append(line[:end]) + return "\n".join(lines) + + +def read_text(path): + with open(path, encoding="utf-8", errors="replace") as f: + return f.read() + + +def declared_options(): + return set(OPTION_DECLARATION.findall(strip_cmake_comments(read_text(ALG_SUPPORT)))) + + +def referenced_options(): + """Every OQS_ENABLE_SIG/KEM option tested by a family's CMakeLists.""" + references = {} + for dirpath, _, filenames in os.walk(os.path.join(LIBOQS_ROOT, "src")): + if "CMakeLists.txt" not in filenames: + continue + path = os.path.join(dirpath, "CMakeLists.txt") + relative = os.path.relpath(path, LIBOQS_ROOT).replace(os.sep, "/") + for symbol in OPTION_REFERENCE.findall(strip_cmake_comments(read_text(path))): + references.setdefault(symbol, set()).add(relative) + return references + + +def configured_defines(): + """Every OQS_ENABLE_SIG/KEM macro src/oqsconfig.h.cmake promises to define.""" + return set(CMAKEDEFINE.findall(read_text(OQSCONFIG))) + + +def withheld_pairs(): + """(family, implementation) pairs no generated option can enable. + + Mirrors the filter in add_enable_by_alg_conditional.fragment. + """ + yaml = pytest.importorskip("yaml") + pairs = set() + pattern = os.path.join(LIBOQS_ROOT, "docs", "algorithms", "*", "*.yml") + for path in sorted(glob.glob(pattern)): + family = os.path.splitext(os.path.basename(path))[0] + data = yaml.safe_load(read_text(path)) or {} + for parameter_set in data.get("parameter-sets") or []: + for implementation in parameter_set.get("implementations") or []: + if ( + implementation.get("default") + or implementation.get("supported-platforms") + or implementation.get("memory_optimized") + ): + continue + pairs.add((family, implementation.get("upstream-id"))) + return pairs + + +def matches_pair(symbol, pairs): + """Whether an option name belongs to one of the withheld (family, impl) pairs.""" + for prefix in ("OQS_ENABLE_SIG_", "OQS_ENABLE_KEM_"): + if symbol.startswith(prefix): + tail = symbol[len(prefix):] + return any( + tail.startswith(family + "_") and tail.endswith("_" + implementation) + for family, implementation in pairs + ) + return False + + +def test_a_line_comment_hides_a_declaration(): + text = '# option(OQS_ENABLE_SIG_ghost_1_neon "" ON)' + assert not OPTION_DECLARATION.findall(strip_cmake_comments(text)) + + +def test_a_bracket_comment_hides_a_declaration(): + """A `#[[ ]]` body must not be read as live, or the guard can be silenced. + + Wrapping a declaration in a bracket comment would otherwise make an + unselectable implementation look selectable, and the staleness check + would then invite someone to delete its recorded reason. + """ + text = '#[[\noption(OQS_ENABLE_SIG_ghost_1_neon "" ON)\n]]' + assert not OPTION_DECLARATION.findall(strip_cmake_comments(text)) + + +def test_a_bracket_argument_does_not_hide_live_code(): + """The inverse: a `#` inside `[[ ]]` must not truncate a live line.""" + text = 'message([[note # see below]])\nif(OQS_ENABLE_SIG_ghost_1_neon)' + assert "OQS_ENABLE_SIG_ghost_1_neon" in strip_cmake_comments(text) + + +def test_a_quoted_hash_does_not_hide_live_code(): + text = 'set(X "a # b")\nif(OQS_ENABLE_SIG_ghost_1_neon)' + assert "OQS_ENABLE_SIG_ghost_1_neon" in strip_cmake_comments(text) + + +def test_comment_stripping_preserves_line_count(): + text = "a\n#[[\nb\n]]\nc" + assert len(strip_cmake_comments(text).splitlines()) == len(text.splitlines()) + + +def test_option_parsing_finds_known_options(): + """A regex regression that matched almost nothing would pass every check.""" + declared = declared_options() + assert "OQS_ENABLE_SIG_mayo_1_avx2" in declared + assert "OQS_ENABLE_KEM_ml_kem_768" in declared + + +def test_reference_parsing_finds_known_options(): + referenced = referenced_options() + assert "OQS_ENABLE_SIG_mayo_1_avx2" in referenced + assert "OQS_ENABLE_SIG_qruov_1q7L10aes" in referenced + + +def test_every_withheld_implementation_has_a_recorded_reason(): + undocumented = sorted(withheld_pairs() - set(WITHHELD_REASONS)) + assert not undocumented, ( + "these implementations ship but no generated option can enable them, " + "and no reason is recorded:\n" + + "\n".join(f" {family}: {impl}" for family, impl in undocumented) + + "\n\nGive the implementation a supported platform in " + "docs/algorithms, or record why it is withheld in WITHHELD_REASONS." + ) + + stale = sorted(set(WITHHELD_REASONS) - withheld_pairs()) + assert not stale, ( + "these implementations are recorded as withheld but the metadata now " + "allows an option for them, so the entry is out of date:\n" + + "\n".join(f" {family}: {impl}" for family, impl in stale) + ) + + +def test_every_referenced_option_can_be_enabled(): + declared = declared_options() + references = referenced_options() + pairs = withheld_pairs() + + undeclared = { + symbol: sorted(files) + for symbol, files in references.items() + if symbol not in declared and not matches_pair(symbol, pairs) + } + + assert not undeclared, ( + "these options are tested by a CMakeLists but declared nowhere in " + ".CMake/alg_support.cmake, so the sources they guard can never be " + "compiled in any configuration:\n" + + "\n".join(f" {symbol} ({', '.join(undeclared[symbol])})" + for symbol in sorted(undeclared)) + ) + + +def test_every_configured_define_can_be_enabled(): + """src/oqsconfig.h.cmake must not promise a macro no option can define. + + The same defect seen from a third surface: the generator emits a + `#cmakedefine` for every implementation but an option only for some, so a + withheld implementation leaves a macro that is silently never defined. + """ + declared = declared_options() + pairs = withheld_pairs() + + undefinable = sorted( + symbol + for symbol in configured_defines() - declared + if not matches_pair(symbol, pairs) + ) + + assert not undefinable, ( + "src/oqsconfig.h.cmake declares these macros but no CMake option can " + "ever define them:\n" + "\n".join(f" {symbol}" for symbol in undefinable) + ) diff --git a/tests/test_kats_json.py b/tests/test_kats_json.py new file mode 100644 index 0000000000..bd68de899b --- /dev/null +++ b/tests/test_kats_json.py @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: MIT +"""Structural checks on the KAT digest files themselves. + +`test_kat.py` and `test_kat_all.py` index `tests/KATs/{kem,sig}/kats.json` +directly, so an entry that is missing a digest surfaces as a `KeyError` +raised from inside an unrelated test rather than as a problem with the data. +When a new family is added and only one of the two digests is generated for +it, that reads as N confusing test failures rather than one clear one, and +it is easy to mistake for a build or dispatch problem. + +Algorithms that have no KATs at all are simply absent from these files, and +that stays the way to express it: SLH-DSA uses ACVP vectors and the `-extmu` +variants have no KATs, and neither appears here. `SINGLE_DIGEST_ONLY` is for +the different case of an algorithm that is present but legitimately has no +`--all` digest. It is empty today, and the check is exact in both +directions, so an entry that stops being needed fails rather than lingering. + +These checks read the data on its own. They need no build, so they run +everywhere and fail fast, and they name the algorithms at fault. +""" + +import json +import os +import re + +import pytest + +LIBOQS_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +KATS_DIR = os.path.join(LIBOQS_ROOT, "tests", "KATs") +SRC_DIR = os.path.join(LIBOQS_ROOT, "src") + +# `single` is compared by test_kat.py, `all` by test_kat_all.py. Both are a +# sha256 over subprocess output, so both are 64 lowercase hex characters. +REQUIRED_DIGESTS = ("all", "single") +DIGEST_PATTERN = re.compile(r"\A[0-9a-f]{64}\Z") + +# Algorithms present in kats.json that legitimately carry only `single`, +# keyed by kind, each with the reason. +SINGLE_DIGEST_ONLY = {} + + +def load_kats(kind): + with open(os.path.join(KATS_DIR, kind, "kats.json"), encoding="utf-8") as f: + return json.load(f) + + +@pytest.mark.parametrize("kind", ["kem", "sig"]) +def test_kats_file_is_not_empty(kind): + assert load_kats(kind), f"tests/KATs/{kind}/kats.json has no entries" + + +@pytest.mark.parametrize("kind", ["kem", "sig"]) +def test_every_algorithm_carries_every_digest(kind): + kats = load_kats(kind) + exempt = SINGLE_DIGEST_ONLY.get(kind, {}) + + incomplete = { + name: sorted(set(REQUIRED_DIGESTS) - set(entry)) + for name, entry in kats.items() + if not set(REQUIRED_DIGESTS) <= set(entry) and name not in exempt + } + + assert not incomplete, ( + f"tests/KATs/{kind}/kats.json is missing digests: " + + "; ".join(f"{name} has no {', '.join(fields)}" + for name, fields in sorted(incomplete.items())) + + ". test_kat_all.py reads ['all'] with no guard, so a missing one " + "fails as a KeyError inside that test. Generate the digest, or, if " + "the algorithm genuinely has none, record it in SINGLE_DIGEST_ONLY." + ) + + stale = sorted(name for name in exempt if name in kats + and set(REQUIRED_DIGESTS) <= set(kats[name])) + assert not stale, ( + f"these {kind} algorithms are recorded in SINGLE_DIGEST_ONLY but now " + f"carry every digest: {', '.join(stale)}" + ) + + +def declared_algorithms(kind): + """Algorithm names from the public header, which is the universe of names. + + Mirrors `helpers.available_{kems,sigs}_by_name()`. + """ + header = os.path.join(SRC_DIR, kind, f"{kind}.h") + macro = f"#define OQS_{kind.upper()}_alg_" + names = [] + with open(header, encoding="utf-8", errors="replace") as f: + for line in f: + if line.startswith(macro): + names.append(line.split(" ")[2].strip()[1:-1]) + return names + + +def has_kats(name): + """Whether an algorithm is expected to appear in kats.json at all. + + The exclusions match the skips in test_kat_all.py: SLH-DSA is covered by + ACVP vectors instead, and the extmu variants have no KATs. Kept in step + with that file rather than inferred from the data. + """ + return "SLH_DSA" not in name and "-extmu" not in name + + +@pytest.mark.parametrize("kind", ["kem", "sig"]) +def test_every_algorithm_with_kats_has_an_entry(kind): + """A missing entry is the failure the other checks cannot see. + + Iterating the file only validates what is in it, so deleting an algorithm + outright would pass every other check here and then reappear as the + KeyError this module exists to pre-empt. + """ + kats = load_kats(kind) + expected = [name for name in declared_algorithms(kind) if has_kats(name)] + + missing = [name for name in expected if name not in kats] + assert not missing, ( + f"these {kind} algorithms are declared in src/{kind}/{kind}.h but have " + f"no entry in tests/KATs/{kind}/kats.json: {', '.join(sorted(missing))}" + ) + + unknown = [name for name in kats if name not in set(declared_algorithms(kind))] + assert not unknown, ( + f"tests/KATs/{kind}/kats.json has entries for algorithms that " + f"src/{kind}/{kind}.h does not declare: {', '.join(sorted(unknown))}" + ) + + +@pytest.mark.parametrize("kind", ["kem", "sig"]) +def test_every_digest_is_a_sha256_hex_string(kind): + kats = load_kats(kind) + + malformed = [ + f"{name}[{field}]={value!r}" + for name, entry in sorted(kats.items()) + for field, value in sorted(entry.items()) + if not (isinstance(value, str) and DIGEST_PATTERN.match(value)) + ] + + assert not malformed, ( + f"tests/KATs/{kind}/kats.json has values that are not lowercase " + f"sha256 hex digests: {', '.join(malformed)}" + )