mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Fix MD5 and SHA buffer overrun.
This commit is contained in:
@ -461,7 +461,9 @@ int wc_Md5Final(wc_Md5* md5, byte* hash)
|
||||
|
||||
/* pad with zeros */
|
||||
if (md5->buffLen > WC_MD5_PAD_SIZE) {
|
||||
XMEMSET(&local[md5->buffLen], 0, WC_MD5_BLOCK_SIZE - md5->buffLen);
|
||||
if (md5->buffLen < WC_MD5_BLOCK_SIZE) {
|
||||
XMEMSET(&local[md5->buffLen], 0, WC_MD5_BLOCK_SIZE - md5->buffLen);
|
||||
}
|
||||
md5->buffLen += WC_MD5_BLOCK_SIZE - md5->buffLen;
|
||||
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
|
@ -1321,8 +1321,11 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
|
||||
/* pad with zeros */
|
||||
if (sha256->buffLen > WC_SHA256_PAD_SIZE) {
|
||||
XMEMSET(&local[sha256->buffLen], 0,
|
||||
WC_SHA256_BLOCK_SIZE - sha256->buffLen);
|
||||
if (sha256->buffLen < WC_SHA256_BLOCK_SIZE) {
|
||||
XMEMSET(&local[sha256->buffLen], 0,
|
||||
WC_SHA256_BLOCK_SIZE - sha256->buffLen);
|
||||
}
|
||||
|
||||
sha256->buffLen += WC_SHA256_BLOCK_SIZE - sha256->buffLen;
|
||||
|
||||
#if defined(WOLFSSL_USE_ESP32_CRYPT_HASH_HW) && \
|
||||
|
@ -942,7 +942,11 @@ static WC_INLINE int Sha512Final(wc_Sha512* sha512)
|
||||
|
||||
/* pad with zeros */
|
||||
if (sha512->buffLen > WC_SHA512_PAD_SIZE) {
|
||||
XMEMSET(&local[sha512->buffLen], 0, WC_SHA512_BLOCK_SIZE - sha512->buffLen);
|
||||
if (sha512->buffLen < WC_SHA512_BLOCK_SIZE ) {
|
||||
XMEMSET(&local[sha512->buffLen], 0,
|
||||
WC_SHA512_BLOCK_SIZE - sha512->buffLen);
|
||||
}
|
||||
|
||||
sha512->buffLen += WC_SHA512_BLOCK_SIZE - sha512->buffLen;
|
||||
#if defined(LITTLE_ENDIAN_ORDER)
|
||||
#if defined(USE_INTEL_SPEEDUP) && \
|
||||
|
Reference in New Issue
Block a user