]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
slh_dsa: cleanse generated add_random buffer
authorMounir IDRASSI <mounir.idrassi@idrix.fr>
Wed, 29 Apr 2026 11:21:51 +0000 (20:21 +0900)
committerNorbert Pocs <norbertp@openssl.org>
Sun, 3 May 2026 14:49:14 +0000 (16:49 +0200)
Fix the inverted cleanse guard in the SLH DSA provider signing path.

When randomized signing populates the local add_rand buffer, the cleanup step currently skips that stack buffer. Other signing modes do not create this transient buffer, so they should not drive this cleanup. Swap the guard so only the transient per signature buffer is cleansed, and cleanse the full fixed size buffer directly.

Fixes #30950

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Sun May  3 14:49:20 2026
(Merged from https://github.com/openssl/openssl/pull/31029)

providers/implementations/signature/slh_dsa_sig.c

index 421b75df20a1ce65c6de6cb6cbd130131e31a9c7..fa315a7b84a4591eb244833b559a88d4978b8a60 100644 (file)
@@ -241,8 +241,9 @@ static int slh_dsa_sign(void *vctx, unsigned char *sig, size_t *siglen,
         ctx->context_string, ctx->context_string_len,
         opt_rand, ctx->msg_encode,
         sig, siglen, sigsize);
-    if (opt_rand != add_rand)
-        OPENSSL_cleanse(opt_rand, n);
+    /* Only cleanse the temporary buffer generated for this signature. */
+    if (opt_rand == add_rand)
+        OPENSSL_cleanse(add_rand, sizeof(add_rand));
     return ret;
 }