Skip to content

Commit 7fd41b1

Browse files
authored
Merge pull request #10104 from padelsbach/cast-shift-slhdsa.c
Cast to unsigned prior to shift to avoid UB in SLH-DSA
2 parents 27aac0a + 4aac31b commit 7fd41b1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

wolfcrypt/src/wc_slhdsa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5768,7 +5768,7 @@ static void slhdsakey_set_ha_from_md(SlhDsaKey* key, const byte* md,
57685768
/* Step 9/12: Mask off any extra high bits. */
57695769
bits = key->params->h - (key->params->h / key->params->d);
57705770
if (bits < 64) {
5771-
t[1] &= (1 << (bits - 32)) - 1;
5771+
t[1] &= ((word32)1 << (bits - 32)) - 1;
57725772
}
57735773

57745774
/* Step 8/11: Get pointer to tree leaf index data. */
@@ -5777,7 +5777,7 @@ static void slhdsakey_set_ha_from_md(SlhDsaKey* key, const byte* md,
57775777
ato32(p, l);
57785778
/* Step 10/13: Mask off any extra high bits. */
57795779
bits = key->params->h / key->params->d;
5780-
*l &= (1 << bits) - 1;
5780+
*l &= ((word32)1 << bits) - 1;
57815781

57825782
/* Step 11/14: Set the tree index into address. */
57835783
HA_SetTreeAddress(adrs, t);

0 commit comments

Comments
 (0)