Initialize GCM AAD in case wc_AesInit() wasn't called

This commit is contained in:
Tesfa Mael 2019-09-20 12:04:33 -07:00
parent 54cdab8005
commit 74386fd0d0

View File

@ -3601,7 +3601,12 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
if (!((len == 16) || (len == 24) || (len == 32))) if (!((len == 16) || (len == 24) || (len == 32)))
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
XMEMSET(aes, 0, sizeof(Aes)); #ifdef OPENSSL_EXTRA
if (aes != NULL) {
XMEMSET(aes->aadH, 0, sizeof(aes->aadH));
aes->aadLen = 0;
}
#endif
XMEMSET(iv, 0, AES_BLOCK_SIZE); XMEMSET(iv, 0, AES_BLOCK_SIZE);
ret = wc_AesSetKey(aes, key, len, iv, AES_ENCRYPTION); ret = wc_AesSetKey(aes, key, len, iv, AES_ENCRYPTION);