@@ -1339,10 +1339,10 @@ static void wc_lmots_public_key_encode(const LmsParams* params,
13391339 const byte * priv_i = priv + LMS_Q_LEN + params -> hash_len ;
13401340
13411341 /* u32str(type) || ... || T(1) */
1342- c32toa (params -> lmsType , pub );
1342+ c32toa (params -> lmsType & LMS_H_W_MASK , pub );
13431343 pub += 4 ;
13441344 /* u32str(type) || u32str(otstype) || ... || T(1) */
1345- c32toa (params -> lmOtsType , pub );
1345+ c32toa (params -> lmOtsType & LMS_H_W_MASK , pub );
13461346 pub += 4 ;
13471347 /* u32str(type) || u32str(otstype) || I || T(1) */
13481348 XMEMCPY (pub , priv_i , LMS_I_LEN );
@@ -1365,14 +1365,14 @@ static int wc_lmots_public_key_check(const LmsParams* params, const byte* pub)
13651365 ato32 (pub , & type );
13661366 pub += 4 ;
13671367 /* Compare with parameters. */
1368- if (type != params -> lmsType ) {
1368+ if (type != ( params -> lmsType & LMS_H_W_MASK ) ) {
13691369 ret = PUBLIC_KEY_E ;
13701370 }
13711371 if (ret == 0 ) {
13721372 /* Get node hash and Winternitz width type. */
13731373 ato32 (pub , & type );
13741374 /* Compare with parameters. */
1375- if (type != params -> lmOtsType ) {
1375+ if (type != ( params -> lmOtsType & LMS_H_W_MASK ) ) {
13761376 ret = PUBLIC_KEY_E ;
13771377 }
13781378 }
@@ -2250,7 +2250,7 @@ static int wc_lms_sign(LmsState* state, const byte* priv, const byte* msg,
22502250 s += LMS_Q_LEN ;
22512251
22522252 /* ots_signature = sig = u32str(type) || ... */
2253- c32toa (state -> params -> lmOtsType , s );
2253+ c32toa (state -> params -> lmOtsType & LMS_H_W_MASK , s );
22542254 s += LMS_TYPE_LEN ;
22552255 /* Sign this level.
22562256 * S = u32str(q) || ots_signature || ... */
@@ -2259,7 +2259,7 @@ static int wc_lms_sign(LmsState* state, const byte* priv, const byte* msg,
22592259 /* Skip over ots_signature. */
22602260 s += params -> hash_len + params -> p * params -> hash_len ;
22612261 /* S = u32str(q) || ots_signature || u32str(type) || ... */
2262- c32toa (params -> lmsType , s );
2262+ c32toa (params -> lmsType & LMS_H_W_MASK , s );
22632263 }
22642264
22652265 return ret ;
@@ -2280,13 +2280,13 @@ static void wc_lms_sig_copy(const LmsParams* params, const byte* y,
22802280 XMEMCPY (sig , priv , LMS_Q_LEN );
22812281 sig += LMS_Q_LEN ;
22822282 /* S = u32str(q) || ... */
2283- c32toa (params -> lmOtsType , sig );
2283+ c32toa (params -> lmOtsType & LMS_H_W_MASK , sig );
22842284 sig += LMS_TYPE_LEN ;
22852285 /* S = u32str(q) || ots_signature || ... */
22862286 XMEMCPY (sig , y , params -> hash_len + params -> p * params -> hash_len );
22872287 sig += params -> hash_len + params -> p * params -> hash_len ;
22882288 /* S = u32str(q) || ots_signature || u32str(type) || ... */
2289- c32toa (params -> lmsType , sig );
2289+ c32toa (params -> lmsType & LMS_H_W_MASK , sig );
22902290}
22912291#endif /* !WOLFSSL_WC_LMS_SMALL && !WOLFSSL_LMS_NO_SIG_CACHE */
22922292#endif /* !WOLFSSL_LMS_VERIFY_ONLY */
0 commit comments