Merge pull request #6288 from JacobBarthelmeh/Testing

avoid callback buffer overwrite with sha512_224 and remove min from w…
This commit is contained in:
Sean Parkinson 2023-04-26 08:36:20 +10:00 committed by GitHub
commit c4233e7aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -99,7 +99,8 @@ int wc_CAAM_Cmac(Cmac* cmac, const byte* key, word32 keySz, const byte* in,
WOLFSSL_MSG("Error with CMAC buffer size");
return -1;
}
add = min(sz, (int)(AES_BLOCK_SIZE - cmac->bufferSz));
add = (sz < ((int)(AES_BLOCK_SIZE - cmac->bufferSz))) ? sz :
(int)(AES_BLOCK_SIZE - cmac->bufferSz);
XMEMCPY(&cmac->buffer[cmac->bufferSz], pt, add);
cmac->bufferSz += add;

View File

@ -1152,9 +1152,12 @@ static int Sha512_Family_Final(wc_Sha512* sha512, byte* hash, size_t digestSz,
#ifdef WOLF_CRYPTO_CB
if (sha512->devId != INVALID_DEVID) {
ret = wc_CryptoCb_Sha512Hash(sha512, NULL, 0, hash);
if (ret != CRYPTOCB_UNAVAILABLE)
byte localHash[WC_SHA512_DIGEST_SIZE];
ret = wc_CryptoCb_Sha512Hash(sha512, NULL, 0, localHash);
if (ret != CRYPTOCB_UNAVAILABLE) {
XMEMCPY(hash, localHash, digestSz);
return ret;
}
/* fall-through when unavailable */
}
#endif