From 16b862997207eb717dd84e27ec7f893bb06fe7ab Mon Sep 17 00:00:00 2001 From: nonam3e <71525212+nonam3e@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:52:26 +0700 Subject: [PATCH] Icicle-pqc integration (#2216) * correct build Signed-off-by: nonam3e * use interface to link Signed-off-by: nonam3e * remove load backends Signed-off-by: nonam3e * liboqs 0.14.0 release candidate 1 (#2180) * Prepare 0.14.0 release candidate 1 [full tests] [extended tests] Signed-off-by: Spencer Wilson * Update release notes with deprecation and security info [skip ci] Signed-off-by: Spencer Wilson --------- Signed-off-by: Spencer Wilson Signed-off-by: nonam3e * add icicle in scripts Signed-off-by: nonam3e * update docs Signed-off-by: nonam3e * add link Signed-off-by: nonam3e * build with local package Signed-off-by: nonam3e * update scripts Signed-off-by: nonam3e * choose alg -DOQS_ENABLE_KEM_ml_kem_512_icicle_cuda=ON -DOQS_ENABLE_KEM_ml_kem_768_icicle_cuda=OFF Signed-off-by: nonam3e * docs Signed-off-by: nonam3e * OQS_STATUS return type Signed-off-by: nonam3e * Document public / internal API split [skip ci] (#2182) Signed-off-by: Spencer Wilson Signed-off-by: nonam3e * liboqs 0.14.0 release (#2198) Signed-off-by: Douglas Stebila Signed-off-by: nonam3e * manual build Signed-off-by: nonam3e * remove tmp Signed-off-by: nonam3e * build statically with target_link_libraries Signed-off-by: nonam3e * Switch to dev mode for 0.14.1 (#2199) Signed-off-by: Douglas Stebila Signed-off-by: nonam3e * update ACVP to 1.1.0.40 (#2172) Signed-off-by: Abhinav Saxena Signed-off-by: nonam3e * Added Custom Timeout to CI (#2189) * Added Custom Timeout to CI Signed-off-by: Konstantinos * remove unnecessary comment Signed-off-by: Konstantinos * Use correct syntax for timeout in jobs that span multiple files Signed-off-by: Konstantinos --------- Signed-off-by: Konstantinos Signed-off-by: nonam3e * Update nixpkgs from 24.05 to 25.05 (#2187) Signed-off-by: Aiden Fox Ivey Signed-off-by: nonam3e * update commit Signed-off-by: nonam3e * icicle pqc package cmd in CONFIGURE.md Signed-off-by: nonam3e * remove unnecessary targets from cmake config Signed-off-by: nonam3e * add SPDX-License-Identifier header Signed-off-by: nonam3e --------- Signed-off-by: nonam3e Signed-off-by: Spencer Wilson Signed-off-by: Douglas Stebila Signed-off-by: Abhinav Saxena Signed-off-by: Konstantinos Signed-off-by: Aiden Fox Ivey Co-authored-by: Spencer Wilson Co-authored-by: Douglas Stebila Co-authored-by: Abhinav Saxena Co-authored-by: Kitsios Konstantinos Co-authored-by: Aiden Fox Ivey --- .CMake/alg_support.cmake | 20 +++++++++++ CMakeLists.txt | 10 ++++++ CONFIGURE.md | 27 +++++++++++++++ docs/algorithms/kem/ml_kem.md | 3 ++ docs/algorithms/kem/ml_kem.yml | 3 ++ .../add_enable_by_alg_conditional.fragment | 14 ++++++-- .../copy_from_upstream/copy_from_upstream.yml | 10 ++++++ .../src/kem/family/CMakeLists.txt | 8 ++++- .../src/kem/family/kem_scheme.c | 27 +++++++++++++-- src/CMakeLists.txt | 3 ++ src/kem/ml_kem/CMakeLists.txt | 18 ++++++++++ .../icicle_ml-kem.cpp | 33 +++++++++++++++++++ .../icicle_ml-kem.cpp | 33 +++++++++++++++++++ .../icicle_ml-kem.cpp | 33 +++++++++++++++++++ src/kem/ml_kem/kem_ml_kem_1024.c | 19 +++++++++++ src/kem/ml_kem/kem_ml_kem_512.c | 19 +++++++++++ src/kem/ml_kem/kem_ml_kem_768.c | 19 +++++++++++ src/oqsconfig.h.cmake | 4 +++ 18 files changed, 297 insertions(+), 6 deletions(-) create mode 100644 src/kem/ml_kem/icicle_ml-kem-1024_icicle_cuda/icicle_ml-kem.cpp create mode 100644 src/kem/ml_kem/icicle_ml-kem-512_icicle_cuda/icicle_ml-kem.cpp create mode 100644 src/kem/ml_kem/icicle_ml-kem-768_icicle_cuda/icicle_ml-kem.cpp diff --git a/.CMake/alg_support.cmake b/.CMake/alg_support.cmake index 51ae5eaaf..cb7cb35d4 100644 --- a/.CMake/alg_support.cmake +++ b/.CMake/alg_support.cmake @@ -33,6 +33,8 @@ function(filter_algs alglist) string(REPLACE "_avx" "" _var_base ${_var_base}) string(REPLACE "_x86_64" "" _var_base ${_var_base}) string(REPLACE "_aarch64" "" _var_base ${_var_base}) + string(REPLACE "_icicle_cuda" "" _var_base ${_var_base}) + string(REPLACE "_cuda" "" _var_base ${_var_base}) foreach (_alg ${ARGV0}) if(${_var}_AVAILABLE) if(${_var_base}X STREQUAL ${_alg}X) @@ -547,6 +549,12 @@ if(OQS_USE_CUPQC) endif() endif() +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_USE_ICICLE) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda "" ON "OQS_ENABLE_KEM_ml_kem_512" 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_POPCNT_INSTRUCTIONS)) cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768_x86_64 "" ON "OQS_ENABLE_KEM_ml_kem_768" OFF) @@ -567,6 +575,12 @@ if(OQS_USE_CUPQC) endif() endif() +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_USE_ICICLE) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda "" ON "OQS_ENABLE_KEM_ml_kem_768" 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_POPCNT_INSTRUCTIONS)) cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024_x86_64 "" ON "OQS_ENABLE_KEM_ml_kem_1024" OFF) @@ -587,6 +601,12 @@ if(OQS_USE_CUPQC) endif() endif() +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") +if(OQS_USE_ICICLE) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda "" ON "OQS_ENABLE_KEM_ml_kem_1024" OFF) +endif() +endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux") if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS)) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65fc2b49e..c3fb62722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(OQS_PERMIT_UNSUPPORTED_ARCHITECTURE "Permit compilation on an an unsuppor option(OQS_STRICT_WARNINGS "Enable all compiler warnings." OFF) option(OQS_EMBEDDED_BUILD "Compile liboqs for an Embedded environment without a full standard library." OFF) option(OQS_USE_CUPQC "Utilize cuPQC as the backend for supported PQC algorithms." OFF) +option(OQS_USE_ICICLE "Utilize ICICLE as the backend for supported PQC algorithms." OFF) # Libfuzzer isn't supported on gcc if('${CMAKE_C_COMPILER_ID}' STREQUAL 'Clang') @@ -151,6 +152,15 @@ if(${OQS_USE_CUPQC}) find_package(cuPQC 0.2.0 REQUIRED) endif() +if(OQS_USE_ICICLE) + enable_language(CXX) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + + find_package(icicle_pqc_package REQUIRED) +endif() + + if (NOT ((CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin") AND (ARCH_X86_64 STREQUAL "ON")) AND (OQS_LIBJADE_BUILD STREQUAL "ON")) message(FATAL_ERROR "Building liboqs with libjade implementations from libjade is only supported on Linux and Darwin on x86_64.") endif() diff --git a/CONFIGURE.md b/CONFIGURE.md index 417b0552d..1e6fe149e 100644 --- a/CONFIGURE.md +++ b/CONFIGURE.md @@ -14,6 +14,7 @@ The following options can be passed to CMake before the build file generation pr - [OQS_USE_CPUFEATURE_INSTRUCTIONS](#OQS_USE_CPUFEATURE_INSTRUCTIONS) - [OQS_USE_OPENSSL](#OQS_USE_OPENSSL) - [OQS_USE_CUPQC](#OQS_USE_CUPQC) +- [OQS_USE_ICICLE](#OQS_USE_ICICLE) - [OQS_OPT_TARGET](#OQS_OPT_TARGET) - [OQS_SPEED_USE_ARM_PMU](#OQS_SPEED_USE_ARM_PMU) - [USE_COVERAGE](#USE_COVERAGE) @@ -134,6 +135,32 @@ Can be `ON` or `OFF`. When `ON`, use NVIDIA's cuPQC library where able (current **Default**: `OFF` +### OQS_USE_ICICLE + +This CMake option can be set to `ON` or `OFF`. When enabled (`ON`), it configures liboqs to use ICICLE as the backend for supported post-quantum cryptographic (PQC) algorithms — currently ML-KEM. +ICICLE is a GPU-accelerated cryptographic library developed by Ingonyama. It provides CUDA-based implementations of PQC algorithms to boost the performance on systems with compatible NVIDIA GPUs. +To use ICICLE, the user needs to build and install the `icicle_pqc_package`, which contains the necessary CUDA kernels and runtime support. This package must be compiled separately before configuring liboqs with `OQS_USE_ICICLE` enabled, and its installation path should be made available to CMake. + +Enabling this option also automatically enables C++ support in CMake, as required by ICICLE’s implementations. + +To build ICICLE with the required PQC package: + +```bash +cmake -S icicle -B "$BUILD_DIR" \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ + -DCPU_BACKEND=OFF \ + -DDISABLE_ALL_FEATURES=ON \ + -DPQC=ON \ + -DCUDA_PQC_BACKEND=ON \ + -DICICLE_STATIC_LINK=ON \ + -DPQC_PACKAGE=ON +cmake --build "$BUILD_DIR" +cmake --install "$BUILD_DIR" +``` + +For full documentation, setup instructions, and backend support details, see the [Ingonyama documentation](https://dev.ingonyama.com/) + +**Default**: `OFF`. ## Stateful Hash Based Signatures diff --git a/docs/algorithms/kem/ml_kem.md b/docs/algorithms/kem/ml_kem.md index e65c9e6b4..e21bbc058 100644 --- a/docs/algorithms/kem/ml_kem.md +++ b/docs/algorithms/kem/ml_kem.md @@ -13,6 +13,9 @@ - **cupqc-cuda**: - **Source**: https://github.com/open-quantum-safe/liboqs-cupqc-meta/commit/b026f4e5475cd9c20c2082c7d9bad80e5b0ba89e - **Implementation license (SPDX-Identifier)**: Apache-2.0 + - **icicle-icicle_cuda**: + - **Source**: https://github.com/ingonyama-zk/icicle-liboqs/commit/8f215fd845928abfc2bb7d5ca15db76b839bee5c + - **Implementation license (SPDX-Identifier)**: MIT ## Parameter set summary diff --git a/docs/algorithms/kem/ml_kem.yml b/docs/algorithms/kem/ml_kem.yml index a88097338..5aa00ff02 100644 --- a/docs/algorithms/kem/ml_kem.yml +++ b/docs/algorithms/kem/ml_kem.yml @@ -23,6 +23,9 @@ optimized-upstreams: cupqc-cuda: source: https://github.com/open-quantum-safe/liboqs-cupqc-meta/commit/b026f4e5475cd9c20c2082c7d9bad80e5b0ba89e spdx-license-identifier: Apache-2.0 + icicle-icicle_cuda: + source: https://github.com/ingonyama-zk/icicle-liboqs/commit/8f215fd845928abfc2bb7d5ca15db76b839bee5c + spdx-license-identifier: MIT parameter-sets: - name: ML-KEM-512 claimed-nist-level: 1 diff --git a/scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg_conditional.fragment b/scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg_conditional.fragment index 0830c024f..23e2962de 100644 --- a/scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg_conditional.fragment +++ b/scripts/copy_from_upstream/.CMake/alg_support.cmake/add_enable_by_alg_conditional.fragment @@ -16,12 +16,22 @@ endif() {%- for platform in impl['supported_platforms'] if platform['architecture'] == 'CUDA' %} {% if platform['operating_systems'] %}if(CMAKE_SYSTEM_NAME MATCHES "{{ platform['operating_systems']|join('|') }}") {% endif -%} +{% if impl['name'] == 'cuda' -%} if(OQS_USE_CUPQC) - cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}" OFF) + cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['scheme'] }}" OFF) {%- if 'alias_scheme' in scheme %} - cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['alias_scheme'] }}" OFF) + cmake_dependent_option(OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }} "" ON "OQS_ENABLE_KEM_{{ family['name'] }}_{{ scheme['alias_scheme'] }}" OFF) {%- endif %} endif() +{% endif %} +{%- if impl['name'] == 'icicle_cuda' -%} +if(OQS_USE_ICICLE) + cmake_dependent_option(OQS_ENABLE_KEM_{{ family.name }}_{{ scheme.scheme }}_{{ impl.name }} "" ON "OQS_ENABLE_KEM_{{ family.name }}_{{ scheme.scheme }}" OFF) +{%- if scheme.alias_scheme is defined -%} + cmake_dependent_option(OQS_ENABLE_KEM_{{ family.name }}_{{ scheme.alias_scheme }}_{{ impl.name }} "" ON "OQS_ENABLE_KEM_{{ family.name }}_{{ scheme.alias_scheme }}" OFF) +{%- endif %} +endif() +{% endif -%} {% if platform['operating_systems'] %}endif() {% endif -%} {%- endfor -%} diff --git a/scripts/copy_from_upstream/copy_from_upstream.yml b/scripts/copy_from_upstream/copy_from_upstream.yml index 4f419524e..80e333fd3 100644 --- a/scripts/copy_from_upstream/copy_from_upstream.yml +++ b/scripts/copy_from_upstream/copy_from_upstream.yml @@ -46,6 +46,14 @@ upstreams: kem_meta_path: '{pretty_name_full}_META.yml' kem_scheme_path: '.' patches: [] + - + name: icicle + git_url: https://github.com/ingonyama-zk/icicle-liboqs.git + git_branch: main + git_commit: 8f215fd845928abfc2bb7d5ca15db76b839bee5c + kem_meta_path: '{pretty_name_full}_META.yml' + kem_scheme_path: '.' + patches: [] - name: pqcrystals-dilithium git_url: https://github.com/pq-crystals/dilithium.git @@ -191,8 +199,10 @@ kems: default_implementation: ref arch_specific_implementations: cuda: cuda + icicle_cuda: icicle_cuda arch_specific_upstream_locations: cuda: cupqc + icicle_cuda: icicle upstream_location: mlkem-native derandomized_keypair: true schemes: diff --git a/scripts/copy_from_upstream/src/kem/family/CMakeLists.txt b/scripts/copy_from_upstream/src/kem/family/CMakeLists.txt index e86c23830..f9ac42626 100644 --- a/scripts/copy_from_upstream/src/kem/family/CMakeLists.txt +++ b/scripts/copy_from_upstream/src/kem/family/CMakeLists.txt @@ -40,12 +40,18 @@ if(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme_c'] }}_{{ impl['name'] }}{%- if target_link_libraries({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} cupqc) set_property(TARGET {{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PROPERTY CUDA_ARCHITECTURES OFF) target_compile_options({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PRIVATE {{ impl['compile_opts'] }}) + + {%- elif impl['name'] == 'icicle_cuda' %} + +if(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme_c'] }}_{{ impl['name'] }}{%- if 'alias_scheme' in scheme %} OR OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}{%- endif %}) + add_library({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} OBJECT icicle_{{ scheme['pqclean_scheme'] }}_{{ impl['name'] }}/icicle_ml-kem.cpp) + target_link_libraries({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PRIVATE icicle::icicle_pqc_package) {%- else %} if(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme_c'] }}_{{ impl['name'] }}{%- if 'alias_scheme' in scheme %} OR OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}{%- endif %}) add_library({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} OBJECT {% for source_file in impl['sources']|sort -%}{{ impl['upstream']['name'] }}_{{ scheme['pqclean_scheme'] }}_{{ impl['name'] }}/{{ source_file }}{%- if not loop.last %} {% endif -%}{%- endfor -%}) {%- endif %} - {%- if impl['name'] != 'cuda' %} + {%- if impl['name'] != 'cuda' and impl['name'] != 'icicle_cuda' %} target_include_directories({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/{{ impl['upstream']['name'] }}_{{ scheme['pqclean_scheme'] }}_{{ impl['name'] }}) target_include_directories({{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) {%- if impl['name'] != scheme['default_implementation'] and impl['required_flags'] -%} diff --git a/scripts/copy_from_upstream/src/kem/family/kem_scheme.c b/scripts/copy_from_upstream/src/kem/family/kem_scheme.c index 256a04e75..a85bed4d5 100644 --- a/scripts/copy_from_upstream/src/kem/family/kem_scheme.c +++ b/scripts/copy_from_upstream/src/kem/family/kem_scheme.c @@ -105,6 +105,9 @@ extern int {{ scheme['metadata']['default_dec_signature'] }}(uint8_t *ss, const {% if impl['name'] == 'cuda'%} #if defined(OQS_USE_CUPQC) {%- endif %} +{%- if impl['name'] == 'icicle_cuda'%} +#if defined(OQS_USE_ICICLE) + {%- endif %} #if defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} {%- if impl['signature_keypair'] %} extern int {{ impl['signature_keypair'] }}(uint8_t *pk, uint8_t *sk); @@ -131,6 +134,9 @@ extern int PQCLEAN_{{ scheme['pqclean_scheme_c']|upper }}_{{ impl['name']|upper {%- if impl['name'] == 'cuda'%} #endif /* OQS_USE_CUPQC */ {%- endif %} + {%- if impl['name'] == 'icicle_cuda'%} +#endif /* OQS_USE_ICICLE */ + {%- endif %} {%- endfor %} {%- if libjade_implementation is defined and scheme['libjade_implementation'] %} @@ -230,7 +236,12 @@ OQS_API OQS_STATUS OQS_KEM_{{ family }}_{{ scheme['scheme'] }}_keypair(uint8_t * return (OQS_STATUS) {{ impl['signature_keypair'] }}(public_key, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ {%- endfor %} - {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda') %} + {%- for impl in scheme['metadata']['implementations'] if impl['name'] == 'icicle_cuda' %} +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) + return (OQS_STATUS) {{ impl['signature_keypair'] }}(public_key, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ + {%- endfor %} + {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda' and impl['name'] != 'icicle_cuda') %} {%- if loop.first %} #if defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} {%- else %} @@ -309,7 +320,12 @@ OQS_API OQS_STATUS OQS_KEM_{{ family }}_{{ scheme['scheme'] }}_encaps(uint8_t *c return (OQS_STATUS) {{ impl['signature_enc'] }}(ciphertext, shared_secret, public_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ {%- endfor %} - {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda') %} + {%- for impl in scheme['metadata']['implementations'] if impl['name'] == 'icicle_cuda' %} +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) + return (OQS_STATUS) {{ impl['signature_enc'] }}(ciphertext, shared_secret, public_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ + {%- endfor %} + {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda' and impl['name'] != 'icicle_cuda') %} {%- if loop.first %} #if defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} {%- else %} @@ -388,7 +404,12 @@ OQS_API OQS_STATUS OQS_KEM_{{ family }}_{{ scheme['scheme'] }}_decaps(uint8_t *s return (OQS_STATUS) {{ impl['signature_dec'] }}(shared_secret, ciphertext, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ {%- endfor %} - {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda') %} + {%- for impl in scheme['metadata']['implementations'] if impl['name'] == 'icicle_cuda' %} +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) + return (OQS_STATUS) {{ impl['signature_dec'] }}(shared_secret, ciphertext, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }} */ + {%- endfor %} + {%- for impl in scheme['metadata']['implementations'] if (impl['name'] != scheme['default_implementation'] and impl['name'] != 'cuda' and impl['name'] != 'icicle_cuda') %} {%- if loop.first %} #if defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_KEM_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} {%- else %} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e3c52078..3f0fea8ff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -117,6 +117,9 @@ if(${OQS_USE_CUPQC}) target_link_libraries(oqs PRIVATE cupqc) target_link_options(oqs PRIVATE $) endif() +if(${OQS_USE_ICICLE}) + target_link_libraries(oqs PRIVATE icicle::icicle_pqc_package) +endif() target_include_directories(oqs PUBLIC diff --git a/src/kem/ml_kem/CMakeLists.txt b/src/kem/ml_kem/CMakeLists.txt index 3fc517330..c1bd87055 100644 --- a/src/kem/ml_kem/CMakeLists.txt +++ b/src/kem/ml_kem/CMakeLists.txt @@ -39,6 +39,12 @@ if(OQS_ENABLE_KEM_ml_kem_512_cuda) set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() +if(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) + add_library(ml_kem_512_icicle_cuda OBJECT icicle_ml-kem-512_icicle_cuda/icicle_ml-kem.cpp) + target_link_libraries(ml_kem_512_icicle_cuda PRIVATE icicle::icicle_pqc_package) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +endif() + if(OQS_ENABLE_KEM_ml_kem_768) add_library(ml_kem_768_ref OBJECT kem_ml_kem_768.c mlkem-native_ml-kem-768_ref/mlkem/src/compress.c mlkem-native_ml-kem-768_ref/mlkem/src/debug.c mlkem-native_ml-kem-768_ref/mlkem/src/indcpa.c mlkem-native_ml-kem-768_ref/mlkem/src/kem.c mlkem-native_ml-kem-768_ref/mlkem/src/poly.c mlkem-native_ml-kem-768_ref/mlkem/src/poly_k.c mlkem-native_ml-kem-768_ref/mlkem/src/sampling.c mlkem-native_ml-kem-768_ref/mlkem/src/verify.c) target_compile_options(ml_kem_768_ref PUBLIC -DMLK_CONFIG_PARAMETER_SET=768 -DMLK_CONFIG_FILE="../../integration/liboqs/config_c.h") @@ -73,6 +79,12 @@ if(OQS_ENABLE_KEM_ml_kem_768_cuda) set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() +if(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) + add_library(ml_kem_768_icicle_cuda OBJECT icicle_ml-kem-768_icicle_cuda/icicle_ml-kem.cpp) + target_link_libraries(ml_kem_768_icicle_cuda PRIVATE icicle::icicle_pqc_package) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +endif() + if(OQS_ENABLE_KEM_ml_kem_1024) add_library(ml_kem_1024_ref OBJECT kem_ml_kem_1024.c mlkem-native_ml-kem-1024_ref/mlkem/src/compress.c mlkem-native_ml-kem-1024_ref/mlkem/src/debug.c mlkem-native_ml-kem-1024_ref/mlkem/src/indcpa.c mlkem-native_ml-kem-1024_ref/mlkem/src/kem.c mlkem-native_ml-kem-1024_ref/mlkem/src/poly.c mlkem-native_ml-kem-1024_ref/mlkem/src/poly_k.c mlkem-native_ml-kem-1024_ref/mlkem/src/sampling.c mlkem-native_ml-kem-1024_ref/mlkem/src/verify.c) target_compile_options(ml_kem_1024_ref PUBLIC -DMLK_CONFIG_PARAMETER_SET=1024 -DMLK_CONFIG_FILE="../../integration/liboqs/config_c.h") @@ -107,4 +119,10 @@ if(OQS_ENABLE_KEM_ml_kem_1024_cuda) set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() +if(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) + add_library(ml_kem_1024_icicle_cuda OBJECT icicle_ml-kem-1024_icicle_cuda/icicle_ml-kem.cpp) + target_link_libraries(ml_kem_1024_icicle_cuda PRIVATE icicle::icicle_pqc_package) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +endif() + set(ML_KEM_OBJS ${_ML_KEM_OBJS} PARENT_SCOPE) diff --git a/src/kem/ml_kem/icicle_ml-kem-1024_icicle_cuda/icicle_ml-kem.cpp b/src/kem/ml_kem/icicle_ml-kem-1024_icicle_cuda/icicle_ml-kem.cpp new file mode 100644 index 000000000..33b38cb1e --- /dev/null +++ b/src/kem/ml_kem/icicle_ml-kem-1024_icicle_cuda/icicle_ml-kem.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT + +#include +#include +#include "icicle/pqc/ml_kem.h" +#include "icicle/runtime.h" +#include "icicle/device.h" +#include "icicle/errors.h" + +extern "C" { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) +OQS_STATUS icicle_ml_kem_1024_keypair(uint8_t *pk, uint8_t *sk) { + uint8_t coins[icicle::pqc::ml_kem::ENTROPY_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::ENTROPY_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::keygen((std::byte*)coins, config, (std::byte*)pk, (std::byte*)sk) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_1024_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk) { + uint8_t coins[icicle::pqc::ml_kem::MESSAGE_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::MESSAGE_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::encapsulate((std::byte*)coins, (std::byte*)pk, config, (std::byte*)ct, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_1024_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk) { + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::decapsulate((std::byte*)sk, (std::byte*)ct, config, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} +#endif +} diff --git a/src/kem/ml_kem/icicle_ml-kem-512_icicle_cuda/icicle_ml-kem.cpp b/src/kem/ml_kem/icicle_ml-kem-512_icicle_cuda/icicle_ml-kem.cpp new file mode 100644 index 000000000..89c421177 --- /dev/null +++ b/src/kem/ml_kem/icicle_ml-kem-512_icicle_cuda/icicle_ml-kem.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT + +#include +#include +#include "icicle/pqc/ml_kem.h" +#include "icicle/runtime.h" +#include "icicle/device.h" +#include "icicle/errors.h" + +extern "C" { +#if defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) +OQS_STATUS icicle_ml_kem_512_keypair(uint8_t *pk, uint8_t *sk) { + uint8_t coins[icicle::pqc::ml_kem::ENTROPY_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::ENTROPY_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::keygen((std::byte*)coins, config, (std::byte*)pk, (std::byte*)sk) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_512_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk) { + uint8_t coins[icicle::pqc::ml_kem::MESSAGE_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::MESSAGE_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::encapsulate((std::byte*)coins, (std::byte*)pk, config, (std::byte*)ct, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_512_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk) { + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::decapsulate((std::byte*)sk, (std::byte*)ct, config, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} +#endif +} diff --git a/src/kem/ml_kem/icicle_ml-kem-768_icicle_cuda/icicle_ml-kem.cpp b/src/kem/ml_kem/icicle_ml-kem-768_icicle_cuda/icicle_ml-kem.cpp new file mode 100644 index 000000000..33b38cb1e --- /dev/null +++ b/src/kem/ml_kem/icicle_ml-kem-768_icicle_cuda/icicle_ml-kem.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT + +#include +#include +#include "icicle/pqc/ml_kem.h" +#include "icicle/runtime.h" +#include "icicle/device.h" +#include "icicle/errors.h" + +extern "C" { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) +OQS_STATUS icicle_ml_kem_1024_keypair(uint8_t *pk, uint8_t *sk) { + uint8_t coins[icicle::pqc::ml_kem::ENTROPY_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::ENTROPY_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::keygen((std::byte*)coins, config, (std::byte*)pk, (std::byte*)sk) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_1024_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk) { + uint8_t coins[icicle::pqc::ml_kem::MESSAGE_BYTES]; + OQS_randombytes(coins, icicle::pqc::ml_kem::MESSAGE_BYTES); + + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::encapsulate((std::byte*)coins, (std::byte*)pk, config, (std::byte*)ct, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} + +OQS_STATUS icicle_ml_kem_1024_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk) { + icicle::pqc::ml_kem::MlKemConfig config; + return icicle::pqc::ml_kem::decapsulate((std::byte*)sk, (std::byte*)ct, config, (std::byte*)ss) == icicle::eIcicleError::SUCCESS ? OQS_SUCCESS : OQS_ERROR; +} +#endif +} diff --git a/src/kem/ml_kem/kem_ml_kem_1024.c b/src/kem/ml_kem/kem_ml_kem_1024.c index 9924c6fbe..58e6c1878 100644 --- a/src/kem/ml_kem/kem_ml_kem_1024.c +++ b/src/kem/ml_kem/kem_ml_kem_1024.c @@ -59,6 +59,14 @@ extern int cupqc_ml_kem_1024_dec(uint8_t *ss, const uint8_t *ct, const uint8_t * #endif #endif /* OQS_USE_CUPQC */ +#if defined(OQS_USE_ICICLE) +#if defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) +extern int icicle_ml_kem_1024_keypair(uint8_t *pk, uint8_t *sk); +extern int icicle_ml_kem_1024_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); +extern int icicle_ml_kem_1024_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); +#endif +#endif /* OQS_USE_ICICLE */ + OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *seed) { #if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) #if defined(OQS_DIST_BUILD) @@ -82,6 +90,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair_derand(uint8_t *public_key, uint8 #endif /* OQS_DIST_BUILD */ #elif defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) PQCLEAN_MLKEM1024_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); +#elif defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM1024_ICICLE_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); #else return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM1024_C_keypair_derand(public_key, secret_key, seed); #endif @@ -91,6 +101,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *sec #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) cupqc_ml_kem_1024_keypair(public_key, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_1024_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_1024_keypair(public_key, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) #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_POPCNT)) { @@ -120,6 +133,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps(uint8_t *ciphertext, uint8_t *shar #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) cupqc_ml_kem_1024_enc(ciphertext, shared_secret, public_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_1024_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_1024_enc(ciphertext, shared_secret, public_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) #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_POPCNT)) { @@ -149,6 +165,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_decaps(uint8_t *shared_secret, const uint #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_1024_cuda) return (OQS_STATUS) cupqc_ml_kem_1024_dec(shared_secret, ciphertext, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_1024_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_1024_dec(shared_secret, ciphertext, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_1024_x86_64) #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_POPCNT)) { diff --git a/src/kem/ml_kem/kem_ml_kem_512.c b/src/kem/ml_kem/kem_ml_kem_512.c index 5e2d14ced..757e739fe 100644 --- a/src/kem/ml_kem/kem_ml_kem_512.c +++ b/src/kem/ml_kem/kem_ml_kem_512.c @@ -59,6 +59,14 @@ extern int cupqc_ml_kem_512_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *s #endif #endif /* OQS_USE_CUPQC */ +#if defined(OQS_USE_ICICLE) +#if defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) +extern int icicle_ml_kem_512_keypair(uint8_t *pk, uint8_t *sk); +extern int icicle_ml_kem_512_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); +extern int icicle_ml_kem_512_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); +#endif +#endif /* OQS_USE_ICICLE */ + OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *seed) { #if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) #if defined(OQS_DIST_BUILD) @@ -82,6 +90,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair_derand(uint8_t *public_key, uint8_ #endif /* OQS_DIST_BUILD */ #elif defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) PQCLEAN_MLKEM512_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); +#elif defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM512_ICICLE_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); #else return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM512_C_keypair_derand(public_key, secret_key, seed); #endif @@ -91,6 +101,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secr #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) cupqc_ml_kem_512_keypair(public_key, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_512_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_512_keypair(public_key, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_512_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) #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_POPCNT)) { @@ -120,6 +133,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps(uint8_t *ciphertext, uint8_t *share #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) cupqc_ml_kem_512_enc(ciphertext, shared_secret, public_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_512_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_512_enc(ciphertext, shared_secret, public_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_512_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) #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_POPCNT)) { @@ -149,6 +165,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_decaps(uint8_t *shared_secret, const uint8 #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_512_cuda) return (OQS_STATUS) cupqc_ml_kem_512_dec(shared_secret, ciphertext, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_512_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_512_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_512_dec(shared_secret, ciphertext, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_512_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_512_x86_64) #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_POPCNT)) { diff --git a/src/kem/ml_kem/kem_ml_kem_768.c b/src/kem/ml_kem/kem_ml_kem_768.c index ae506edbb..3e9e7d2b8 100644 --- a/src/kem/ml_kem/kem_ml_kem_768.c +++ b/src/kem/ml_kem/kem_ml_kem_768.c @@ -59,6 +59,14 @@ extern int cupqc_ml_kem_768_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *s #endif #endif /* OQS_USE_CUPQC */ +#if defined(OQS_USE_ICICLE) +#if defined(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) +extern int icicle_ml_kem_768_keypair(uint8_t *pk, uint8_t *sk); +extern int icicle_ml_kem_768_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); +extern int icicle_ml_kem_768_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); +#endif +#endif /* OQS_USE_ICICLE */ + OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair_derand(uint8_t *public_key, uint8_t *secret_key, const uint8_t *seed) { #if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) #if defined(OQS_DIST_BUILD) @@ -82,6 +90,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair_derand(uint8_t *public_key, uint8_ #endif /* OQS_DIST_BUILD */ #elif defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) PQCLEAN_MLKEM768_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); +#elif defined(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) + return (OQS_STATUS) PQCLEAN_MLKEM768_ICICLE_CUDA_crypto_kem_keypair_derand(public_key, secret_key, seed); #else return (OQS_STATUS) PQCP_MLKEM_NATIVE_MLKEM768_C_keypair_derand(public_key, secret_key, seed); #endif @@ -91,6 +101,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secr #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) cupqc_ml_kem_768_keypair(public_key, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_768_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_768_keypair(public_key, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_768_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) #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_POPCNT)) { @@ -120,6 +133,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps(uint8_t *ciphertext, uint8_t *share #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) cupqc_ml_kem_768_enc(ciphertext, shared_secret, public_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_768_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_768_enc(ciphertext, shared_secret, public_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_768_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) #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_POPCNT)) { @@ -149,6 +165,9 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_decaps(uint8_t *shared_secret, const uint8 #if defined(OQS_USE_CUPQC) && defined(OQS_ENABLE_KEM_ml_kem_768_cuda) return (OQS_STATUS) cupqc_ml_kem_768_dec(shared_secret, ciphertext, secret_key); #endif /* OQS_USE_CUPQC && OQS_ENABLE_KEM_ml_kem_768_cuda */ +#if defined(OQS_USE_ICICLE) && defined(OQS_ENABLE_KEM_ml_kem_768_icicle_cuda) + return (OQS_STATUS) icicle_ml_kem_768_dec(shared_secret, ciphertext, secret_key); +#endif /* OQS_USE_ICICLE && OQS_ENABLE_KEM_ml_kem_768_icicle_cuda */ #if defined(OQS_ENABLE_KEM_ml_kem_768_x86_64) #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_POPCNT)) { diff --git a/src/oqsconfig.h.cmake b/src/oqsconfig.h.cmake index 8fc996bdf..16e6e181c 100644 --- a/src/oqsconfig.h.cmake +++ b/src/oqsconfig.h.cmake @@ -72,6 +72,7 @@ #cmakedefine OQS_USE_SHA3_AVX512VL 1 #cmakedefine01 OQS_USE_CUPQC +#cmakedefine01 OQS_USE_ICICLE #cmakedefine OQS_ENABLE_KEM_BIKE 1 #cmakedefine OQS_ENABLE_KEM_bike_l1 1 @@ -135,14 +136,17 @@ #cmakedefine OQS_ENABLE_KEM_ml_kem_512_x86_64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_512_aarch64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_512_cuda 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_512_icicle_cuda 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_768 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_768_x86_64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_768_aarch64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_768_cuda 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_768_icicle_cuda 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_1024 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_1024_x86_64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_1024_aarch64 1 #cmakedefine OQS_ENABLE_KEM_ml_kem_1024_cuda 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_1024_icicle_cuda 1 #cmakedefine OQS_ENABLE_SIG_DILITHIUM 1 #cmakedefine OQS_ENABLE_SIG_dilithium_2 1