Skip to content

Commit

Permalink
add XMSS-SHAKE256_*_256 parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Duc Tri Nguyen <[email protected]>
  • Loading branch information
cothan committed Jun 8, 2024
1 parent c6816f8 commit 23490d3
Show file tree
Hide file tree
Showing 14 changed files with 211 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .CMake/alg_support.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_sha256_h20_192 "" ON "OQS_ENABLE
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h10_192 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h16_192 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h20_192 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)

cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
cmake_dependent_option(OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_4 "" ON "OQS_ENABLE_SIG_STFL_XMSS" OFF)
Expand Down
3 changes: 3 additions & 0 deletions src/oqsconfig.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h10_192 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h16_192 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h20_192 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256 1

#cmakedefine OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2 1
#cmakedefine OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_4 1
Expand Down
57 changes: 57 additions & 0 deletions src/sig_stfl/sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ OQS_API const char *OQS_SIG_STFL_alg_identifier(size_t i) {
OQS_SIG_STFL_alg_xmss_shake256_h10_192,
OQS_SIG_STFL_alg_xmss_shake256_h16_192,
OQS_SIG_STFL_alg_xmss_shake256_h20_192,
OQS_SIG_STFL_alg_xmss_shake256_h10_256,
OQS_SIG_STFL_alg_xmss_shake256_h16_256,
OQS_SIG_STFL_alg_xmss_shake256_h20_256,
OQS_SIG_STFL_alg_xmssmt_sha256_h20_2,
OQS_SIG_STFL_alg_xmssmt_sha256_h20_4,
OQS_SIG_STFL_alg_xmssmt_sha256_h40_2,
Expand Down Expand Up @@ -225,6 +228,24 @@ OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name) {
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h10_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h16_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h20_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256
return 1;
#else
return 0;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmssmt_sha256_h20_2)) {
#ifdef OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2
Expand Down Expand Up @@ -649,6 +670,24 @@ OQS_API OQS_SIG_STFL *OQS_SIG_STFL_new(const char *method_name) {
return OQS_SIG_STFL_alg_xmss_shake256_h20_192_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h10_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256
return OQS_SIG_STFL_alg_xmss_shake256_h10_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h16_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256
return OQS_SIG_STFL_alg_xmss_shake256_h16_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h20_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256
return OQS_SIG_STFL_alg_xmss_shake256_h20_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmssmt_sha256_h20_2)) {
#ifdef OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2
Expand Down Expand Up @@ -1146,6 +1185,24 @@ OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SIG_STFL_SECRET_KEY_new(const char *method_
return OQS_SECRET_KEY_XMSS_SHAKE256_H20_192_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h10_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256
return OQS_SECRET_KEY_XMSS_SHAKE256_H10_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h16_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256
return OQS_SECRET_KEY_XMSS_SHAKE256_H16_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmss_shake256_h20_256)) {
#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256
return OQS_SECRET_KEY_XMSS_SHAKE256_H20_256_new();
#else
return NULL;
#endif
} else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_xmssmt_sha256_h20_2)) {
#ifdef OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2
Expand Down
5 changes: 4 additions & 1 deletion src/sig_stfl/sig_stfl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ extern "C"
#define OQS_SIG_STFL_alg_xmss_shake256_h10_192 "XMSS-SHAKE256_10_192"
#define OQS_SIG_STFL_alg_xmss_shake256_h16_192 "XMSS-SHAKE256_16_192"
#define OQS_SIG_STFL_alg_xmss_shake256_h20_192 "XMSS-SHAKE256_20_192"
#define OQS_SIG_STFL_alg_xmss_shake256_h10_256 "XMSS-SHAKE256_10_256"
#define OQS_SIG_STFL_alg_xmss_shake256_h16_256 "XMSS-SHAKE256_16_256"
#define OQS_SIG_STFL_alg_xmss_shake256_h20_256 "XMSS-SHAKE256_20_256"

#define OQS_SIG_STFL_alg_xmssmt_sha256_h20_2 "XMSSMT-SHA2_20/2_256"
#define OQS_SIG_STFL_alg_xmssmt_sha256_h20_4 "XMSSMT-SHA2_20/4_256"
Expand Down Expand Up @@ -129,7 +132,7 @@ extern "C"
/*
* Total number of stateful variants defined above, used to create the tracking array
*/
#define OQS_SIG_STFL_algs_length 67
#define OQS_SIG_STFL_algs_length 70

typedef struct OQS_SIG_STFL_SECRET_KEY OQS_SIG_STFL_SECRET_KEY;

Expand Down
18 changes: 18 additions & 0 deletions src/sig_stfl/xmss/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ if (OQS_ENABLE_SIG_STFL_xmss_shake256_h20_192)
set(_XMSS_OBJS ${_XMSS_OBJS} $<TARGET_OBJECTS:xmss_shake256_h20_192>)
endif()

if (OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256)
add_library(xmss_shake256_h10_256 OBJECT sig_stfl_xmss_shake256_h10_256.c sig_stfl_xmss_functions.c ${SRCS})
target_compile_options(xmss_shake256_h10_256 PRIVATE -DXMSS_PARAMS_NAMESPACE=xmss_shake256_h10_256 -DHASH=5)
set(_XMSS_OBJS ${_XMSS_OBJS} $<TARGET_OBJECTS:xmss_shake256_h10_256>)
endif()

if (OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256)
add_library(xmss_shake256_h16_256 OBJECT sig_stfl_xmss_shake256_h16_256.c sig_stfl_xmss_functions.c ${SRCS})
target_compile_options(xmss_shake256_h16_256 PRIVATE -DXMSS_PARAMS_NAMESPACE=xmss_shake256_h16_256 -DHASH=5)
set(_XMSS_OBJS ${_XMSS_OBJS} $<TARGET_OBJECTS:xmss_shake256_h16_256>)
endif()

if (OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256)
add_library(xmss_shake256_h20_256 OBJECT sig_stfl_xmss_shake256_h20_256.c sig_stfl_xmss_functions.c ${SRCS})
target_compile_options(xmss_shake256_h20_256 PRIVATE -DXMSS_PARAMS_NAMESPACE=xmss_shake256_h20_256 -DHASH=5)
set(_XMSS_OBJS ${_XMSS_OBJS} $<TARGET_OBJECTS:xmss_shake256_h20_256>)
endif()

if (OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2)
add_library(xmssmt_sha256_h20_2 OBJECT sig_stfl_xmssmt_sha256_h20_2.c sig_stfl_xmssmt_functions.c ${SRCS})
target_compile_options(xmssmt_sha256_h20_2 PRIVATE -DXMSS_PARAMS_NAMESPACE=xmssmt_sha256_h20_2 -DHASH=3)
Expand Down
55 changes: 55 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
* | XMSS-SHA2_16_192 | 0x0e | 1605 | 48 | 1636 | 24 | ❌ | ✅ | ✅ |
* | XMSS-SHA2_20_192 | 0x0f | 1973 | 48 | 1732 | 24 | ❌ | ✅ | ✅ |
*
* | XMSS-SHAKE256_10_256 | 0x10 | 1373 | 64 | 2500 | 32 | ❌ | ✅ | ✅ |
* | XMSS-SHAKE256_16_256 | 0x11 | 2093 | 64 | 2692 | 32 | ❌ | ✅ | ✅ |
* | XMSS-SHAKE256_20_256 | 0x12 | 2573 | 64 | 2820 | 32 | ❌ | ✅ | ✅ |
*
* | XMSS-SHAKE256_10_192 | 0x13 | 1053 | 48 | 1492 | 24 | ❌ | ✅ | ✅ |
* | XMSS-SHAKE256_16_192 | 0x14 | 1605 | 48 | 1636 | 24 | ❌ | ✅ | ✅ |
* | XMSS-SHAKE256_20_192 | 0x15 | 1973 | 48 | 1732 | 24 | ❌ | ✅ | ✅ |
Expand Down Expand Up @@ -364,6 +368,57 @@ OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_192_sigs_total(unsigned lo

#endif

#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h10_256

#define OQS_SIG_STFL_alg_xmss_shake256_h10_256_oid 0x10
#define OQS_SIG_STFL_alg_xmss_shake256_h10_256_length_sk (1373 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h10_256_length_pk (64 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h10_256_length_signature 2500

OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h10_256_new(void);
OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H10_256_new(void);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_256_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_256_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_256_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_256_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_256_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key);

#endif

#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h16_256

#define OQS_SIG_STFL_alg_xmss_shake256_h16_256_oid 0x11
#define OQS_SIG_STFL_alg_xmss_shake256_h16_256_length_sk (2093 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h16_256_length_pk (64 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h16_256_length_signature 2692

OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h16_256_new(void);
OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H16_256_new(void);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_256_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_256_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_256_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_256_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_256_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key);

