silence static analysis tool warning about null parameter after sanity check

This commit is contained in:
Jacob Barthelmeh
2017-04-13 15:32:31 -06:00
parent 620d21c850
commit ebde18af59

View File

@ -254,7 +254,9 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
return WC_KEY_SIZE_E;
}
if (key != NULL) {
XMEMCPY(hmac->keyRaw, key, length);
}
hmac->keyLen = (word16)length;
return 0; /* nothing to do here */
@ -279,8 +281,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case MD5:
hmac_block_size = MD5_BLOCK_SIZE;
if (length <= MD5_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Md5Update(&hmac->hash.md5, key, length);
if (ret != 0)
@ -297,8 +301,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA:
hmac_block_size = SHA_BLOCK_SIZE;
if (length <= SHA_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_ShaUpdate(&hmac->hash.sha, key, length);
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;
if (length <= SHA224_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha224Update(&hmac->hash.sha224, key, length);
if (ret != 0)
@ -337,8 +345,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA256:
hmac_block_size = SHA256_BLOCK_SIZE;
if (length <= SHA256_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
if (ret != 0)
@ -357,8 +367,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA384:
hmac_block_size = SHA384_BLOCK_SIZE;
if (length <= SHA384_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
if (ret != 0)
@ -374,8 +386,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case SHA512:
hmac_block_size = SHA512_BLOCK_SIZE;
if (length <= SHA512_BLOCK_SIZE) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
if (ret != 0)
@ -393,8 +407,10 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
case BLAKE2B_ID:
hmac_block_size = BLAKE2B_BLOCKBYTES;
if (length <= BLAKE2B_BLOCKBYTES) {
if (key != NULL) {
XMEMCPY(ip, key, length);
}
}
else {
ret = wc_Blake2bUpdate(&hmac->hash.blake2b, key, length);
if (ret != 0)