forked from wolfSSL/wolfssl
silence static analysis tool warning about null parameter after sanity check
This commit is contained in:
@@ -254,7 +254,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
return WC_KEY_SIZE_E;
|
return WC_KEY_SIZE_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(hmac->keyRaw, key, length);
|
XMEMCPY(hmac->keyRaw, key, length);
|
||||||
|
}
|
||||||
hmac->keyLen = (word16)length;
|
hmac->keyLen = (word16)length;
|
||||||
|
|
||||||
return 0; /* nothing to do here */
|
return 0; /* nothing to do here */
|
||||||
@@ -279,8 +281,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case MD5:
|
case MD5:
|
||||||
hmac_block_size = MD5_BLOCK_SIZE;
|
hmac_block_size = MD5_BLOCK_SIZE;
|
||||||
if (length <= MD5_BLOCK_SIZE) {
|
if (length <= MD5_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Md5Update(&hmac->hash.md5, key, length);
|
ret = wc_Md5Update(&hmac->hash.md5, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -297,8 +301,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case SHA:
|
case SHA:
|
||||||
hmac_block_size = SHA_BLOCK_SIZE;
|
hmac_block_size = SHA_BLOCK_SIZE;
|
||||||
if (length <= SHA_BLOCK_SIZE) {
|
if (length <= SHA_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_ShaUpdate(&hmac->hash.sha, key, length);
|
ret = wc_ShaUpdate(&hmac->hash.sha, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -317,8 +323,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
{
|
{
|
||||||
hmac_block_size = SHA224_BLOCK_SIZE;
|
hmac_block_size = SHA224_BLOCK_SIZE;
|
||||||
if (length <= SHA224_BLOCK_SIZE) {
|
if (length <= SHA224_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Sha224Update(&hmac->hash.sha224, key, length);
|
ret = wc_Sha224Update(&hmac->hash.sha224, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -337,8 +345,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case SHA256:
|
case SHA256:
|
||||||
hmac_block_size = SHA256_BLOCK_SIZE;
|
hmac_block_size = SHA256_BLOCK_SIZE;
|
||||||
if (length <= SHA256_BLOCK_SIZE) {
|
if (length <= SHA256_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
|
ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -357,8 +367,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case SHA384:
|
case SHA384:
|
||||||
hmac_block_size = SHA384_BLOCK_SIZE;
|
hmac_block_size = SHA384_BLOCK_SIZE;
|
||||||
if (length <= SHA384_BLOCK_SIZE) {
|
if (length <= SHA384_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
|
ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -374,8 +386,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case SHA512:
|
case SHA512:
|
||||||
hmac_block_size = SHA512_BLOCK_SIZE;
|
hmac_block_size = SHA512_BLOCK_SIZE;
|
||||||
if (length <= SHA512_BLOCK_SIZE) {
|
if (length <= SHA512_BLOCK_SIZE) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
|
ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -393,8 +407,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
|
|||||||
case BLAKE2B_ID:
|
case BLAKE2B_ID:
|
||||||
hmac_block_size = BLAKE2B_BLOCKBYTES;
|
hmac_block_size = BLAKE2B_BLOCKBYTES;
|
||||||
if (length <= BLAKE2B_BLOCKBYTES) {
|
if (length <= BLAKE2B_BLOCKBYTES) {
|
||||||
|
if (key != NULL) {
|
||||||
XMEMCPY(ip, key, length);
|
XMEMCPY(ip, key, length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_Blake2bUpdate(&hmac->hash.blake2b, key, length);
|
ret = wc_Blake2bUpdate(&hmac->hash.blake2b, key, length);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
Reference in New Issue
Block a user