Skip to content

Commit 62f2875

Browse files
committed
LMS: fix for when WOLFSSL_LMS_MAX_LEVELS is 1
1 parent bfab68f commit 62f2875

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wolfcrypt/src/wc_lms_impl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,9 @@ static int wc_hss_sign_build_sig(LmsState* state, byte* priv_raw,
34763476
/* Build from bottom up. */
34773477
for (i = params->levels - 1; (ret == 0) && (i >= 0); i--) {
34783478
byte* p = priv + i * (LMS_Q_LEN + params->hash_len + LMS_I_LEN);
3479+
#if !defined(WOLFSSL_LMS_MAX_LEVELS) || WOLFSSL_LMS_MAX_LEVELS > 1
34793480
byte* root = NULL;
3481+
#endif
34803482
#ifndef WOLFSSL_LMS_NO_SIG_CACHE
34813483
int store_p = 0;
34823484
word32 q_32 = LMS_Q_AT_LEVEL(q, params->levels, i,
@@ -3487,10 +3489,12 @@ static int wc_hss_sign_build_sig(LmsState* state, byte* priv_raw,
34873489

34883490
/* Move to start of next signature at this level. */
34893491
sig -= LMS_SIG_LEN(params->height, params->p, params->hash_len);
3492+
#if !defined(WOLFSSL_LMS_MAX_LEVELS) || WOLFSSL_LMS_MAX_LEVELS > 1
34903493
if (i != 0) {
34913494
/* Put root node into signature at this index. */
34923495
root = sig - params->hash_len;
34933496
}
3497+
#endif
34943498

34953499
#ifndef WOLFSSL_LMS_NO_SIG_CACHE
34963500
/* Check if we have a cached version of C and the p hashes that we
@@ -3526,10 +3530,12 @@ static int wc_hss_sign_build_sig(LmsState* state, byte* priv_raw,
35263530
/* Copy the authentication path out of the private key. */
35273531
XMEMCPY(s, priv_key->state[i].auth_path,
35283532
params->height * params->hash_len);
3533+
#if !defined(WOLFSSL_LMS_MAX_LEVELS) || WOLFSSL_LMS_MAX_LEVELS > 1
35293534
/* Copy the root node into signature unless at top. */
35303535
if (i != 0) {
35313536
XMEMCPY(root, priv_key->state[i].root, params->hash_len);
35323537
}
3538+
#endif
35333539
}
35343540
if ((ret == 0) && (i != 0)) {
35353541
/* Create public data for this level if there is another. */

0 commit comments

Comments
 (0)