Merge pull request #6288 from JacobBarthelmeh/Testing
avoid callback buffer overwrite with sha512_224 and remove min from w…
This commit is contained in:
commit
c4233e7aec
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user