From 9590255cebf71097dfb163dcf190c1630cbcb01f Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 16 Mar 2026 21:24:08 +1000 Subject: [PATCH] XMSS: Fix index copy for signing. The index is already big-endian encoded but it needs to be front padded with zeros instead of back end padded. --- wolfcrypt/src/wc_xmss_impl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/wc_xmss_impl.c b/wolfcrypt/src/wc_xmss_impl.c index 56836f3d0d..c7a75f3143 100644 --- a/wolfcrypt/src/wc_xmss_impl.c +++ b/wolfcrypt/src/wc_xmss_impl.c @@ -413,8 +413,7 @@ static void wc_idx_update(unsigned char* a, word8 l) /* Copy index from source buffer to destination buffer. * - * Index is put into the front of the destination buffer with the length of the - * source. + * Index is put in the back of the destination buffer. * * @param [in] s Source buffer. * @param [in] sl Length of index in source. @@ -424,8 +423,8 @@ static void wc_idx_update(unsigned char* a, word8 l) static void wc_idx_copy(const unsigned char* s, word8 sl, unsigned char* d, word8 dl) { - XMEMCPY(d, s, sl); - XMEMSET(d + sl, 0, dl - sl); + XMEMSET(d, 0, dl - sl); + XMEMCPY(d + dl - sl, s, sl); } #endif