#endif

#ifdef OQS_ENABLE_SIG_STFL_xmss_shake256_h20_256

#define OQS_SIG_STFL_alg_xmss_shake256_h20_256_oid 0x12
#define OQS_SIG_STFL_alg_xmss_shake256_h20_256_length_sk (2573 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h20_256_length_pk (64 + XMSS_OID_LEN)
#define OQS_SIG_STFL_alg_xmss_shake256_h20_256_length_signature 2820

OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h20_256_new(void);
OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H20_256_new(void);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_256_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_256_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_256_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_256_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key);
OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_256_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key);

#endif

#ifdef OQS_ENABLE_SIG_STFL_xmssmt_sha256_h20_2

#define OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_oid 0x01
Expand Down
7 changes: 7 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10_256.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT) AND CC0-1.0

#include "sig_stfl_xmss_xmssmt.c"

// ======================== XMSS-SHAKE256_10_256 ======================== //

XMSS_ALG(, _shake256_h10_256, _SHAKE256_H10_256)
7 changes: 7 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16_256.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT) AND CC0-1.0

#include "sig_stfl_xmss_xmssmt.c"

// ======================== XMSS-SHAKE256_16_256 ======================== //

XMSS_ALG(, _shake256_h16_256, _SHAKE256_H16_256)
7 changes: 7 additions & 0 deletions src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20_256.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT) AND CC0-1.0

