From 1fa75a5503b80617b17911cfda1e3760b0cabead Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 23 Mar 2023 09:28:22 +1000 Subject: [PATCH] AES-GCM streaming: EVP needs to set IV with wc_AesGcmInit Store IV if it is small enough to fit in aes->reg - was a copy of the aes->reg in the first place. --- wolfcrypt/src/aes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index a93da6ea4..4faabc33b 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -8169,6 +8169,11 @@ int wc_AesGcmInit(Aes* aes, const byte* key, word32 len, const byte* iv, } if (ret == 0) { + /* Set the IV passed in if it is smaller than a block. */ + if ((iv != NULL) && (ivSz <= AES_BLOCK_SIZE)) { + XMEMCPY((byte*)aes->reg, iv, ivSz); + aes->nonceSz = ivSz; + } /* No IV passed in, check for cached IV. */ if ((iv == NULL) && (aes->nonceSz != 0)) { /* Use the cached copy. */