more fixes for implicit casts, mostly asn=original.

This commit is contained in:
Daniel Pouzzner 2023-04-12 02:17:18 -05:00
parent fe2acb53af
commit 4b59588cf3
4 changed files with 384 additions and 335 deletions

File diff suppressed because it is too large Load Diff

View File

@ -528,11 +528,15 @@ int wc_Hash(enum wc_HashType hash_type, const byte* data,
word32 data_len, byte* hash, word32 hash_len)
{
int ret = HASH_TYPE_E; /* Default to hash type error */
word32 dig_size;
int dig_size;
/* Validate hash buffer size */
dig_size = (word32)wc_HashGetDigestSize(hash_type);
if (hash_len < dig_size) {
dig_size = wc_HashGetDigestSize(hash_type);
if (dig_size < 0) {
return dig_size;
}
if (hash_len < (word32)dig_size) {
return BUFFER_E;
}

View File

@ -3820,7 +3820,7 @@ static int wc_PKCS7_VerifyContentMessageDigest(PKCS7* pkcs7,
/* compare generated to hash in messageDigest attribute */
if ((innerAttribSz != digestSz) ||
(XMEMCMP(attrib->value + idx, digestBuf, (word32)digestSz) != 0)) {
(XMEMCMP(attrib->value + idx, digestBuf, (size_t)digestSz) != 0)) {
WOLFSSL_MSG("Content digest does not match messageDigest attrib value");
#ifdef WOLFSSL_SMALL_STACK
XFREE(digest, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);

View File

@ -4845,7 +4845,7 @@ WOLFSSL_TEST_SUBROUTINE int hash_test(void)
for (i = 0; i < (int)(sizeof(typesHashBad)/sizeof(*typesHashBad)); i++) {
ret = wc_Hash(typesHashBad[i], data, sizeof(data), out, sizeof(out));
if (ret != BAD_FUNC_ARG && ret != BUFFER_E)
if ((ret != BAD_FUNC_ARG) && (ret != BUFFER_E) && (ret != HASH_TYPE_E))
return WC_TEST_RET_ENC_I(i);
}