Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit 1d9047f

Browse files
tinycrypt/hmac: Array compared to NULL has no effect
This commit fixes the issue reported by Coverity/Zephyr: an array compared against NULL is always false. Coverity-CID: 143687 Coverity-CID: 143737 Coverity-CID: 143740 Change-Id: If6234b4b3d169a4023b7adaa545be79f48ac3dea Signed-off-by: Flavio Santes <[email protected]>
1 parent 351636e commit 1d9047f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/source/hmac.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ int32_t tc_hmac_set_key(TCHmacState_t ctx,
9696
int32_t tc_hmac_init(TCHmacState_t ctx)
9797
{
9898
/* input sanity check: */
99-
if (ctx == (TCHmacState_t) 0 ||
100-
ctx->key == (uint8_t *) 0) {
99+
if (ctx == (TCHmacState_t) 0) {
101100
return TC_CRYPTO_FAIL;
102101
}
103102

@@ -114,7 +113,7 @@ int32_t tc_hmac_update(TCHmacState_t ctx,
114113
uint32_t data_length)
115114
{
116115
/* input sanity check: */
117-
if (ctx == (TCHmacState_t) 0 || ctx->key == (uint8_t *) 0) {
116+
if (ctx == (TCHmacState_t) 0) {
118117
return TC_CRYPTO_FAIL;
119118
}
120119

@@ -128,8 +127,7 @@ int32_t tc_hmac_final(uint8_t *tag, uint32_t taglen, TCHmacState_t ctx)
128127
/* input sanity check: */
129128
if (tag == (uint8_t *) 0 ||
130129
taglen != TC_SHA256_DIGEST_SIZE ||
131-
ctx == (TCHmacState_t) 0 ||
132-
ctx->key == (uint8_t *) 0) {
130+
ctx == (TCHmacState_t) 0) {
133131
return TC_CRYPTO_FAIL;
134132
}
135133

0 commit comments

Comments
 (0)