Skip to content

Commit 32439c9

Browse files
authored
Merge pull request #10448 from SparkiDev/lms_fixes_1
LMS: fixes and improvements
2 parents 2239fc3 + 69027c2 commit 32439c9

6 files changed

Lines changed: 357 additions & 174 deletions

File tree

tests/api.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37899,7 +37899,11 @@ static int test_lms_init_key(LmsKey* key, WC_RNG* rng)
3789937899
ret = wc_LmsKey_Init(key, NULL, INVALID_DEVID);
3790037900
if (ret != 0) return ret;
3790137901

37902+
#if !defined(WOLFSSL_LMS_MAX_HEIGHT) || (WOLFSSL_LMS_MAX_HEIGHT >= 10)
3790237903
ret = wc_LmsKey_SetParameters(key, 1, 10, 8);
37904+
#else
37905+
ret = wc_LmsKey_SetParameters(key, 1, 5, 8);
37906+
#endif
3790337907
if (ret != 0) return ret;
3790437908

3790537909
ret = wc_LmsKey_SetWriteCb(key, test_lms_write_key);
@@ -37973,7 +37977,8 @@ int test_wc_LmsKey_sign_verify(void)
3797337977
int test_wc_LmsKey_reload_cache(void)
3797437978
{
3797537979
EXPECT_DECLS;
37976-
#if defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_VERIFY_ONLY)
37980+
#if defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_VERIFY_ONLY) && \
37981+
(!defined(WOLFSSL_LMS_MAX_HEIGHT) || (WOLFSSL_LMS_MAX_HEIGHT >= 10))
3797737982
LmsKey key;
3797837983
LmsKey vkey;
3797937984
WC_RNG rng;
@@ -38012,7 +38017,11 @@ int test_wc_LmsKey_reload_cache(void)
3801238017
ExpectIntEQ(wc_LmsKey_Sign(&key, sig, &sigSz, msg, sizeof(msg)), 0);
3801338018

3801438019
ExpectIntEQ(wc_LmsKey_Init(&vkey, NULL, INVALID_DEVID), 0);
38020+
#if !defined(WOLFSSL_LMS_MAX_HEIGHT) || (WOLFSSL_LMS_MAX_HEIGHT >= 10)
3801538021
ExpectIntEQ(wc_LmsKey_SetParameters(&vkey, 1, 10, 8), 0);
38022+
#else
38023+
ExpectIntEQ(wc_LmsKey_SetParameters(&vkey, 1, 5, 8), 0);
38024+
#endif
3801638025
ExpectIntEQ(wc_LmsKey_ImportPubRaw(&vkey, pub, pubSz), 0);
3801738026
ExpectIntEQ(wc_LmsKey_Verify(&vkey, sig, sigSz, msg, sizeof(msg)), 0);
3801838027

@@ -38688,9 +38697,15 @@ int test_rfc9802_lms_x509_verify(void)
3868838697
* or SHAKE-only builds skip this block. */
3868938698
static const char* const lmsFiles[] = {
3869038699
"./certs/lms/bc_lms_sha256_h5_w4_root.der",
38700+
#if !defined(WOLFSSL_LMS_MAX_HEIGHT) || (WOLFSSL_LMS_MAX_HEIGHT >= 10)
3869138701
"./certs/lms/bc_lms_sha256_h10_w8_root.der",
38702+
#endif
38703+
#if !defined(WOLFSSL_LMS_MAX_LEVELS) || (WOLFSSL_LMS_MAX_LEVELS >= 2)
3869238704
"./certs/lms/bc_hss_L2_H5_W8_root.der",
38705+
#endif
38706+
#if !defined(WOLFSSL_LMS_MAX_LEVELS) || (WOLFSSL_LMS_MAX_LEVELS >= 3)
3869338707
"./certs/lms/bc_hss_L3_H5_W4_root.der",
38708+
#endif
3869438709
"./certs/lms/bc_lms_native_bc_root.der",
3869538710
};
3869638711
size_t i;

wolfcrypt/benchmark/benchmark.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11700,7 +11700,6 @@ static void bench_lms_sign_verify(enum wc_LmsParm parm, byte* pub)
1170011700
XMEMCPY(key.pub, lms_pub_L4_H5_W8, HSS_MAX_PUBLIC_KEY_LEN);
1170111701
break;
1170211702

11703-
case WC_LMS_PARM_NONE:
1170411703
case WC_LMS_PARM_L1_H15_W2:
1170511704
case WC_LMS_PARM_L1_H15_W4:
1170611705
case WC_LMS_PARM_L2_H10_W8:

0 commit comments

Comments
 (0)