#include "sig_stfl_xmss_xmssmt.c"

// ======================== XMSS-SHAKE256_20_256 ======================== //

XMSS_ALG(, _shake256_h20_256, _SHAKE256_H20_256)
3 changes: 3 additions & 0 deletions tests/KATs/sig_stfl/kats.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"XMSS-SHAKE256_10_192": "b62a1dbc2f8920df2f5a164ed175829ed95d5b3301269b0ab2452cd46b4261d6",
"XMSS-SHAKE256_16_192": "935570c4bc7c61e4cdc0517182766dcee53ceec71f91b8dd969568a7f8b76db1",
"XMSS-SHAKE256_20_192": "18067167a1eeee294bf1f0e3087e468b512f7c0c4cfad9c449dc425aab45336b",
"XMSS-SHAKE256_10_256": "7cbb582c6723cb86a9c775151865a67f3f9fa30140beab8f115cd4a7dc15eb2d",
"XMSS-SHAKE256_16_256": "ccc819bc17f78cdb4f2733b97350b7ef351e07d1456564a4185247db1a682fe3",
"XMSS-SHAKE256_20_256": "01ace5400a407030b0cb43ed0982c5f378a1d0c4108fdca2b70bc4ba78067c7f",
"XMSSMT-SHA2_20/2_256": "9f117294999c886ac6b69d6f32c3fc152599343add210f4464aee5d1ca0ec34d",
"XMSSMT-SHA2_20/4_256": "0c990e8ff8189140e8539b11ae3f85040544fc7d549f8db17d83392569647de9",
"XMSSMT-SHA2_40/2_256": "91605c4b67afb4e17d57ed076e10d3c4287264deea4a46092e374199c041d489",
Expand Down
Loading

0 comments on commit 23490d3

Please sign in to comment.