diff --git a/.github/configs/pq-all.json b/.github/configs/pq-all.json index 09a1ab91af6..29e5c742736 100644 --- a/.github/configs/pq-all.json +++ b/.github/configs/pq-all.json @@ -518,5 +518,82 @@ {"name": "mldsa-weak-prehash", "minutes": 2, "comment": "Opt-in acceptance of a HashML-DSA pre-hash weaker than the parameter set", "configure": ["--enable-cryptonly", "--enable-mldsa", - "CPPFLAGS=-DWOLFSSL_MLDSA_ALLOW_WEAK_PREHASH"]} + "CPPFLAGS=-DWOLFSSL_MLDSA_ALLOW_WEAK_PREHASH"]}, +{"name": "hqc-all-asm", "minutes": 5.5, + "comment": "HQC (experimental) with everything else and the x86_64 assembly: multiplication, sampling, Reed-Muller/Reed-Solomon and multi-stream decapsulation kernels, chosen at run time. hqc_test() repeats the known-answer tests with CPU features removed (cpuid_clear_flag) so every path the runner can execute is tested, as in all the HQC asm configs", + "configure": ["--enable-intelasm", "--enable-sp-asm", + "--enable-all", "--enable-testcert", "--enable-experimental", + "--enable-hqc", "--disable-qt", + "CPPFLAGS=-pedantic -Wdeclaration-after-statement -Wnull-dereference -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"]}, +{"name": "hqc-noasm", "minutes": 2.0, + "comment": "HQC portable C code only", + "configure": ["--disable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc", + "CPPFLAGS=-pedantic -Wdeclaration-after-statement -Wnull-dereference"]}, +{"name": "hqc-sha3-noasm", "minutes": 2.0, + "comment": "HQC assembly with SHA-3 assembly disabled: decapsulation must not use the multi-way Keccak kernels", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-sha3=noasm", "--enable-experimental", "--enable-hqc", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-cache-h-asm", "minutes": 1.6, + "comment": "h kept in the key: no generation of h in encapsulation and decapsulation, single-stream decapsulation", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc=cache-h", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-no-cache-hek-asm", "minutes": 1.6, + "comment": "H(ek) not kept in the key: encapsulation and decapsulation hash the public key each time", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc=no-cache-hek", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-no-cache-y-asm", "minutes": 1.6, + "comment": "seed_dk kept in the key instead of y: y is sampled in each decapsulation", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc=no-cache-y", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-dec-only-no-cache-y-small-mem", "minutes": 1.2, + "comment": "Decapsulation only with y sampled in each decapsulation and small memory re-encryption; unused static functions are errors", + "extra_cflags": "-Werror=unused-function", + "configure": ["--enable-cryptonly", "--enable-experimental", + "--enable-hqc=no-make-key,no-encapsulate,no-cache-y,small-mem"]}, +{"name": "hqc-lazy-hek-cache-h", "minutes": 1.6, + "comment": "H(ek) kept in the key but calculated on first use, with h kept too", + "configure": ["--enable-cryptonly", "--enable-experimental", + "--enable-hqc=lazy-hek,cache-h", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-makekey-only-lazy-hek", "minutes": 1.2, + "comment": "Key generation only: H(ek) is never needed; unused static functions are errors", + "extra_cflags": "-Werror=unused-function", + "configure": ["--enable-cryptonly", "--enable-experimental", + "--enable-hqc=no-encapsulate,no-decapsulate,lazy-hek"]}, +{"name": "hqc-small-smallstack-noasm", "minutes": 2.2, + "comment": "Smallest HQC: small code, small memory workspaces and small stack", + "configure": ["--disable-intelasm", "--enable-smallstack", + "--enable-cryptonly", "--enable-experimental", + "--enable-hqc=small,small-mem", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-1-no-large-code", "minutes": 1.6, + "comment": "One parameter set without the large code paths, with the assembly", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc=1,no-large-code", + "CPPFLAGS=-Wdeclaration-after-statement"]}, +{"name": "hqc-make-enc-only", "minutes": 1.2, + "comment": "Key generation and encapsulation without decapsulation; unused static functions are errors", + "extra_cflags": "-Werror=unused-function", + "configure": ["--enable-cryptonly", "--enable-experimental", + "--enable-hqc=no-decapsulate,cache-h"]}, +{"name": "hqc-dec-only-small-mem", "minutes": 1.2, + "comment": "Decapsulation only (key decoded from a seed) with small memory re-encryption; unused static functions are errors", + "extra_cflags": "-Werror=unused-function", + "configure": ["--enable-cryptonly", "--enable-experimental", + "--enable-hqc=no-make-key,no-encapsulate,small-mem"]}, +{"name": "hqc-makekey-small-mem-asm", "minutes": 1.6, + "comment": "Small memory key generation only, with h kept in the key: key generation regenerates h after writing s, and the fast and small multiplications are both built", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc=cache-h", + "CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_HQC_MAKEKEY_SMALL_MEM"]}, +{"name": "hqc-encaps-small-mem-asm", "minutes": 1.6, + "comment": "Small memory encapsulation and decapsulation only: fast key generation alongside the small memory re-encryption", + "configure": ["--enable-intelasm", "--enable-cryptonly", + "--enable-experimental", "--enable-hqc", + "CPPFLAGS=-Wdeclaration-after-statement -DWOLFSSL_HQC_ENCAPSULATE_SMALL_MEM"]} ] diff --git a/.github/workflows/whitebox-smoke.yml b/.github/workflows/whitebox-smoke.yml index b2996e4d608..43daf44fab9 100644 --- a/.github/workflows/whitebox-smoke.yml +++ b/.github/workflows/whitebox-smoke.yml @@ -71,6 +71,42 @@ jobs: CC: gcc run: ./tests/unit-mcdc/run-whitebox-smoke.sh . + # HQC is experimental and not in --enable-all, so the smoke run above + # only builds the HQC white-boxes' skip stubs. Build HQC twice - with + # the x86_64 assembly, and in C with H(ek) calculated on first use and + # y sampled in each decapsulation - and run both white-boxes against + # each build: + # - test_wc_hqc_whitebox.c: Reed-Solomon error correction (GFNI + # kernels when the runner has GFNI, and the C decoder), + # - test_hqc_fault_whitebox.c: allocation and SHA-3 failures in every + # operation, under ASan for leaks on the error paths. + # They exit 0 either way, as the MC/DC harness expects, and report a + # failed check in their closing "done (with failures)" line. + - name: Run the HQC white-boxes + run: | + set -o pipefail + for opts in "--enable-hqc --enable-intelasm" \ + "--enable-hqc=lazy-hek,no-cache-y"; do + make distclean + ./configure --enable-experimental --enable-cryptonly \ + --enable-static --disable-shared \ + CPPFLAGS=-DWOLFSSL_TEST_STATIC_BUILD $opts + make -j"$(nproc)" src/libwolfssl.la + cp src/.libs/libwolfssl.a hqc-wb.a + ar d hqc-wb.a "$(ar t hqc-wb.a | grep -E '_la-wc_hqc\.o$')" + for wb in test_wc_hqc_whitebox test_hqc_fault_whitebox; do + gcc -O1 -g -fsanitize=address,undefined \ + -fno-sanitize-recover=all -fno-omit-frame-pointer \ + -I. -Itests -DWOLFSSL_TEST_STATIC_BUILD -DHAVE_CONFIG_H \ + -DWOLFSSL_USE_OPTIONS_H \ + $(sed -n 's/^AM_CFLAGS *= *//p' Makefile | tr ' ' '\n' | \ + grep -E '^-m' | tr '\n' ' ') \ + -o hqc-wb "tests/unit-mcdc/$wb.c" hqc-wb.a -lm -lpthread + ./hqc-wb | tee hqc-wb.log + grep -q 'done (ok)' hqc-wb.log + done + done + wolfentropy-latch: name: wolfEntropy latch white-box runs-on: ubuntu-24.04 diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 7d956d43a28..ebabdd1d579 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -548,6 +548,7 @@ NO_ESP_MP_MUL_EVEN_ALT_CALC NO_FORCE_SCR_SAME_SUITE NO_GCM_ENCRYPT_EXTRA NO_GETENV +NO_GFNI_SUPPORT NO_HANDSHAKE_DONE_CB NO_IMX6_CAAM_AES NO_IMX6_CAAM_HASH @@ -1055,6 +1056,7 @@ WOLFSSL_HARDEN_TLS_NO_PKEY_CHECK WOLFSSL_HARDEN_TLS_NO_SCR_CHECK WOLFSSL_HAVE_KYBER WOLFSSL_HOSTNAME_VERIFY_ALT_NAME_ONLY +WOLFSSL_HQC_BENCH_DETERMINISTIC WOLFSSL_I2D_ECDSA_SIG_ALLOC WOLFSSL_IAR_ARM_TIME WOLFSSL_IGNORE_BAD_CERT_PATH diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fe188969ce..c26283fd554 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1436,6 +1436,59 @@ add_option(WOLFSSL_FRODOKEM_SME "Enable FrodoKEM AArch64 SME acceleration (default: disabled)" "no" "yes;no") +# HQC KEM (experimental: no NIST standard document yet) +add_option(WOLFSSL_HQC + "Enable the wolfSSL HQC KEM implementation (requires WOLFSSL_EXPERIMENTAL) (default: disabled)" + "no" "yes;no") +# HQC parameter sets (each default: enabled) +add_option(WOLFSSL_HQC_1 + "Enable the HQC-1 parameter set (default: enabled)" + "yes" "yes;no") +add_option(WOLFSSL_HQC_3 + "Enable the HQC-3 parameter set (default: enabled)" + "yes" "yes;no") +add_option(WOLFSSL_HQC_5 + "Enable the HQC-5 parameter set (default: enabled)" + "yes" "yes;no") +# HQC operations (each default: enabled) +add_option(WOLFSSL_HQC_MAKE_KEY + "Enable HQC key generation (default: enabled)" + "yes" "yes;no") +add_option(WOLFSSL_HQC_ENCAPSULATE + "Enable HQC encapsulation (default: enabled)" + "yes" "yes;no") +add_option(WOLFSSL_HQC_DECAPSULATE + "Enable HQC decapsulation (default: enabled)" + "yes" "yes;no") +# HQC small memory key generation, encapsulation and decapsulation +add_option(WOLFSSL_HQC_SMALL_MEM + "Enable HQC operations that use less dynamic memory (default: disabled)" + "no" "yes;no") +# HQC code size: smallest code / smaller code that is not unrolled +add_option(WOLFSSL_HQC_SMALL + "Enable smallest HQC code size (default: disabled)" + "no" "yes;no") +add_option(WOLFSSL_HQC_NO_LARGE_CODE + "Enable smaller HQC code that is not unrolled (default: disabled)" + "no" "yes;no") +# HQC: keep h generated from the public key in the key object +add_option(WOLFSSL_HQC_CACHE_H + "Enable keeping HQC h in the key object (default: disabled)" + "no" "yes;no") +# HQC: keep H(ek) in the key object, calculated when the key is made or +# decoded, or on first use +add_option(WOLFSSL_HQC_CACHE_HEK + "Enable keeping HQC H(ek) in the key object (default: enabled)" + "yes" "yes;no") +add_option(WOLFSSL_HQC_LAZY_HEK + "Enable calculating the kept HQC H(ek) on first use (default: disabled)" + "no" "yes;no") +# HQC: keep the support of y in the key object, or only seed_dk and sample y +# in each decapsulation +add_option(WOLFSSL_HQC_CACHE_Y + "Enable keeping the support of HQC y in the key object (default: enabled)" + "yes" "yes;no") + message(STATUS "Looking for WOLFSSL_EXPERIMENTAL") if (WOLFSSL_EXPERIMENTAL) message(STATUS "Looking for WOLFSSL_EXPERIMENTAL - found") @@ -1554,6 +1607,109 @@ if (WOLFSSL_EXPERIMENTAL) message(STATUS "Looking for WOLFSSL_FRODOKEM - not found") endif() + # Checking for experimental feature: HQC + message(STATUS "Looking for WOLFSSL_HQC") + if (WOLFSSL_HQC) + set(WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1) + message(STATUS "Looking for WOLFSSL_HQC - found") + + # At least one parameter set must be enabled. + if (NOT WOLFSSL_HQC_1 AND NOT WOLFSSL_HQC_3 AND NOT WOLFSSL_HQC_5) + message(FATAL_ERROR + "WOLFSSL_HQC requires at least one of WOLFSSL_HQC_1, WOLFSSL_HQC_3 or WOLFSSL_HQC_5.") + endif() + # At least one operation must be enabled. + if (NOT WOLFSSL_HQC_MAKE_KEY AND NOT WOLFSSL_HQC_ENCAPSULATE + AND NOT WOLFSSL_HQC_DECAPSULATE) + message(FATAL_ERROR + "WOLFSSL_HQC requires at least one of WOLFSSL_HQC_MAKE_KEY, WOLFSSL_HQC_ENCAPSULATE or WOLFSSL_HQC_DECAPSULATE.") + endif() + + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HAVE_HQC") + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA3") + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHAKE256") + + set_wolfssl_definitions("WOLFSSL_HAVE_HQC" RESULT) + set_wolfssl_definitions("WOLFSSL_SHA3" RESULT) + set_wolfssl_definitions("WOLFSSL_SHAKE256" RESULT) + + # Excluded parameter sets. + if (NOT WOLFSSL_HQC_1) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_NO_HQC_1") + set_wolfssl_definitions("WOLFSSL_NO_HQC_1" RESULT) + endif() + if (NOT WOLFSSL_HQC_3) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_NO_HQC_3") + set_wolfssl_definitions("WOLFSSL_NO_HQC_3" RESULT) + endif() + if (NOT WOLFSSL_HQC_5) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_NO_HQC_5") + set_wolfssl_definitions("WOLFSSL_NO_HQC_5" RESULT) + endif() + # Excluded operations. + if (NOT WOLFSSL_HQC_MAKE_KEY) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_MAKE_KEY") + set_wolfssl_definitions("WOLFSSL_HQC_NO_MAKE_KEY" RESULT) + endif() + if (NOT WOLFSSL_HQC_ENCAPSULATE) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_ENCAPSULATE") + set_wolfssl_definitions("WOLFSSL_HQC_NO_ENCAPSULATE" RESULT) + endif() + if (NOT WOLFSSL_HQC_DECAPSULATE) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_DECAPSULATE") + set_wolfssl_definitions("WOLFSSL_HQC_NO_DECAPSULATE" RESULT) + endif() + # Small memory operations. + if (WOLFSSL_HQC_SMALL_MEM) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_MAKEKEY_SMALL_MEM") + list(APPEND WOLFSSL_DEFINITIONS + "-DWOLFSSL_HQC_ENCAPSULATE_SMALL_MEM") + set_wolfssl_definitions("WOLFSSL_HQC_MAKEKEY_SMALL_MEM" RESULT) + set_wolfssl_definitions("WOLFSSL_HQC_ENCAPSULATE_SMALL_MEM" RESULT) + endif() + # Code size. + if (WOLFSSL_HQC_SMALL) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_SMALL") + set_wolfssl_definitions("WOLFSSL_HQC_SMALL" RESULT) + endif() + if (WOLFSSL_HQC_NO_LARGE_CODE) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_LARGE_CODE") + set_wolfssl_definitions("WOLFSSL_HQC_NO_LARGE_CODE" RESULT) + endif() + # h is only kept for encapsulation and decapsulation that are not + # small memory: otherwise caching h has no effect (see wc_hqc.h). + if (WOLFSSL_HQC_CACHE_H AND (WOLFSSL_HQC_SMALL_MEM OR + (NOT WOLFSSL_HQC_ENCAPSULATE AND NOT WOLFSSL_HQC_DECAPSULATE))) + message(WARNING + "WOLFSSL_HQC_CACHE_H has no effect with WOLFSSL_HQC_SMALL_MEM or without encapsulation and decapsulation: disabled.") + override_cache(WOLFSSL_HQC_CACHE_H "no") + endif() + if (WOLFSSL_HQC_CACHE_H) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_CACHE_H") + set_wolfssl_definitions("WOLFSSL_HQC_CACHE_H" RESULT) + endif() + # H(ek) is only calculated on first use when it is kept in the key. + if (WOLFSSL_HQC_LAZY_HEK AND NOT WOLFSSL_HQC_CACHE_HEK) + message(WARNING + "WOLFSSL_HQC_LAZY_HEK has no effect without WOLFSSL_HQC_CACHE_HEK: disabled.") + override_cache(WOLFSSL_HQC_LAZY_HEK "no") + endif() + if (NOT WOLFSSL_HQC_CACHE_HEK) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_CACHE_HEK") + set_wolfssl_definitions("WOLFSSL_HQC_NO_CACHE_HEK" RESULT) + endif() + if (WOLFSSL_HQC_LAZY_HEK) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_LAZY_HEK") + set_wolfssl_definitions("WOLFSSL_HQC_LAZY_HEK" RESULT) + endif() + if (NOT WOLFSSL_HQC_CACHE_Y) + list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_HQC_NO_CACHE_Y") + set_wolfssl_definitions("WOLFSSL_HQC_NO_CACHE_Y" RESULT) + endif() + else() + message(STATUS "Looking for WOLFSSL_HQC - not found") + endif() + # Other experimental feature detection can be added here... # Were any experimental features found? Display a message. @@ -1572,6 +1728,9 @@ else() if (WOLFSSL_FRODOKEM) message(FATAL_ERROR "Error: WOLFSSL_FRODOKEM requires WOLFSSL_EXPERIMENTAL at this time.") endif() + if (WOLFSSL_HQC) + message(FATAL_ERROR "Error: WOLFSSL_HQC requires WOLFSSL_EXPERIMENTAL at this time.") + endif() endif() # LMS @@ -5447,6 +5606,7 @@ if(WOLFSSL_EXAMPLES) tests/api/test_curve448.c tests/api/test_ed448.c tests/api/test_frodokem.c + tests/api/test_hqc.c tests/api/test_mlkem.c tests/api/test_mldsa.c tests/api/test_mldsa_legacy.c diff --git a/ChangeLog.md b/ChangeLog.md index eec802b2479..80735d67e01 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,19 @@ curve equation need no curve arithmetic, so both are still done on the host. Both macros are documented in `wolfcrypt/src/port/nxp/README_SE050.md` and `IDE/CRYPTOCELL/README.md`. by @SparkiDev +* Added the HQC key encapsulation mechanism (HQC-1, HQC-3 and HQC-5), which + NIST selected for standardization as a backup to ML-KEM. There is no NIST + standard document yet, so it is experimental: `--enable-hqc` requires + `--enable-experimental` and is not part of `--enable-all`. It follows the + HQC specification v5.1 and is byte-for-byte compatible with the reference + implementation v5.1.0 and liboqs. The `wc_HqcKey_*` API mirrors the ML-KEM + API; there are no ASN.1 key formats or TLS groups. With `--enable-intelasm`, + x86_64 assembly using PCLMULQDQ, VPCLMULQDQ, AVX2, AVX-512 and GFNI is chosen + at run time from the CPU's features. Sub-options of `--enable-hqc` select the + parameter sets and operations, smaller code or less dynamic memory, and what + is kept in the key object: `h` (`cache-h`), the hash of the public key, by + default calculated when the key is made or decoded (`no-cache-hek`, + `lazy-hek`), and the support of `y` (`no-cache-y`). by @SparkiDev ## Behavioral Changes * **Behavioral change (built-in OCSP and CRL HTTP fetches now time out)**: diff --git a/IDE/INTIME-RTOS/Makefile b/IDE/INTIME-RTOS/Makefile index 136407325c2..13eb66108c5 100644 --- a/IDE/INTIME-RTOS/Makefile +++ b/IDE/INTIME-RTOS/Makefile @@ -325,6 +325,7 @@ INCL_TARGS := wolfssl/callbacks.h \ wolfssl/wolfcrypt/types.h \ wolfssl/wolfcrypt/visibility.h \ wolfssl/wolfcrypt/wc_encrypt.h \ + wolfssl/wolfcrypt/wc_hqc.h \ wolfssl/wolfcrypt/wc_kyber.h \ wolfssl/wolfcrypt/wc_lms.h \ wolfssl/wolfcrypt/wc_pkcs11.h \ diff --git a/cmake/functions.cmake b/cmake/functions.cmake index c13cd3fdf52..ceff29acc3e 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -358,6 +358,9 @@ function(generate_build_flags) if(WOLFSSL_FRODOKEM OR WOLFSSL_USER_SETTINGS) set(BUILD_WC_FRODOKEM "yes" PARENT_SCOPE) endif() + if(WOLFSSL_HQC OR WOLFSSL_USER_SETTINGS) + set(BUILD_WC_HQC "yes" PARENT_SCOPE) + endif() if(WOLFSSL_MLDSA OR WOLFSSL_DILITHIUM OR WOLFSSL_USER_SETTINGS) set(BUILD_MLDSA "yes" PARENT_SCOPE) endif() @@ -1384,6 +1387,13 @@ function(generate_lib_src_list LIB_SOURCES) endif() endif() + if(BUILD_WC_HQC) + list(APPEND LIB_SOURCES wolfcrypt/src/wc_hqc.c) + if(BUILD_INTELASM) + list(APPEND LIB_SOURCES wolfcrypt/src/wc_hqc_asm.S) + endif() + endif() + if(BUILD_WC_LMS) list(APPEND LIB_SOURCES wolfcrypt/src/wc_lms.c) list(APPEND LIB_SOURCES wolfcrypt/src/wc_lms_impl.c) diff --git a/cmake/options.h.in b/cmake/options.h.in index 3dad37d8533..fd63306668d 100644 --- a/cmake/options.h.in +++ b/cmake/options.h.in @@ -464,6 +464,36 @@ extern "C" { #cmakedefine WOLFSSL_EXPERIMENTAL_SETTINGS #undef WOLFSSL_HAVE_MLKEM #cmakedefine WOLFSSL_HAVE_MLKEM +#undef WOLFSSL_HAVE_HQC +#cmakedefine WOLFSSL_HAVE_HQC +#undef WOLFSSL_NO_HQC_1 +#cmakedefine WOLFSSL_NO_HQC_1 +#undef WOLFSSL_NO_HQC_3 +#cmakedefine WOLFSSL_NO_HQC_3 +#undef WOLFSSL_NO_HQC_5 +#cmakedefine WOLFSSL_NO_HQC_5 +#undef WOLFSSL_HQC_NO_MAKE_KEY +#cmakedefine WOLFSSL_HQC_NO_MAKE_KEY +#undef WOLFSSL_HQC_NO_ENCAPSULATE +#cmakedefine WOLFSSL_HQC_NO_ENCAPSULATE +#undef WOLFSSL_HQC_NO_DECAPSULATE +#cmakedefine WOLFSSL_HQC_NO_DECAPSULATE +#undef WOLFSSL_HQC_MAKEKEY_SMALL_MEM +#cmakedefine WOLFSSL_HQC_MAKEKEY_SMALL_MEM +#undef WOLFSSL_HQC_ENCAPSULATE_SMALL_MEM +#cmakedefine WOLFSSL_HQC_ENCAPSULATE_SMALL_MEM +#undef WOLFSSL_HQC_SMALL +#cmakedefine WOLFSSL_HQC_SMALL +#undef WOLFSSL_HQC_NO_LARGE_CODE +#cmakedefine WOLFSSL_HQC_NO_LARGE_CODE +#undef WOLFSSL_HQC_CACHE_H +#cmakedefine WOLFSSL_HQC_CACHE_H +#undef WOLFSSL_HQC_NO_CACHE_HEK +#cmakedefine WOLFSSL_HQC_NO_CACHE_HEK +#undef WOLFSSL_HQC_LAZY_HEK +#cmakedefine WOLFSSL_HQC_LAZY_HEK +#undef WOLFSSL_HQC_NO_CACHE_Y +#cmakedefine WOLFSSL_HQC_NO_CACHE_Y #undef WOLFSSL_TLS_NO_MLKEM_STANDALONE #cmakedefine WOLFSSL_TLS_NO_MLKEM_STANDALONE #undef NO_WOLFSSL_STUB diff --git a/configure.ac b/configure.ac index f825af4ff6e..3f71658f469 100644 --- a/configure.ac +++ b/configure.ac @@ -2538,6 +2538,128 @@ else fi fi +# HQC (experimental: no NIST standard document yet) +AC_ARG_ENABLE([hqc], + [AS_HELP_STRING([--enable-hqc],[Enable HQC KEM, optionally with a comma-separated list of sub-options e.g. 1,3,no-make-key,small-mem,small,no-large-code,cache-h,no-cache-hek,lazy-hek,no-cache-y. Naming parameter sets (1, 3, 5) builds only those; otherwise all are built (requires --enable-experimental) (default: disabled)])], + [ ENABLED_HQC=$enableval ], + [ ENABLED_HQC=no ] + ) + +AS_IF([ test "$ENABLED_HQC" != "no" && test "$ENABLED_EXPERIMENTAL" != "yes" ],[ AC_MSG_ERROR([hqc requires --enable-experimental.]) ]) + +# Parameter sets: unset until named; see defaulting after the options. +ENABLED_HQC_1= +ENABLED_HQC_3= +ENABLED_HQC_5= +ENABLED_HQC_MAKE_KEY=yes +ENABLED_HQC_ENCAPSULATE=yes +ENABLED_HQC_DECAPSULATE=yes +ENABLED_HQC_SMALL_MEM=no +ENABLED_HQC_SMALL=no +ENABLED_HQC_NO_LARGE_CODE=no +ENABLED_HQC_CACHE_H=no +ENABLED_HQC_CACHE_HEK=yes +ENABLED_HQC_LAZY_HEK=no +ENABLED_HQC_CACHE_Y=yes +# Sub-options given as a comma-separated list to --enable-hqc, e.g. +# --enable-hqc=1,3,no-make-key. "no-