From 5b47ca7395703b9d2234412c570ba9c15eede62d Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Wed, 16 Nov 2016 16:43:32 -0600 Subject: [PATCH] tests/tinycrypt: Fix wrong sizeof argument in test_ccm_mode This commit fixes the wrong sizeof argument error reported by Coverity. Coverity-CID: 152032 Change-Id: I2ee3089b4b840f4a1b8ba0303e92a3311c07ffeb Signed-off-by: Flavio Santes --- tests/crypto/test_ccm_mode/src/test_ccm_mode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/crypto/test_ccm_mode/src/test_ccm_mode.c b/tests/crypto/test_ccm_mode/src/test_ccm_mode.c index 3008064c365..04768b5dcbf 100644 --- a/tests/crypto/test_ccm_mode/src/test_ccm_mode.c +++ b/tests/crypto/test_ccm_mode/src/test_ccm_mode.c @@ -410,7 +410,7 @@ uint32_t test_vector_8(void) 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; - uint8_t *data = NULL; + uint8_t data[] = {}; struct tc_ccm_mode_struct c; struct tc_aes_key_sched_struct sched; @@ -426,14 +426,17 @@ uint32_t test_vector_8(void) goto exitTest1; } - if (tc_ccm_generation_encryption(ciphertext, hdr, sizeof(hdr), data, 0, &c) == 0) { + result = tc_ccm_generation_encryption(ciphertext, hdr, sizeof(hdr), + data, sizeof(data), &c); + if (result == 0) { TC_ERROR("ccm_encrypt failed in %s.\n", __func__); result = TC_FAIL; goto exitTest1; } - if (tc_ccm_decryption_verification(decrypted, hdr, sizeof(hdr), - ciphertext, mlen, &c) == 0) { + result = tc_ccm_decryption_verification(decrypted, hdr, sizeof(hdr), + ciphertext, mlen, &c); + if (result == 0) { TC_ERROR("ccm_decrypt failed in %s.\n", __func__); show_str("\t\tExpected", data, sizeof(data)); show_str("\t\tComputed", decrypted, sizeof(decrypted)); @@ -441,6 +444,8 @@ uint32_t test_vector_8(void) goto exitTest1; } + result = TC_PASS; + exitTest1: TC_END_RESULT(result); return result;