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

Commit 3e4e536

Browse files
author
Ramakrishna Pallala
committed
tinycrypt/hmac: Array compared to NULL has no effect
This commit fixes the issue reported by Coverity: an array compared against NULL is always false. Signed-off-by: Ramakrishna Pallala <[email protected]>
1 parent 7c7e5c6 commit 3e4e536

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/source/hmac.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ int tc_hmac_init(TCHmacState_t ctx)
9797
{
9898

9999
/* input sanity check: */
100-
if (ctx == (TCHmacState_t) 0 ||
101-
ctx->key == (uint8_t *) 0) {
100+
if (ctx == (TCHmacState_t) 0) {
102101
return TC_CRYPTO_FAIL;
103102
}
104103

@@ -114,8 +113,7 @@ int tc_hmac_update(TCHmacState_t ctx,
114113
{
115114

116115
/* input sanity check: */
117-
if (ctx == (TCHmacState_t) 0 ||
118-
ctx->key == (uint8_t *) 0) {
116+
if (ctx == (TCHmacState_t) 0) {
119117
return TC_CRYPTO_FAIL;
120118
}
121119

@@ -130,8 +128,7 @@ int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx)
130128
/* input sanity check: */
131129
if (tag == (uint8_t *) 0 ||
132130
taglen != TC_SHA256_DIGEST_SIZE ||
133-
ctx == (TCHmacState_t) 0 ||
134-
ctx->key == (uint8_t *) 0) {
131+
ctx == (TCHmacState_t) 0) {
135132
return TC_CRYPTO_FAIL;
136133
}
137134

0 commit comments

Comments
 (0)