From 3e4e536c33f9e8ca32eeae1e32885371bed31131 Mon Sep 17 00:00:00 2001 From: Ramakrishna Pallala Date: Tue, 29 Aug 2017 08:09:08 -0400 Subject: [PATCH 1/2] 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 --- lib/source/hmac.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/source/hmac.c b/lib/source/hmac.c index 3f4dadd..89878ce 100644 --- a/lib/source/hmac.c +++ b/lib/source/hmac.c @@ -97,8 +97,7 @@ int tc_hmac_init(TCHmacState_t ctx) { /* input sanity check: */ - if (ctx == (TCHmacState_t) 0 || - ctx->key == (uint8_t *) 0) { + if (ctx == (TCHmacState_t) 0) { return TC_CRYPTO_FAIL; } @@ -114,8 +113,7 @@ int tc_hmac_update(TCHmacState_t ctx, { /* input sanity check: */ - if (ctx == (TCHmacState_t) 0 || - ctx->key == (uint8_t *) 0) { + if (ctx == (TCHmacState_t) 0) { return TC_CRYPTO_FAIL; } @@ -130,8 +128,7 @@ int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx) /* input sanity check: */ if (tag == (uint8_t *) 0 || taglen != TC_SHA256_DIGEST_SIZE || - ctx == (TCHmacState_t) 0 || - ctx->key == (uint8_t *) 0) { + ctx == (TCHmacState_t) 0) { return TC_CRYPTO_FAIL; } From 72ed9c800348f5a7b703aeb82bc634b37ad641f6 Mon Sep 17 00:00:00 2001 From: Ramakrishna Pallala Date: Tue, 29 Aug 2017 08:12:20 -0400 Subject: [PATCH 2/2] tinycrypt/sha256: 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 --- lib/source/sha256.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/source/sha256.c b/lib/source/sha256.c index 2fbee4f..b4efd20 100644 --- a/lib/source/sha256.c +++ b/lib/source/sha256.c @@ -66,7 +66,6 @@ int tc_sha256_update(TCSha256State_t s, const uint8_t *data, size_t datalen) { /* input sanity check: */ if (s == (TCSha256State_t) 0 || - s->iv == (unsigned int *) 0 || data == (void *) 0) { return TC_CRYPTO_FAIL; } else if (datalen == 0) { @@ -91,8 +90,7 @@ int tc_sha256_final(uint8_t *digest, TCSha256State_t s) /* input sanity check: */ if (digest == (uint8_t *) 0 || - s == (TCSha256State_t) 0 || - s->iv == (unsigned int *) 0) { + s == (TCSha256State_t) 0) { return TC_CRYPTO_FAIL; }