From 7a264162b82bf8470dee979886d7cfe8956af50f Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Mon, 9 Mar 2026 17:21:01 +0100 Subject: [PATCH] wc_ChaCha20Poly1305_Decrypt: clear unauthed plaintext F-452 --- wolfcrypt/src/chacha20_poly1305.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wolfcrypt/src/chacha20_poly1305.c b/wolfcrypt/src/chacha20_poly1305.c index 8911b4d53d..a7acd6acfa 100644 --- a/wolfcrypt/src/chacha20_poly1305.c +++ b/wolfcrypt/src/chacha20_poly1305.c @@ -119,6 +119,10 @@ int wc_ChaCha20Poly1305_Decrypt( if (ret == 0) ret = wc_ChaCha20Poly1305_CheckTag(inAuthTag, calculatedAuthTag); + if (ret != 0) { + /* zero plaintext on error */ + ForceZero(outPlaintext, inCiphertextLen); + } WC_FREE_VAR_EX(aead, NULL, DYNAMIC_TYPE_TMP_BUFFER); return ret;