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. */