forked from wolfSSL/wolfssl
Fix for wc_CryptoCb_AesCbcEncrypt
with improper find device logic. Fix for HMAC scan-build with ret
. Cleanup of HMAC formatting.
This commit is contained in:
@@ -382,7 +382,6 @@ int wc_CryptoCb_AesCbcEncrypt(Aes* aes, byte* out,
|
|||||||
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
dev = wc_CryptoCb_FindDeviceByIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = wc_CryptoCb_FindDevice(aes->devId);
|
|
||||||
if (dev && dev->cb) {
|
if (dev && dev->cb) {
|
||||||
wc_CryptoInfo cryptoInfo;
|
wc_CryptoInfo cryptoInfo;
|
||||||
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
|
||||||
|
@@ -377,7 +377,6 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_SHA224
|
#ifdef WOLFSSL_SHA224
|
||||||
case WC_SHA224:
|
case WC_SHA224:
|
||||||
{
|
|
||||||
hmac_block_size = WC_SHA224_BLOCK_SIZE;
|
hmac_block_size = WC_SHA224_BLOCK_SIZE;
|
||||||
if (length <= WC_SHA224_BLOCK_SIZE) {
|
if (length <= WC_SHA224_BLOCK_SIZE) {
|
||||||
if (key != NULL) {
|
if (key != NULL) {
|
||||||
@@ -394,10 +393,8 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
|
|
||||||
length = WC_SHA224_DIGEST_SIZE;
|
length = WC_SHA224_DIGEST_SIZE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif /* WOLFSSL_SHA224 */
|
#endif /* WOLFSSL_SHA224 */
|
||||||
|
|
||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
case WC_SHA256:
|
case WC_SHA256:
|
||||||
hmac_block_size = WC_SHA256_BLOCK_SIZE;
|
hmac_block_size = WC_SHA256_BLOCK_SIZE;
|
||||||
@@ -626,7 +623,6 @@ static int HmacKeyInnerHash(Hmac* hmac)
|
|||||||
WC_SHA224_BLOCK_SIZE);
|
WC_SHA224_BLOCK_SIZE);
|
||||||
break;
|
break;
|
||||||
#endif /* WOLFSSL_SHA224 */
|
#endif /* WOLFSSL_SHA224 */
|
||||||
|
|
||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
case WC_SHA256:
|
case WC_SHA256:
|
||||||
ret = wc_Sha256Update(&hmac->hash.sha256, (byte*)hmac->ipad,
|
ret = wc_Sha256Update(&hmac->hash.sha256, (byte*)hmac->ipad,
|
||||||
@@ -815,7 +811,6 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
|
|||||||
if (ret != CRYPTOCB_UNAVAILABLE)
|
if (ret != CRYPTOCB_UNAVAILABLE)
|
||||||
return ret;
|
return ret;
|
||||||
/* fall-through when unavailable */
|
/* fall-through when unavailable */
|
||||||
ret = 0; /* reset error code */
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
|
||||||
@@ -878,7 +873,6 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_SHA224
|
#ifdef WOLFSSL_SHA224
|
||||||
case WC_SHA224:
|
case WC_SHA224:
|
||||||
{
|
|
||||||
ret = wc_Sha224Final(&hmac->hash.sha224, (byte*)hmac->innerHash);
|
ret = wc_Sha224Final(&hmac->hash.sha224, (byte*)hmac->innerHash);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
@@ -893,10 +887,8 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
|
|||||||
ret = wc_Sha224Final(&hmac->hash.sha224, hash);
|
ret = wc_Sha224Final(&hmac->hash.sha224, hash);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif /* WOLFSSL_SHA224 */
|
#endif /* WOLFSSL_SHA224 */
|
||||||
|
|
||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
case WC_SHA256:
|
case WC_SHA256:
|
||||||
ret = wc_Sha256Final(&hmac->hash.sha256, (byte*)hmac->innerHash);
|
ret = wc_Sha256Final(&hmac->hash.sha256, (byte*)hmac->innerHash);
|
||||||
@@ -1127,7 +1119,6 @@ void wc_HmacFree(Hmac* hmac)
|
|||||||
wc_Sha224Free(&hmac->hash.sha224);
|
wc_Sha224Free(&hmac->hash.sha224);
|
||||||
break;
|
break;
|
||||||
#endif /* WOLFSSL_SHA224 */
|
#endif /* WOLFSSL_SHA224 */
|
||||||
|
|
||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
case WC_SHA256:
|
case WC_SHA256:
|
||||||
wc_Sha256Free(&hmac->hash.sha256);
|
wc_Sha256Free(&hmac->hash.sha256);
|
||||||
@@ -1199,7 +1190,6 @@ void wc_HmacFree(Hmac* hmac)
|
|||||||
wc_Sha224Free(&hmac->hash.sha224);
|
wc_Sha224Free(&hmac->hash.sha224);
|
||||||
break;
|
break;
|
||||||
#endif /* WOLFSSL_SHA224 */
|
#endif /* WOLFSSL_SHA224 */
|
||||||
|
|
||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
case WC_SHA256:
|
case WC_SHA256:
|
||||||
wc_Sha256Free(&hmac->hash.sha256);
|
wc_Sha256Free(&hmac->hash.sha256);
|
||||||
|
Reference in New Issue
Block a user