fix for retval overwrite (warned by clang-analyzer-deadcode.DeadStores) in sha.c:wc_ShaFinal();

fix for benign clang-analyzer-deadcode.DeadStores in aes.c:wc_AesFeedbackEncrypt();

fix for cppcheck:selfAssignment in chacha.c:wc_Chacha_wordtobyte().
This commit is contained in:
Daniel Pouzzner
2023-04-19 15:53:48 -05:00
parent f396989d20
commit 8f610bb156
3 changed files with 8 additions and 14 deletions

View File

@@ -9914,9 +9914,6 @@ static WARN_UNUSED_RESULT int wc_AesFeedbackEncrypt(
Aes* aes, byte* out, const byte* in, word32 sz, byte mode)
{
byte* tmp = NULL;
#ifdef WOLFSSL_AES_CFB
byte* reg = NULL;
#endif
int ret = 0;
word32 processed;
@@ -9924,12 +9921,6 @@ static WARN_UNUSED_RESULT int wc_AesFeedbackEncrypt(
return BAD_FUNC_ARG;
}
#ifdef WOLFSSL_AES_CFB
if (aes->left && sz) {
reg = (byte*)aes->reg + AES_BLOCK_SIZE - aes->left;
}
#endif
/* consume any unused bytes left in aes->tmp */
processed = min(aes->left, sz);
xorbufout(out, in, (byte*)aes->tmp + AES_BLOCK_SIZE - aes->left, processed);
@@ -9980,14 +9971,11 @@ static WARN_UNUSED_RESULT int wc_AesFeedbackEncrypt(
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
}
#endif
#ifdef WOLFSSL_AES_CFB
reg = (byte*)aes->reg;
#endif
xorbufout(out, in, tmp, sz);
#ifdef WOLFSSL_AES_CFB
if (mode == AES_CFB_MODE) {
XMEMCPY(reg, out, sz);
XMEMCPY(aes->reg, out, sz);
}
#endif
aes->left -= sz;

View File

@@ -222,7 +222,9 @@ static WC_INLINE void wc_Chacha_wordtobyte(word32 x[CHACHA_CHUNK_WORDS],
for (i = 0; i < CHACHA_CHUNK_WORDS; i++) {
x[i] = PLUS(x[i], state[i]);
#ifdef BIG_ENDIAN_ORDER
x[i] = LITTLE32(x[i]);
#endif
}
}

View File

@@ -879,7 +879,11 @@ int wc_ShaFinal(wc_Sha* sha, byte* hash)
XMEMCPY(hash, (byte *)&sha->digest[0], WC_SHA_DIGEST_SIZE);
ret = InitSha(sha); /* reset state */
{
int initret = InitSha(sha); /* reset state */
if (initret < 0)
ret = initret;
}
return ret;
}