diff --git a/.CMake/alg_support.cmake b/.CMake/alg_support.cmake index 49a328c8e5..0994ed4c30 100644 --- a/.CMake/alg_support.cmake +++ b/.CMake/alg_support.cmake @@ -233,24 +233,24 @@ endif() option(OQS_ENABLE_KEM_ML_KEM "Enable ml_kem algorithm family" ON) -cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_512 "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) +cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_512_ipd "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) 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_512_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_512" OFF) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_512_ipd_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_512_ipd" OFF) endif() endif() -cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768 "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) +cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768_ipd "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) 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_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_768" OFF) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_768_ipd_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_768_ipd" OFF) endif() endif() -cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024 "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) +cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024_ipd "" ON "OQS_ENABLE_KEM_ML_KEM" OFF) 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_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_1024" OFF) + cmake_dependent_option(OQS_ENABLE_KEM_ml_kem_1024_ipd_avx2 "" ON "OQS_ENABLE_KEM_ml_kem_1024_ipd" OFF) endif() endif() @@ -297,24 +297,24 @@ endif() option(OQS_ENABLE_SIG_ML_DSA "Enable ml_dsa algorithm family" ON) -cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_44 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_44_ipd "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux") if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS)) - cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_44_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_44" OFF) + cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_44_ipd_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_44_ipd" OFF) endif() endif() -cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_65 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_65_ipd "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux") if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS)) - cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_65_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_65" OFF) + cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_65_ipd_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_65_ipd" OFF) endif() endif() -cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_87 "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) +cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_87_ipd "" ON "OQS_ENABLE_SIG_ML_DSA" OFF) if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux") if(OQS_DIST_X86_64_BUILD OR (OQS_USE_AVX2_INSTRUCTIONS AND OQS_USE_POPCNT_INSTRUCTIONS)) - cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_87_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_87" OFF) + cmake_dependent_option(OQS_ENABLE_SIG_ml_dsa_87_ipd_avx2 "" ON "OQS_ENABLE_SIG_ml_dsa_87_ipd" OFF) endif() endif() @@ -442,7 +442,7 @@ if(NOT ((OQS_MINIMAL_BUILD STREQUAL "") OR (OQS_MINIMAL_BUILD STREQUAL "OFF"))) filter_algs("${OQS_MINIMAL_BUILD}") elseif (${OQS_ALGS_ENABLED} STREQUAL "STD") ##### OQS_COPY_FROM_UPSTREAM_FRAGMENT_LIST_STANDARDIZED_ALGS_START - filter_algs("KEM_kyber_512;KEM_kyber_768;KEM_kyber_1024;KEM_ml_kem_512;KEM_ml_kem_768;KEM_ml_kem_1024;SIG_dilithium_2;SIG_dilithium_3;SIG_dilithium_5;SIG_ml_dsa_44;SIG_ml_dsa_65;SIG_ml_dsa_87;SIG_falcon_512;SIG_falcon_1024;SIG_sphincs_sha2_128f_simple;SIG_sphincs_sha2_128s_simple;SIG_sphincs_sha2_192f_simple;SIG_sphincs_sha2_192s_simple;SIG_sphincs_sha2_256f_simple;SIG_sphincs_sha2_256s_simple;SIG_sphincs_shake_128f_simple;SIG_sphincs_shake_128s_simple;SIG_sphincs_shake_192f_simple;SIG_sphincs_shake_192s_simple;SIG_sphincs_shake_256f_simple;SIG_sphincs_shake_256s_simple") + filter_algs("KEM_kyber_512;KEM_kyber_768;KEM_kyber_1024;KEM_ml_kem_512_ipd;KEM_ml_kem_768_ipd;KEM_ml_kem_1024_ipd;SIG_dilithium_2;SIG_dilithium_3;SIG_dilithium_5;SIG_ml_dsa_44_ipd;SIG_ml_dsa_65_ipd;SIG_ml_dsa_87_ipd;SIG_falcon_512;SIG_falcon_1024;SIG_sphincs_sha2_128f_simple;SIG_sphincs_sha2_128s_simple;SIG_sphincs_sha2_192f_simple;SIG_sphincs_sha2_192s_simple;SIG_sphincs_sha2_256f_simple;SIG_sphincs_sha2_256s_simple;SIG_sphincs_shake_128f_simple;SIG_sphincs_shake_128s_simple;SIG_sphincs_shake_192f_simple;SIG_sphincs_shake_192s_simple;SIG_sphincs_shake_256f_simple;SIG_sphincs_shake_256s_simple") ##### OQS_COPY_FROM_UPSTREAM_FRAGMENT_LIST_STANDARDIZED_ALGS_END elseif(${OQS_ALGS_ENABLED} STREQUAL "NIST_R4") filter_algs("KEM_classic_mceliece_348864;KEM_classic_mceliece_348864f;KEM_classic_mceliece_460896;KEM_classic_mceliece_460896f;KEM_classic_mceliece_6688128;KEM_classic_mceliece_6688128f;KEM_classic_mceliece_6960119;KEM_classic_mceliece_6960119f;KEM_classic_mceliece_8192128;KEM_classic_mceliece_8192128f;KEM_hqc_128;KEM_hqc_192;KEM_hqc_256;KEM_bike_l1;KEM_bike_l3") diff --git a/scripts/copy_from_upstream/copy_from_upstream.yml b/scripts/copy_from_upstream/copy_from_upstream.yml index a314894f9a..21503f4f85 100644 --- a/scripts/copy_from_upstream/copy_from_upstream.yml +++ b/scripts/copy_from_upstream/copy_from_upstream.yml @@ -143,15 +143,15 @@ kems: upstream_location: pqcrystals-kyber-standard schemes: - - scheme: "512" + scheme: "512_ipd" pqclean_scheme: ml-kem-512-ipd pretty_name_full: ML-KEM-512-ipd - - scheme: "768" + scheme: "768_ipd" pqclean_scheme: ml-kem-768-ipd pretty_name_full: ML-KEM-768-ipd - - scheme: "1024" + scheme: "1024_ipd" pqclean_scheme: ml-kem-1024-ipd pretty_name_full: ML-KEM-1024-ipd sigs: @@ -185,17 +185,17 @@ sigs: upstream_location: pqcrystals-dilithium-standard schemes: - - scheme: "44" + scheme: "44_ipd" pqclean_scheme: ml-dsa-44-ipd pretty_name_full: ML-DSA-44-ipd signed_msg_order: sig_then_msg - - scheme: "65" + scheme: "65_ipd" pqclean_scheme: ml-dsa-65-ipd pretty_name_full: ML-DSA-65-ipd signed_msg_order: sig_then_msg - - scheme: "87" + scheme: "87_ipd" pqclean_scheme: ml-dsa-87-ipd pretty_name_full: ML-DSA-87-ipd signed_msg_order: sig_then_msg diff --git a/src/kem/kem.c b/src/kem/kem.c index 2498e73bf3..91c5c52c73 100644 --- a/src/kem/kem.c +++ b/src/kem/kem.c @@ -34,9 +34,9 @@ OQS_API const char *OQS_KEM_alg_identifier(size_t i) { OQS_KEM_alg_kyber_512, OQS_KEM_alg_kyber_768, OQS_KEM_alg_kyber_1024, - OQS_KEM_alg_ml_kem_512, - OQS_KEM_alg_ml_kem_768, - OQS_KEM_alg_ml_kem_1024, + OQS_KEM_alg_ml_kem_512_ipd, + OQS_KEM_alg_ml_kem_768_ipd, + OQS_KEM_alg_ml_kem_1024_ipd, ///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALG_IDENTIFIER_END OQS_KEM_alg_ntruprime_sntrup761, OQS_KEM_alg_frodokem_640_aes, @@ -175,20 +175,20 @@ OQS_API int OQS_KEM_alg_is_enabled(const char *method_name) { #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_512)) { -#ifdef OQS_ENABLE_KEM_ml_kem_512 + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_512_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_512_ipd return 1; #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_768)) { -#ifdef OQS_ENABLE_KEM_ml_kem_768 + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_768_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_768_ipd return 1; #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_1024)) { -#ifdef OQS_ENABLE_KEM_ml_kem_1024 + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_1024_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_1024_ipd return 1; #else return 0; @@ -361,21 +361,21 @@ OQS_API OQS_KEM *OQS_KEM_new(const char *method_name) { #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_512)) { -#ifdef OQS_ENABLE_KEM_ml_kem_512 - return OQS_KEM_ml_kem_512_new(); + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_512_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_512_ipd + return OQS_KEM_ml_kem_512_ipd_new(); #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_768)) { -#ifdef OQS_ENABLE_KEM_ml_kem_768 - return OQS_KEM_ml_kem_768_new(); + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_768_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_768_ipd + return OQS_KEM_ml_kem_768_ipd_new(); #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_1024)) { -#ifdef OQS_ENABLE_KEM_ml_kem_1024 - return OQS_KEM_ml_kem_1024_new(); + } else if (0 == strcasecmp(method_name, OQS_KEM_alg_ml_kem_1024_ipd)) { +#ifdef OQS_ENABLE_KEM_ml_kem_1024_ipd + return OQS_KEM_ml_kem_1024_ipd_new(); #else return NULL; #endif diff --git a/src/kem/kem.h b/src/kem/kem.h index 4fd5e57b15..8bac2cf266 100644 --- a/src/kem/kem.h +++ b/src/kem/kem.h @@ -71,11 +71,11 @@ extern "C" { /** Algorithm identifier for Kyber1024 KEM. */ #define OQS_KEM_alg_kyber_1024 "Kyber1024" /** Algorithm identifier for ML-KEM-512-ipd KEM. */ -#define OQS_KEM_alg_ml_kem_512 "ML-KEM-512-ipd" +#define OQS_KEM_alg_ml_kem_512_ipd "ML-KEM-512-ipd" /** Algorithm identifier for ML-KEM-768-ipd KEM. */ -#define OQS_KEM_alg_ml_kem_768 "ML-KEM-768-ipd" +#define OQS_KEM_alg_ml_kem_768_ipd "ML-KEM-768-ipd" /** Algorithm identifier for ML-KEM-1024-ipd KEM. */ -#define OQS_KEM_alg_ml_kem_1024 "ML-KEM-1024-ipd" +#define OQS_KEM_alg_ml_kem_1024_ipd "ML-KEM-1024-ipd" ///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALG_IDENTIFIER_END /** Algorithm identifier for sntrup761 KEM. */ #define OQS_KEM_alg_ntruprime_sntrup761 "sntrup761" diff --git a/src/kem/ml_kem/CMakeLists.txt b/src/kem/ml_kem/CMakeLists.txt index d3c7d8f3e3..a5890ab9ce 100644 --- a/src/kem/ml_kem/CMakeLists.txt +++ b/src/kem/ml_kem/CMakeLists.txt @@ -5,58 +5,58 @@ set(_ML_KEM_OBJS "") -if(OQS_ENABLE_KEM_ml_kem_512) - add_library(ml_kem_512_ref OBJECT kem_ml_kem_512.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/verify.c) - target_compile_options(ml_kem_512_ref PUBLIC -DKYBER_K=2) - target_include_directories(ml_kem_512_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-512-ipd_ref) - target_include_directories(ml_kem_512_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_512_ref PUBLIC -DKYBER_K=2) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_512_ipd) + add_library(ml_kem_512_ipd_ref OBJECT kem_ml_kem_512_ipd.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-512-ipd_ref/verify.c) + target_compile_options(ml_kem_512_ipd_ref PUBLIC -DKYBER_K=2) + target_include_directories(ml_kem_512_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-512-ipd_ref) + target_include_directories(ml_kem_512_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_512_ipd_ref PUBLIC -DKYBER_K=2) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() -if(OQS_ENABLE_KEM_ml_kem_512_avx2) - add_library(ml_kem_512_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/verify.c) - target_include_directories(ml_kem_512_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-512-ipd_avx2) - target_include_directories(ml_kem_512_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_512_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) - target_compile_options(ml_kem_512_avx2 PUBLIC -DKYBER_K=2) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_512_ipd_avx2) + add_library(ml_kem_512_ipd_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-512-ipd_avx2/verify.c) + target_include_directories(ml_kem_512_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-512-ipd_avx2) + target_include_directories(ml_kem_512_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_512_ipd_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) + target_compile_options(ml_kem_512_ipd_avx2 PUBLIC -DKYBER_K=2) + 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 pqcrystals-kyber-standard_ml-kem-768-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/verify.c) - target_compile_options(ml_kem_768_ref PUBLIC -DKYBER_K=3) - target_include_directories(ml_kem_768_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-768-ipd_ref) - target_include_directories(ml_kem_768_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_768_ref PUBLIC -DKYBER_K=3) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_768_ipd) + add_library(ml_kem_768_ipd_ref OBJECT kem_ml_kem_768_ipd.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-768-ipd_ref/verify.c) + target_compile_options(ml_kem_768_ipd_ref PUBLIC -DKYBER_K=3) + target_include_directories(ml_kem_768_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-768-ipd_ref) + target_include_directories(ml_kem_768_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_768_ipd_ref PUBLIC -DKYBER_K=3) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() -if(OQS_ENABLE_KEM_ml_kem_768_avx2) - add_library(ml_kem_768_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/verify.c) - target_include_directories(ml_kem_768_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-768-ipd_avx2) - target_include_directories(ml_kem_768_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_768_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) - target_compile_options(ml_kem_768_avx2 PUBLIC -DKYBER_K=3) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_768_ipd_avx2) + add_library(ml_kem_768_ipd_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-768-ipd_avx2/verify.c) + target_include_directories(ml_kem_768_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-768-ipd_avx2) + target_include_directories(ml_kem_768_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_768_ipd_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) + target_compile_options(ml_kem_768_ipd_avx2 PUBLIC -DKYBER_K=3) + 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 pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/verify.c) - target_compile_options(ml_kem_1024_ref PUBLIC -DKYBER_K=4) - target_include_directories(ml_kem_1024_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-1024-ipd_ref) - target_include_directories(ml_kem_1024_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_1024_ref PUBLIC -DKYBER_K=4) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_1024_ipd) + add_library(ml_kem_1024_ipd_ref OBJECT kem_ml_kem_1024_ipd.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/cbd.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/indcpa.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/kem.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/ntt.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/poly.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/polyvec.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/reduce.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-1024-ipd_ref/verify.c) + target_compile_options(ml_kem_1024_ipd_ref PUBLIC -DKYBER_K=4) + target_include_directories(ml_kem_1024_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-1024-ipd_ref) + target_include_directories(ml_kem_1024_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_1024_ipd_ref PUBLIC -DKYBER_K=4) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() -if(OQS_ENABLE_KEM_ml_kem_1024_avx2) - add_library(ml_kem_1024_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/verify.c) - target_include_directories(ml_kem_1024_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2) - target_include_directories(ml_kem_1024_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_kem_1024_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) - target_compile_options(ml_kem_1024_avx2 PUBLIC -DKYBER_K=4) - set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) +if(OQS_ENABLE_KEM_ml_kem_1024_ipd_avx2) + add_library(ml_kem_1024_ipd_avx2 OBJECT pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/basemul.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/cbd.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/consts.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/fq.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/indcpa.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/invntt.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/kem.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/ntt.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/poly.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/polyvec.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/rejsample.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/shuffle.S pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/symmetric-shake.c pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2/verify.c) + target_include_directories(ml_kem_1024_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-kyber-standard_ml-kem-1024-ipd_avx2) + target_include_directories(ml_kem_1024_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_kem_1024_ipd_avx2 PRIVATE -mavx2 -mbmi2 -mpopcnt ) + target_compile_options(ml_kem_1024_ipd_avx2 PUBLIC -DKYBER_K=4) + set(_ML_KEM_OBJS ${_ML_KEM_OBJS} $) endif() set(ML_KEM_OBJS ${_ML_KEM_OBJS} PARENT_SCOPE) diff --git a/src/kem/ml_kem/kem_ml_kem.h b/src/kem/ml_kem/kem_ml_kem.h index 77d7e14359..cfe9d2f862 100644 --- a/src/kem/ml_kem/kem_ml_kem.h +++ b/src/kem/ml_kem/kem_ml_kem.h @@ -5,37 +5,37 @@ #include -#ifdef OQS_ENABLE_KEM_ml_kem_512 -#define OQS_KEM_ml_kem_512_length_public_key 800 -#define OQS_KEM_ml_kem_512_length_secret_key 1632 -#define OQS_KEM_ml_kem_512_length_ciphertext 768 -#define OQS_KEM_ml_kem_512_length_shared_secret 32 -OQS_KEM *OQS_KEM_ml_kem_512_new(void); -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); +#ifdef OQS_ENABLE_KEM_ml_kem_512_ipd +#define OQS_KEM_ml_kem_512_ipd_length_public_key 800 +#define OQS_KEM_ml_kem_512_ipd_length_secret_key 1632 +#define OQS_KEM_ml_kem_512_ipd_length_ciphertext 768 +#define OQS_KEM_ml_kem_512_ipd_length_shared_secret 32 +OQS_KEM *OQS_KEM_ml_kem_512_ipd_new(void); +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); #endif -#ifdef OQS_ENABLE_KEM_ml_kem_768 -#define OQS_KEM_ml_kem_768_length_public_key 1184 -#define OQS_KEM_ml_kem_768_length_secret_key 2400 -#define OQS_KEM_ml_kem_768_length_ciphertext 1088 -#define OQS_KEM_ml_kem_768_length_shared_secret 32 -OQS_KEM *OQS_KEM_ml_kem_768_new(void); -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); +#ifdef OQS_ENABLE_KEM_ml_kem_768_ipd +#define OQS_KEM_ml_kem_768_ipd_length_public_key 1184 +#define OQS_KEM_ml_kem_768_ipd_length_secret_key 2400 +#define OQS_KEM_ml_kem_768_ipd_length_ciphertext 1088 +#define OQS_KEM_ml_kem_768_ipd_length_shared_secret 32 +OQS_KEM *OQS_KEM_ml_kem_768_ipd_new(void); +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); #endif -#ifdef OQS_ENABLE_KEM_ml_kem_1024 -#define OQS_KEM_ml_kem_1024_length_public_key 1568 -#define OQS_KEM_ml_kem_1024_length_secret_key 3168 -#define OQS_KEM_ml_kem_1024_length_ciphertext 1568 -#define OQS_KEM_ml_kem_1024_length_shared_secret 32 -OQS_KEM *OQS_KEM_ml_kem_1024_new(void); -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); +#ifdef OQS_ENABLE_KEM_ml_kem_1024_ipd +#define OQS_KEM_ml_kem_1024_ipd_length_public_key 1568 +#define OQS_KEM_ml_kem_1024_ipd_length_secret_key 3168 +#define OQS_KEM_ml_kem_1024_ipd_length_ciphertext 1568 +#define OQS_KEM_ml_kem_1024_ipd_length_shared_secret 32 +OQS_KEM *OQS_KEM_ml_kem_1024_ipd_new(void); +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key); #endif #endif diff --git a/src/kem/ml_kem/kem_ml_kem_1024.c b/src/kem/ml_kem/kem_ml_kem_1024_ipd.c similarity index 69% rename from src/kem/ml_kem/kem_ml_kem_1024.c rename to src/kem/ml_kem/kem_ml_kem_1024_ipd.c index 64aae5db07..8ac972eb74 100644 --- a/src/kem/ml_kem/kem_ml_kem_1024.c +++ b/src/kem/ml_kem/kem_ml_kem_1024_ipd.c @@ -4,28 +4,28 @@ #include -#if defined(OQS_ENABLE_KEM_ml_kem_1024) +#if defined(OQS_ENABLE_KEM_ml_kem_1024_ipd) -OQS_KEM *OQS_KEM_ml_kem_1024_new(void) { +OQS_KEM *OQS_KEM_ml_kem_1024_ipd_new(void) { OQS_KEM *kem = malloc(sizeof(OQS_KEM)); if (kem == NULL) { return NULL; } - kem->method_name = OQS_KEM_alg_ml_kem_1024; + kem->method_name = OQS_KEM_alg_ml_kem_1024_ipd; kem->alg_version = "https://github.com/pq-crystals/kyber/tree/standard"; kem->claimed_nist_level = 5; kem->ind_cca = true; - kem->length_public_key = OQS_KEM_ml_kem_1024_length_public_key; - kem->length_secret_key = OQS_KEM_ml_kem_1024_length_secret_key; - kem->length_ciphertext = OQS_KEM_ml_kem_1024_length_ciphertext; - kem->length_shared_secret = OQS_KEM_ml_kem_1024_length_shared_secret; + kem->length_public_key = OQS_KEM_ml_kem_1024_ipd_length_public_key; + kem->length_secret_key = OQS_KEM_ml_kem_1024_ipd_length_secret_key; + kem->length_ciphertext = OQS_KEM_ml_kem_1024_ipd_length_ciphertext; + kem->length_shared_secret = OQS_KEM_ml_kem_1024_ipd_length_shared_secret; - kem->keypair = OQS_KEM_ml_kem_1024_keypair; - kem->encaps = OQS_KEM_ml_kem_1024_encaps; - kem->decaps = OQS_KEM_ml_kem_1024_decaps; + kem->keypair = OQS_KEM_ml_kem_1024_ipd_keypair; + kem->encaps = OQS_KEM_ml_kem_1024_ipd_encaps; + kem->decaps = OQS_KEM_ml_kem_1024_ipd_decaps; return kem; } @@ -34,14 +34,14 @@ extern int pqcrystals_ml_kem_1024_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_1024_ipd_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_1024_ipd_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); -#if defined(OQS_ENABLE_KEM_ml_kem_1024_avx2) +#if defined(OQS_ENABLE_KEM_ml_kem_1024_ipd_avx2) extern int pqcrystals_ml_kem_1024_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_1024_ipd_avx2_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_1024_ipd_avx2_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_1024_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -56,8 +56,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_keypair(uint8_t *public_key, uint8_t *sec #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_1024_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -72,8 +72,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_encaps(uint8_t *ciphertext, uint8_t *shar #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_1024_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_1024_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_1024_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/kem/ml_kem/kem_ml_kem_512.c b/src/kem/ml_kem/kem_ml_kem_512_ipd.c similarity index 69% rename from src/kem/ml_kem/kem_ml_kem_512.c rename to src/kem/ml_kem/kem_ml_kem_512_ipd.c index f1623ada1f..e08728a333 100644 --- a/src/kem/ml_kem/kem_ml_kem_512.c +++ b/src/kem/ml_kem/kem_ml_kem_512_ipd.c @@ -4,28 +4,28 @@ #include -#if defined(OQS_ENABLE_KEM_ml_kem_512) +#if defined(OQS_ENABLE_KEM_ml_kem_512_ipd) -OQS_KEM *OQS_KEM_ml_kem_512_new(void) { +OQS_KEM *OQS_KEM_ml_kem_512_ipd_new(void) { OQS_KEM *kem = malloc(sizeof(OQS_KEM)); if (kem == NULL) { return NULL; } - kem->method_name = OQS_KEM_alg_ml_kem_512; + kem->method_name = OQS_KEM_alg_ml_kem_512_ipd; kem->alg_version = "https://github.com/pq-crystals/kyber/tree/standard"; kem->claimed_nist_level = 1; kem->ind_cca = true; - kem->length_public_key = OQS_KEM_ml_kem_512_length_public_key; - kem->length_secret_key = OQS_KEM_ml_kem_512_length_secret_key; - kem->length_ciphertext = OQS_KEM_ml_kem_512_length_ciphertext; - kem->length_shared_secret = OQS_KEM_ml_kem_512_length_shared_secret; + kem->length_public_key = OQS_KEM_ml_kem_512_ipd_length_public_key; + kem->length_secret_key = OQS_KEM_ml_kem_512_ipd_length_secret_key; + kem->length_ciphertext = OQS_KEM_ml_kem_512_ipd_length_ciphertext; + kem->length_shared_secret = OQS_KEM_ml_kem_512_ipd_length_shared_secret; - kem->keypair = OQS_KEM_ml_kem_512_keypair; - kem->encaps = OQS_KEM_ml_kem_512_encaps; - kem->decaps = OQS_KEM_ml_kem_512_decaps; + kem->keypair = OQS_KEM_ml_kem_512_ipd_keypair; + kem->encaps = OQS_KEM_ml_kem_512_ipd_encaps; + kem->decaps = OQS_KEM_ml_kem_512_ipd_decaps; return kem; } @@ -34,14 +34,14 @@ extern int pqcrystals_ml_kem_512_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_512_ipd_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_512_ipd_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); -#if defined(OQS_ENABLE_KEM_ml_kem_512_avx2) +#if defined(OQS_ENABLE_KEM_ml_kem_512_ipd_avx2) extern int pqcrystals_ml_kem_512_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_512_ipd_avx2_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_512_ipd_avx2_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_512_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_512_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -56,8 +56,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_keypair(uint8_t *public_key, uint8_t *secr #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_512_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_512_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -72,8 +72,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_512_encaps(uint8_t *ciphertext, uint8_t *share #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_512_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_512_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_512_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_512_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/kem/ml_kem/kem_ml_kem_768.c b/src/kem/ml_kem/kem_ml_kem_768_ipd.c similarity index 69% rename from src/kem/ml_kem/kem_ml_kem_768.c rename to src/kem/ml_kem/kem_ml_kem_768_ipd.c index bdce1aca2f..9e44e0ff14 100644 --- a/src/kem/ml_kem/kem_ml_kem_768.c +++ b/src/kem/ml_kem/kem_ml_kem_768_ipd.c @@ -4,28 +4,28 @@ #include -#if defined(OQS_ENABLE_KEM_ml_kem_768) +#if defined(OQS_ENABLE_KEM_ml_kem_768_ipd) -OQS_KEM *OQS_KEM_ml_kem_768_new(void) { +OQS_KEM *OQS_KEM_ml_kem_768_ipd_new(void) { OQS_KEM *kem = malloc(sizeof(OQS_KEM)); if (kem == NULL) { return NULL; } - kem->method_name = OQS_KEM_alg_ml_kem_768; + kem->method_name = OQS_KEM_alg_ml_kem_768_ipd; kem->alg_version = "https://github.com/pq-crystals/kyber/tree/standard"; kem->claimed_nist_level = 3; kem->ind_cca = true; - kem->length_public_key = OQS_KEM_ml_kem_768_length_public_key; - kem->length_secret_key = OQS_KEM_ml_kem_768_length_secret_key; - kem->length_ciphertext = OQS_KEM_ml_kem_768_length_ciphertext; - kem->length_shared_secret = OQS_KEM_ml_kem_768_length_shared_secret; + kem->length_public_key = OQS_KEM_ml_kem_768_ipd_length_public_key; + kem->length_secret_key = OQS_KEM_ml_kem_768_ipd_length_secret_key; + kem->length_ciphertext = OQS_KEM_ml_kem_768_ipd_length_ciphertext; + kem->length_shared_secret = OQS_KEM_ml_kem_768_ipd_length_shared_secret; - kem->keypair = OQS_KEM_ml_kem_768_keypair; - kem->encaps = OQS_KEM_ml_kem_768_encaps; - kem->decaps = OQS_KEM_ml_kem_768_decaps; + kem->keypair = OQS_KEM_ml_kem_768_ipd_keypair; + kem->encaps = OQS_KEM_ml_kem_768_ipd_encaps; + kem->decaps = OQS_KEM_ml_kem_768_ipd_decaps; return kem; } @@ -34,14 +34,14 @@ extern int pqcrystals_ml_kem_768_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_768_ipd_ref_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_768_ipd_ref_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); -#if defined(OQS_ENABLE_KEM_ml_kem_768_avx2) +#if defined(OQS_ENABLE_KEM_ml_kem_768_ipd_avx2) extern int pqcrystals_ml_kem_768_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_kem_768_ipd_avx2_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); extern int pqcrystals_ml_kem_768_ipd_avx2_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); #endif -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_768_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_768_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -56,8 +56,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_keypair(uint8_t *public_key, uint8_t *secr #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_768_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_768_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -72,8 +72,8 @@ OQS_API OQS_STATUS OQS_KEM_ml_kem_768_encaps(uint8_t *ciphertext, uint8_t *share #endif } -OQS_API OQS_STATUS OQS_KEM_ml_kem_768_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { -#if defined(OQS_ENABLE_KEM_ml_kem_768_avx2) +OQS_API OQS_STATUS OQS_KEM_ml_kem_768_ipd_decaps(uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_KEM_ml_kem_768_ipd_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_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/oqsconfig.h.cmake b/src/oqsconfig.h.cmake index 76c3eedd18..1404e19f79 100644 --- a/src/oqsconfig.h.cmake +++ b/src/oqsconfig.h.cmake @@ -110,12 +110,12 @@ #cmakedefine OQS_ENABLE_KEM_kyber_1024_aarch64 1 #cmakedefine OQS_ENABLE_KEM_ML_KEM 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_512 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_512_avx2 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_768 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_768_avx2 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_1024 1 -#cmakedefine OQS_ENABLE_KEM_ml_kem_1024_avx2 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_512_ipd 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_512_ipd_avx2 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_768_ipd 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_768_ipd_avx2 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_1024_ipd 1 +#cmakedefine OQS_ENABLE_KEM_ml_kem_1024_ipd_avx2 1 #cmakedefine OQS_ENABLE_SIG_DILITHIUM 1 #cmakedefine OQS_ENABLE_SIG_dilithium_2 1 @@ -129,12 +129,12 @@ #cmakedefine OQS_ENABLE_SIG_dilithium_5_aarch64 1 #cmakedefine OQS_ENABLE_SIG_ML_DSA 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_44 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_44_avx2 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_65 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_65_avx2 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_87 1 -#cmakedefine OQS_ENABLE_SIG_ml_dsa_87_avx2 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_44_ipd 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_44_ipd_avx2 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_65_ipd 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_65_ipd_avx2 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_87_ipd 1 +#cmakedefine OQS_ENABLE_SIG_ml_dsa_87_ipd_avx2 1 #cmakedefine OQS_ENABLE_SIG_FALCON 1 #cmakedefine OQS_ENABLE_SIG_falcon_512 1 diff --git a/src/sig/ml_dsa/CMakeLists.txt b/src/sig/ml_dsa/CMakeLists.txt index 8ef4174c80..128cd0cf2a 100644 --- a/src/sig/ml_dsa/CMakeLists.txt +++ b/src/sig/ml_dsa/CMakeLists.txt @@ -5,58 +5,58 @@ set(_ML_DSA_OBJS "") -if(OQS_ENABLE_SIG_ml_dsa_44) - add_library(ml_dsa_44_ref OBJECT sig_ml_dsa_44.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/symmetric-shake.c) - target_compile_options(ml_dsa_44_ref PUBLIC -DDILITHIUM_MODE=2) - target_include_directories(ml_dsa_44_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref) - target_include_directories(ml_dsa_44_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_44_ref PUBLIC -DDILITHIUM_MODE=2) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_44_ipd) + add_library(ml_dsa_44_ipd_ref OBJECT sig_ml_dsa_44_ipd.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref/symmetric-shake.c) + target_compile_options(ml_dsa_44_ipd_ref PUBLIC -DDILITHIUM_MODE=2) + target_include_directories(ml_dsa_44_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-44-ipd_ref) + target_include_directories(ml_dsa_44_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_44_ipd_ref PUBLIC -DDILITHIUM_MODE=2) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() -if(OQS_ENABLE_SIG_ml_dsa_44_avx2) - add_library(ml_dsa_44_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/symmetric-shake.c) - target_include_directories(ml_dsa_44_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2) - target_include_directories(ml_dsa_44_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_44_avx2 PRIVATE -mavx2 -mpopcnt) - target_compile_options(ml_dsa_44_avx2 PUBLIC -DDILITHIUM_MODE=2) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_44_ipd_avx2) + add_library(ml_dsa_44_ipd_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2/symmetric-shake.c) + target_include_directories(ml_dsa_44_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-44-ipd_avx2) + target_include_directories(ml_dsa_44_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_44_ipd_avx2 PRIVATE -mavx2 -mpopcnt) + target_compile_options(ml_dsa_44_ipd_avx2 PUBLIC -DDILITHIUM_MODE=2) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() -if(OQS_ENABLE_SIG_ml_dsa_65) - add_library(ml_dsa_65_ref OBJECT sig_ml_dsa_65.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/symmetric-shake.c) - target_compile_options(ml_dsa_65_ref PUBLIC -DDILITHIUM_MODE=3) - target_include_directories(ml_dsa_65_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref) - target_include_directories(ml_dsa_65_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_65_ref PUBLIC -DDILITHIUM_MODE=3) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_65_ipd) + add_library(ml_dsa_65_ipd_ref OBJECT sig_ml_dsa_65_ipd.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref/symmetric-shake.c) + target_compile_options(ml_dsa_65_ipd_ref PUBLIC -DDILITHIUM_MODE=3) + target_include_directories(ml_dsa_65_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-65-ipd_ref) + target_include_directories(ml_dsa_65_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_65_ipd_ref PUBLIC -DDILITHIUM_MODE=3) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() -if(OQS_ENABLE_SIG_ml_dsa_65_avx2) - add_library(ml_dsa_65_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/symmetric-shake.c) - target_include_directories(ml_dsa_65_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2) - target_include_directories(ml_dsa_65_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_65_avx2 PRIVATE -mavx2 -mpopcnt) - target_compile_options(ml_dsa_65_avx2 PUBLIC -DDILITHIUM_MODE=3) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_65_ipd_avx2) + add_library(ml_dsa_65_ipd_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2/symmetric-shake.c) + target_include_directories(ml_dsa_65_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-65-ipd_avx2) + target_include_directories(ml_dsa_65_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_65_ipd_avx2 PRIVATE -mavx2 -mpopcnt) + target_compile_options(ml_dsa_65_ipd_avx2 PUBLIC -DDILITHIUM_MODE=3) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() -if(OQS_ENABLE_SIG_ml_dsa_87) - add_library(ml_dsa_87_ref OBJECT sig_ml_dsa_87.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/symmetric-shake.c) - target_compile_options(ml_dsa_87_ref PUBLIC -DDILITHIUM_MODE=5) - target_include_directories(ml_dsa_87_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref) - target_include_directories(ml_dsa_87_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_87_ref PUBLIC -DDILITHIUM_MODE=5) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_87_ipd) + add_library(ml_dsa_87_ipd_ref OBJECT sig_ml_dsa_87_ipd.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/ntt.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/packing.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/poly.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/polyvec.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/reduce.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/rounding.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/sign.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref/symmetric-shake.c) + target_compile_options(ml_dsa_87_ipd_ref PUBLIC -DDILITHIUM_MODE=5) + target_include_directories(ml_dsa_87_ipd_ref PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-87-ipd_ref) + target_include_directories(ml_dsa_87_ipd_ref PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_87_ipd_ref PUBLIC -DDILITHIUM_MODE=5) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() -if(OQS_ENABLE_SIG_ml_dsa_87_avx2) - add_library(ml_dsa_87_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/symmetric-shake.c) - target_include_directories(ml_dsa_87_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2) - target_include_directories(ml_dsa_87_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) - target_compile_options(ml_dsa_87_avx2 PRIVATE -mavx2 -mpopcnt) - target_compile_options(ml_dsa_87_avx2 PUBLIC -DDILITHIUM_MODE=5) - set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) +if(OQS_ENABLE_SIG_ml_dsa_87_ipd_avx2) + add_library(ml_dsa_87_ipd_avx2 OBJECT pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/consts.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/invntt.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/ntt.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/packing.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/pointwise.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/poly.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/polyvec.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/rejsample.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/rounding.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/shuffle.S pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/sign.c pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2/symmetric-shake.c) + target_include_directories(ml_dsa_87_ipd_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqcrystals-dilithium-standard_ml-dsa-87-ipd_avx2) + target_include_directories(ml_dsa_87_ipd_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims) + target_compile_options(ml_dsa_87_ipd_avx2 PRIVATE -mavx2 -mpopcnt) + target_compile_options(ml_dsa_87_ipd_avx2 PUBLIC -DDILITHIUM_MODE=5) + set(_ML_DSA_OBJS ${_ML_DSA_OBJS} $) endif() set(ML_DSA_OBJS ${_ML_DSA_OBJS} PARENT_SCOPE) diff --git a/src/sig/ml_dsa/sig_ml_dsa.h b/src/sig/ml_dsa/sig_ml_dsa.h index 5f2ee9c503..be69ee5d64 100644 --- a/src/sig/ml_dsa/sig_ml_dsa.h +++ b/src/sig/ml_dsa/sig_ml_dsa.h @@ -5,37 +5,37 @@ #include -#ifdef OQS_ENABLE_SIG_ml_dsa_44 -#define OQS_SIG_ml_dsa_44_length_public_key 1312 -#define OQS_SIG_ml_dsa_44_length_secret_key 2560 -#define OQS_SIG_ml_dsa_44_length_signature 2420 - -OQS_SIG *OQS_SIG_ml_dsa_44_new(void); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_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_ml_dsa_44_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +#ifdef OQS_ENABLE_SIG_ml_dsa_44_ipd +#define OQS_SIG_ml_dsa_44_ipd_length_public_key 1312 +#define OQS_SIG_ml_dsa_44_ipd_length_secret_key 2560 +#define OQS_SIG_ml_dsa_44_ipd_length_signature 2420 + +OQS_SIG *OQS_SIG_ml_dsa_44_ipd_new(void); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_ipd_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_ml_dsa_44_ipd_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); #endif -#ifdef OQS_ENABLE_SIG_ml_dsa_65 -#define OQS_SIG_ml_dsa_65_length_public_key 1952 -#define OQS_SIG_ml_dsa_65_length_secret_key 4032 -#define OQS_SIG_ml_dsa_65_length_signature 3309 +#ifdef OQS_ENABLE_SIG_ml_dsa_65_ipd +#define OQS_SIG_ml_dsa_65_ipd_length_public_key 1952 +#define OQS_SIG_ml_dsa_65_ipd_length_secret_key 4032 +#define OQS_SIG_ml_dsa_65_ipd_length_signature 3309 -OQS_SIG *OQS_SIG_ml_dsa_65_new(void); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_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_ml_dsa_65_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_SIG *OQS_SIG_ml_dsa_65_ipd_new(void); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_ipd_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_ml_dsa_65_ipd_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); #endif -#ifdef OQS_ENABLE_SIG_ml_dsa_87 -#define OQS_SIG_ml_dsa_87_length_public_key 2592 -#define OQS_SIG_ml_dsa_87_length_secret_key 4896 -#define OQS_SIG_ml_dsa_87_length_signature 4627 +#ifdef OQS_ENABLE_SIG_ml_dsa_87_ipd +#define OQS_SIG_ml_dsa_87_ipd_length_public_key 2592 +#define OQS_SIG_ml_dsa_87_ipd_length_secret_key 4896 +#define OQS_SIG_ml_dsa_87_ipd_length_signature 4627 -OQS_SIG *OQS_SIG_ml_dsa_87_new(void); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_keypair(uint8_t *public_key, uint8_t *secret_key); -OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_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_ml_dsa_87_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_SIG *OQS_SIG_ml_dsa_87_ipd_new(void); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_ipd_keypair(uint8_t *public_key, uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_ipd_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_ml_dsa_87_ipd_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); #endif #endif diff --git a/src/sig/ml_dsa/sig_ml_dsa_44.c b/src/sig/ml_dsa/sig_ml_dsa_44_ipd.c similarity index 71% rename from src/sig/ml_dsa/sig_ml_dsa_44.c rename to src/sig/ml_dsa/sig_ml_dsa_44_ipd.c index 79421a1f8d..7a45eb12f1 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_44.c +++ b/src/sig/ml_dsa/sig_ml_dsa_44_ipd.c @@ -4,27 +4,27 @@ #include -#if defined(OQS_ENABLE_SIG_ml_dsa_44) +#if defined(OQS_ENABLE_SIG_ml_dsa_44_ipd) -OQS_SIG *OQS_SIG_ml_dsa_44_new(void) { +OQS_SIG *OQS_SIG_ml_dsa_44_ipd_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); if (sig == NULL) { return NULL; } - sig->method_name = OQS_SIG_alg_ml_dsa_44; + sig->method_name = OQS_SIG_alg_ml_dsa_44_ipd; sig->alg_version = "https://github.com/pq-crystals/dilithium/tree/standard"; sig->claimed_nist_level = 2; sig->euf_cma = true; - sig->length_public_key = OQS_SIG_ml_dsa_44_length_public_key; - sig->length_secret_key = OQS_SIG_ml_dsa_44_length_secret_key; - sig->length_signature = OQS_SIG_ml_dsa_44_length_signature; + sig->length_public_key = OQS_SIG_ml_dsa_44_ipd_length_public_key; + sig->length_secret_key = OQS_SIG_ml_dsa_44_ipd_length_secret_key; + sig->length_signature = OQS_SIG_ml_dsa_44_ipd_length_signature; - sig->keypair = OQS_SIG_ml_dsa_44_keypair; - sig->sign = OQS_SIG_ml_dsa_44_sign; - sig->verify = OQS_SIG_ml_dsa_44_verify; + sig->keypair = OQS_SIG_ml_dsa_44_ipd_keypair; + sig->sign = OQS_SIG_ml_dsa_44_ipd_sign; + sig->verify = OQS_SIG_ml_dsa_44_ipd_verify; return sig; } @@ -33,14 +33,14 @@ extern int pqcrystals_ml_dsa_44_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_44_ipd_ref_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_44_ipd_ref_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); -#if defined(OQS_ENABLE_SIG_ml_dsa_44_avx2) +#if defined(OQS_ENABLE_SIG_ml_dsa_44_ipd_avx2) extern int pqcrystals_ml_dsa_44_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_44_ipd_avx2_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_44_ipd_avx2_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_ml_dsa_44_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_SIG_ml_dsa_44_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_44_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -55,8 +55,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_keypair(uint8_t *public_key, uint8_t *secre #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_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_ml_dsa_44_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_ipd_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_ml_dsa_44_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -71,8 +71,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_sign(uint8_t *signature, size_t *signature_ #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_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_ml_dsa_44_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_ipd_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_ml_dsa_44_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/sig/ml_dsa/sig_ml_dsa_65.c b/src/sig/ml_dsa/sig_ml_dsa_65_ipd.c similarity index 71% rename from src/sig/ml_dsa/sig_ml_dsa_65.c rename to src/sig/ml_dsa/sig_ml_dsa_65_ipd.c index 9f28545601..d6892e51a6 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_65.c +++ b/src/sig/ml_dsa/sig_ml_dsa_65_ipd.c @@ -4,27 +4,27 @@ #include -#if defined(OQS_ENABLE_SIG_ml_dsa_65) +#if defined(OQS_ENABLE_SIG_ml_dsa_65_ipd) -OQS_SIG *OQS_SIG_ml_dsa_65_new(void) { +OQS_SIG *OQS_SIG_ml_dsa_65_ipd_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); if (sig == NULL) { return NULL; } - sig->method_name = OQS_SIG_alg_ml_dsa_65; + sig->method_name = OQS_SIG_alg_ml_dsa_65_ipd; sig->alg_version = "https://github.com/pq-crystals/dilithium/tree/standard"; sig->claimed_nist_level = 3; sig->euf_cma = true; - sig->length_public_key = OQS_SIG_ml_dsa_65_length_public_key; - sig->length_secret_key = OQS_SIG_ml_dsa_65_length_secret_key; - sig->length_signature = OQS_SIG_ml_dsa_65_length_signature; + sig->length_public_key = OQS_SIG_ml_dsa_65_ipd_length_public_key; + sig->length_secret_key = OQS_SIG_ml_dsa_65_ipd_length_secret_key; + sig->length_signature = OQS_SIG_ml_dsa_65_ipd_length_signature; - sig->keypair = OQS_SIG_ml_dsa_65_keypair; - sig->sign = OQS_SIG_ml_dsa_65_sign; - sig->verify = OQS_SIG_ml_dsa_65_verify; + sig->keypair = OQS_SIG_ml_dsa_65_ipd_keypair; + sig->sign = OQS_SIG_ml_dsa_65_ipd_sign; + sig->verify = OQS_SIG_ml_dsa_65_ipd_verify; return sig; } @@ -33,14 +33,14 @@ extern int pqcrystals_ml_dsa_65_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_65_ipd_ref_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_65_ipd_ref_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); -#if defined(OQS_ENABLE_SIG_ml_dsa_65_avx2) +#if defined(OQS_ENABLE_SIG_ml_dsa_65_ipd_avx2) extern int pqcrystals_ml_dsa_65_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_65_ipd_avx2_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_65_ipd_avx2_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_ml_dsa_65_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_SIG_ml_dsa_65_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_65_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -55,8 +55,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_keypair(uint8_t *public_key, uint8_t *secre #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_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_ml_dsa_65_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_ipd_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_ml_dsa_65_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -71,8 +71,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_sign(uint8_t *signature, size_t *signature_ #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_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_ml_dsa_65_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_ipd_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_ml_dsa_65_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/sig/ml_dsa/sig_ml_dsa_87.c b/src/sig/ml_dsa/sig_ml_dsa_87_ipd.c similarity index 71% rename from src/sig/ml_dsa/sig_ml_dsa_87.c rename to src/sig/ml_dsa/sig_ml_dsa_87_ipd.c index e1b5a32a53..54cd819412 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_87.c +++ b/src/sig/ml_dsa/sig_ml_dsa_87_ipd.c @@ -4,27 +4,27 @@ #include -#if defined(OQS_ENABLE_SIG_ml_dsa_87) +#if defined(OQS_ENABLE_SIG_ml_dsa_87_ipd) -OQS_SIG *OQS_SIG_ml_dsa_87_new(void) { +OQS_SIG *OQS_SIG_ml_dsa_87_ipd_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); if (sig == NULL) { return NULL; } - sig->method_name = OQS_SIG_alg_ml_dsa_87; + sig->method_name = OQS_SIG_alg_ml_dsa_87_ipd; sig->alg_version = "https://github.com/pq-crystals/dilithium/tree/standard"; sig->claimed_nist_level = 5; sig->euf_cma = true; - sig->length_public_key = OQS_SIG_ml_dsa_87_length_public_key; - sig->length_secret_key = OQS_SIG_ml_dsa_87_length_secret_key; - sig->length_signature = OQS_SIG_ml_dsa_87_length_signature; + sig->length_public_key = OQS_SIG_ml_dsa_87_ipd_length_public_key; + sig->length_secret_key = OQS_SIG_ml_dsa_87_ipd_length_secret_key; + sig->length_signature = OQS_SIG_ml_dsa_87_ipd_length_signature; - sig->keypair = OQS_SIG_ml_dsa_87_keypair; - sig->sign = OQS_SIG_ml_dsa_87_sign; - sig->verify = OQS_SIG_ml_dsa_87_verify; + sig->keypair = OQS_SIG_ml_dsa_87_ipd_keypair; + sig->sign = OQS_SIG_ml_dsa_87_ipd_sign; + sig->verify = OQS_SIG_ml_dsa_87_ipd_verify; return sig; } @@ -33,14 +33,14 @@ extern int pqcrystals_ml_dsa_87_ipd_ref_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_87_ipd_ref_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_87_ipd_ref_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, const uint8_t *pk); -#if defined(OQS_ENABLE_SIG_ml_dsa_87_avx2) +#if defined(OQS_ENABLE_SIG_ml_dsa_87_ipd_avx2) extern int pqcrystals_ml_dsa_87_ipd_avx2_keypair(uint8_t *pk, uint8_t *sk); extern int pqcrystals_ml_dsa_87_ipd_avx2_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, const uint8_t *sk); extern int pqcrystals_ml_dsa_87_ipd_avx2_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_ml_dsa_87_keypair(uint8_t *public_key, uint8_t *secret_key) { -#if defined(OQS_ENABLE_SIG_ml_dsa_87_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_ipd_keypair(uint8_t *public_key, uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_87_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -55,8 +55,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_keypair(uint8_t *public_key, uint8_t *secre #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_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_ml_dsa_87_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_ipd_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_ml_dsa_87_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ @@ -71,8 +71,8 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_sign(uint8_t *signature, size_t *signature_ #endif } -OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_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_ml_dsa_87_avx2) +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_ipd_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_ml_dsa_87_ipd_avx2) #if defined(OQS_DIST_BUILD) if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { #endif /* OQS_DIST_BUILD */ diff --git a/src/sig/sig.c b/src/sig/sig.c index a2283bf4c3..3604823b3d 100644 --- a/src/sig/sig.c +++ b/src/sig/sig.c @@ -18,9 +18,9 @@ OQS_API const char *OQS_SIG_alg_identifier(size_t i) { OQS_SIG_alg_dilithium_2, OQS_SIG_alg_dilithium_3, OQS_SIG_alg_dilithium_5, - OQS_SIG_alg_ml_dsa_44, - OQS_SIG_alg_ml_dsa_65, - OQS_SIG_alg_ml_dsa_87, + OQS_SIG_alg_ml_dsa_44_ipd, + OQS_SIG_alg_ml_dsa_65_ipd, + OQS_SIG_alg_ml_dsa_87_ipd, OQS_SIG_alg_falcon_512, OQS_SIG_alg_falcon_1024, OQS_SIG_alg_sphincs_sha2_128f_simple, @@ -72,20 +72,20 @@ OQS_API int OQS_SIG_alg_is_enabled(const char *method_name) { #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_44)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_44 + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_44_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_44_ipd return 1; #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_65)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_65 + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_65_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_65_ipd return 1; #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_87)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_87 + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_87_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_87_ipd return 1; #else return 0; @@ -204,21 +204,21 @@ OQS_API OQS_SIG *OQS_SIG_new(const char *method_name) { #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_44)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_44 - return OQS_SIG_ml_dsa_44_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_44_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_44_ipd + return OQS_SIG_ml_dsa_44_ipd_new(); #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_65)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_65 - return OQS_SIG_ml_dsa_65_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_65_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_65_ipd + return OQS_SIG_ml_dsa_65_ipd_new(); #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_87)) { -#ifdef OQS_ENABLE_SIG_ml_dsa_87 - return OQS_SIG_ml_dsa_87_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_alg_ml_dsa_87_ipd)) { +#ifdef OQS_ENABLE_SIG_ml_dsa_87_ipd + return OQS_SIG_ml_dsa_87_ipd_new(); #else return NULL; #endif diff --git a/src/sig/sig.h b/src/sig/sig.h index 4d65a4698a..438bf4dd18 100644 --- a/src/sig/sig.h +++ b/src/sig/sig.h @@ -39,11 +39,11 @@ extern "C" { /** Algorithm identifier for Dilithium5 */ #define OQS_SIG_alg_dilithium_5 "Dilithium5" /** Algorithm identifier for ML-DSA-44-ipd */ -#define OQS_SIG_alg_ml_dsa_44 "ML-DSA-44-ipd" +#define OQS_SIG_alg_ml_dsa_44_ipd "ML-DSA-44-ipd" /** Algorithm identifier for ML-DSA-65-ipd */ -#define OQS_SIG_alg_ml_dsa_65 "ML-DSA-65-ipd" +#define OQS_SIG_alg_ml_dsa_65_ipd "ML-DSA-65-ipd" /** Algorithm identifier for ML-DSA-87-ipd */ -#define OQS_SIG_alg_ml_dsa_87 "ML-DSA-87-ipd" +#define OQS_SIG_alg_ml_dsa_87_ipd "ML-DSA-87-ipd" /** Algorithm identifier for Falcon-512 */ #define OQS_SIG_alg_falcon_512 "Falcon-512" /** Algorithm identifier for Falcon-1024 */ diff --git a/tests/vectors_kem.c b/tests/vectors_kem.c index 49b7db5040..da99cc639e 100644 --- a/tests/vectors_kem.c +++ b/tests/vectors_kem.c @@ -69,9 +69,9 @@ static void hexStringToByteArray(const char *hexString, uint8_t *byteArray) { /* HQC-specific functions */ static inline bool is_ml_kem(const char *method_name) { - return (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_512)) - || (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_768)) - || (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_1024)); + return (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_512_ipd)) + || (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_768_ipd)) + || (0 == strcmp(method_name, OQS_KEM_alg_ml_kem_1024_ipd)); } static void MLKEM_randombytes_init(const uint8_t *entropy_input, const uint8_t *personalization_string) { diff --git a/tests/vectors_sig.c b/tests/vectors_sig.c index fcbd6a5828..6b1e646793 100644 --- a/tests/vectors_sig.c +++ b/tests/vectors_sig.c @@ -60,9 +60,9 @@ static void hexStringToByteArray(const char *hexString, uint8_t *byteArray) { /* HQC-specific functions */ static inline bool is_ml_dsa(const char *method_name) { - return (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_44)) - || (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_65)) - || (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_87)); + return (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_44_ipd)) + || (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_65_ipd)) + || (0 == strcmp(method_name, OQS_SIG_alg_ml_dsa_87_ipd)); } static void MLDSA_randombytes_init(const uint8_t *entropy_input, const uint8_t *personalization_string) {