1 /* test_ccm_mode.c - TinyCrypt AES-CCM tests (RFC 3610 tests) */
2
3 /*
4 * Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Intel Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /*
34 * DESCRIPTION
35 * This module tests the following AES-CCM Mode routines:
36 *
37 * Scenarios tested include:
38 * - AES128 CCM mode encryption RFC 3610 test vector #1
39 * - AES128 CCM mode encryption RFC 3610 test vector #2
40 * - AES128 CCM mode encryption RFC 3610 test vector #3
41 * - AES128 CCM mode encryption RFC 3610 test vector #7
42 * - AES128 CCM mode encryption RFC 3610 test vector #8
43 * - AES128 CCM mode encryption RFC 3610 test vector #9
44 * - AES128 CCM mode encryption No associated data
45 * - AES128 CCM mode encryption No payload data
46 */
47
48 #include <tinycrypt/ccm_mode.h>
49 #include <tinycrypt/constants.h>
50 #include <zephyr/test_utils.h>
51 #include <zephyr/ztest.h>
52
53 #include <string.h>
54
55 #define CIPHERTEXT_LEN 50
56 #define DECRYPTED_LEN 25
57 #define NUM_NIST_KEYS 16
58 #define NONCE_LEN 13
59 #define HEADER_LEN 8
60 #define M_LEN8 8
61 #define M_LEN10 10
62 #define DATA_BUF_LEN23 23
63 #define DATA_BUF_LEN24 24
64 #define DATA_BUF_LEN25 25
65 #define EXPECTED_BUF_LEN31 31
66 #define EXPECTED_BUF_LEN32 32
67 #define EXPECTED_BUF_LEN33 33
68 #define EXPECTED_BUF_LEN34 34
69 #define EXPECTED_BUF_LEN35 35
70
do_test(const uint8_t * key,uint8_t * nonce,size_t nlen,const uint8_t * hdr,size_t hlen,const uint8_t * data,size_t dlen,const uint8_t * expected,size_t elen,const int mlen)71 uint32_t do_test(const uint8_t *key,
72 uint8_t *nonce, size_t nlen,
73 const uint8_t *hdr, size_t hlen,
74 const uint8_t *data, size_t dlen,
75 const uint8_t *expected, size_t elen,
76 const int mlen)
77 {
78 uint32_t result = TC_PASS;
79 uint8_t ciphertext[CIPHERTEXT_LEN];
80 uint8_t decrypted[DECRYPTED_LEN];
81 struct tc_ccm_mode_struct c;
82 struct tc_aes_key_sched_struct sched;
83
84 tc_aes128_set_encrypt_key(&sched, key);
85
86 result = tc_ccm_config(&c, &sched, nonce, nlen, mlen);
87
88 /**TESTPOINT: Check CCM config*/
89 zassert_true(result, "CCM config failed");
90
91 result = tc_ccm_generation_encryption(ciphertext, sizeof(ciphertext),
92 hdr, hlen, data, dlen, &c);
93
94 /**TESTPOINT: Check CCM encrypt*/
95 zassert_true(result, "ccm_encrypt failed");
96
97 /**TESTPOINT: Verify ciphertext*/
98 if (memcmp(expected, ciphertext, elen) != 0) {
99 show_str("\t\tExpected", expected, elen);
100 show_str("\t\tComputed", ciphertext, elen);
101
102 /**ASSERTION: Signal wrong output and assert*/
103 zassert_true(0, "ccm_encrypt produced wrong ciphertext");
104 }
105
106 result = tc_ccm_decryption_verification(decrypted, sizeof(decrypted),
107 hdr, hlen, ciphertext,
108 dlen + mlen, &c);
109
110 /**TESTPOINT: Check decryption*/
111 if (result == 0U) {
112 show_str("\t\tExpected", data, dlen);
113 show_str("\t\tComputed", decrypted, sizeof(decrypted));
114
115 /**ASSERTION: Decrypt failed, so exit by assert*/
116 zassert_true(0, "ccm_decrypt failed");
117 }
118
119 result = TC_PASS;
120 return result;
121 }
122
ZTEST(tinycrypt,test_ccm_vector_1)123 ZTEST(tinycrypt, test_ccm_vector_1)
124 {
125 uint32_t result = TC_PASS;
126 /* RFC 3610 test vector #1 */
127 const uint8_t key[NUM_NIST_KEYS] = {
128 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
129 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
130 };
131 uint8_t nonce[NONCE_LEN] = {
132 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0,
133 0xa1, 0xa2, 0xa3, 0xa4, 0xa5
134 };
135 const uint8_t hdr[HEADER_LEN] = {
136 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
137 };
138 const uint8_t data[DATA_BUF_LEN23] = {
139 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
140 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
141 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e
142 };
143 const uint8_t expected[EXPECTED_BUF_LEN31] = {
144 0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2,
145 0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80,
146 0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84, 0x17,
147 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0
148 };
149 uint16_t mlen = M_LEN8;
150
151 TC_PRINT("%s: Performing CCM test #1 (RFC 3610 test vector #1):\n",
152 __func__);
153
154 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
155 data, sizeof(data), expected, sizeof(expected), mlen);
156
157 /**TESTPOINT: Check result*/
158 zassert_false(result, "CCM test #1 (RFC 3610 test vector #1) failed.");
159 }
160
ZTEST(tinycrypt,test_ccm_vector_2)161 ZTEST(tinycrypt, test_ccm_vector_2)
162 {
163 uint32_t result = TC_PASS;
164 /* RFC 3610 test vector #2 */
165 const uint8_t key[NUM_NIST_KEYS] = {
166 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
167 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
168 };
169 uint8_t nonce[NONCE_LEN] = {
170 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01, 0xa0,
171 0xa1, 0xa2, 0xa3, 0xa4, 0xa5
172 };
173 const uint8_t hdr[HEADER_LEN] = {
174 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
175 };
176 const uint8_t data[DATA_BUF_LEN24] = {
177 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
178 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
179 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
180 };
181 const uint8_t expected[EXPECTED_BUF_LEN32] = {
182 0x72, 0xc9, 0x1a, 0x36, 0xe1, 0x35, 0xf8, 0xcf,
183 0x29, 0x1c, 0xa8, 0x94, 0x08, 0x5c, 0x87, 0xe3,
184 0xcc, 0x15, 0xc4, 0x39, 0xc9, 0xe4, 0x3a, 0x3b,
185 0xa0, 0x91, 0xd5, 0x6e, 0x10, 0x40, 0x09, 0x16
186 };
187 uint16_t mlen = M_LEN8;
188
189 TC_PRINT("%s: Performing CCM test #2 (RFC 3610 test vector #2):\n",
190 __func__);
191
192 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
193 data, sizeof(data), expected, sizeof(expected), mlen);
194
195 /**TESTPOINT: Check result*/
196 zassert_false(result, "CCM test #2 failed.");
197 }
198
ZTEST(tinycrypt,test_ccm_vector_3)199 ZTEST(tinycrypt, test_ccm_vector_3)
200 {
201 uint32_t result = TC_PASS;
202 /* RFC 3610 test vector #3 */
203 const uint8_t key[NUM_NIST_KEYS] = {
204 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
205 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
206 };
207 uint8_t nonce[NONCE_LEN] = {
208 0x00, 0x00, 0x00, 0x05, 0x04, 0x03, 0x02, 0xa0,
209 0xa1, 0xa2, 0xa3, 0xa4, 0xa5
210 };
211 const uint8_t hdr[HEADER_LEN] = {
212 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
213 };
214 const uint8_t data[DATA_BUF_LEN25] = {
215 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
216 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
217 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
218 0x20
219 };
220 const uint8_t expected[EXPECTED_BUF_LEN33] = {
221 0x51, 0xb1, 0xe5, 0xf4, 0x4a, 0x19, 0x7d, 0x1d,
222 0xa4, 0x6b, 0x0f, 0x8e, 0x2d, 0x28, 0x2a, 0xe8,
223 0x71, 0xe8, 0x38, 0xbb, 0x64, 0xda, 0x85, 0x96,
224 0x57, 0x4a, 0xda, 0xa7, 0x6f, 0xbd, 0x9f, 0xb0,
225 0xc5
226 };
227 uint16_t mlen = M_LEN8;
228
229 TC_PRINT("%s: Performing CCM test #3 (RFC 3610 test vector #3):\n",
230 __func__);
231
232 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr), data,
233 sizeof(data), expected, sizeof(expected), mlen);
234
235 /**TESTPOINT: Check result*/
236 zassert_false(result, "CCM test #3 failed.");
237 }
238
ZTEST(tinycrypt,test_ccm_vector_4)239 ZTEST(tinycrypt, test_ccm_vector_4)
240 {
241 uint32_t result = TC_PASS;
242 /* RFC 3610 test vector #7 */
243 const uint8_t key[NUM_NIST_KEYS] = {
244 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
245 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf
246 };
247 uint8_t nonce[NONCE_LEN] = {
248 0x00, 0x00, 0x00, 0x09, 0x08, 0x07, 0x06, 0xa0,
249 0xa1, 0xa2, 0xa3, 0xa4, 0xa5
250 };
251 const uint8_t hdr[HEADER_LEN] = {
252 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
253 };
254 const uint8_t data[DATA_BUF_LEN23] = {
255 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
256 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
257 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e
258 };
259 const uint8_t expected[EXPECTED_BUF_LEN33] = {
260 0x01, 0x35, 0xD1, 0xB2, 0xC9, 0x5F, 0x41, 0xD5,
261 0xD1, 0xD4, 0xFE, 0xC1, 0x85, 0xD1, 0x66, 0xB8,
262 0x09, 0x4E, 0x99, 0x9D, 0xFE, 0xD9, 0x6C, 0x04,
263 0x8C, 0x56, 0x60, 0x2C, 0x97, 0xAC, 0xBB, 0x74,
264 0x90
265 };
266 uint16_t mlen = M_LEN10;
267
268 TC_PRINT("%s: Performing CCM test #4 (RFC 3610 test vector #7):\n",
269 __func__);
270
271 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
272 data, sizeof(data), expected, sizeof(expected), mlen);
273
274 /**TESTPOINT: Check result*/
275 zassert_false(result, "CCM test #4 failed.");
276 }
277
ZTEST(tinycrypt,test_ccm_vector_5)278 ZTEST(tinycrypt, test_ccm_vector_5)
279 {
280 uint32_t result = TC_PASS;
281 /* RFC 3610 test vector #8 */
282 const uint8_t key[NUM_NIST_KEYS] = {
283 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
284 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
285 };
286 uint8_t nonce[NONCE_LEN] = {
287 0x00, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x07, 0xA0,
288 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
289 };
290 const uint8_t hdr[HEADER_LEN] = {
291 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
292 };
293 const uint8_t data[DATA_BUF_LEN24] = {
294 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
295 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
296 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
297 };
298 const uint8_t expected[EXPECTED_BUF_LEN34] = {
299 0x7B, 0x75, 0x39, 0x9A, 0xC0, 0x83, 0x1D, 0xD2,
300 0xF0, 0xBB, 0xD7, 0x58, 0x79, 0xA2, 0xFD, 0x8F,
301 0x6C, 0xAE, 0x6B, 0x6C, 0xD9, 0xB7, 0xDB, 0x24,
302 0xC1, 0x7B, 0x44, 0x33, 0xF4, 0x34, 0x96, 0x3F,
303 0x34, 0xB4
304 };
305 uint16_t mlen = M_LEN10;
306
307 TC_PRINT("%s: Performing CCM test #5 (RFC 3610 test vector #8):\n",
308 __func__);
309
310 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
311 data, sizeof(data), expected, sizeof(expected), mlen);
312
313 /**TESTPOINT: Check result*/
314 zassert_false(result, "CCM test #5 failed.");
315 }
316
ZTEST(tinycrypt,test_ccm_vector_6)317 ZTEST(tinycrypt, test_ccm_vector_6)
318 {
319 uint32_t result = TC_PASS;
320 /* RFC 3610 test vector #9 */
321 const uint8_t key[NUM_NIST_KEYS] = {
322 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
323 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
324 };
325 uint8_t nonce[NONCE_LEN] = {
326 0x00, 0x00, 0x00, 0x0B, 0x0A, 0x09, 0x08, 0xA0,
327 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
328 };
329 const uint8_t hdr[HEADER_LEN] = {
330 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
331 };
332 const uint8_t data[DATA_BUF_LEN25] = {
333 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
334 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
335 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
336 0x20
337 };
338 const uint8_t expected[EXPECTED_BUF_LEN35] = {
339 0x82, 0x53, 0x1a, 0x60, 0xCC, 0x24, 0x94, 0x5a,
340 0x4b, 0x82, 0x79, 0x18, 0x1a, 0xb5, 0xc8, 0x4d,
341 0xf2, 0x1c, 0xe7, 0xf9, 0xb7, 0x3f, 0x42, 0xe1,
342 0x97, 0xea, 0x9c, 0x07, 0xe5, 0x6b, 0x5e, 0xb1,
343 0x7e, 0x5f, 0x4e
344 };
345 uint16_t mlen = M_LEN10;
346
347 TC_PRINT("%s: Performing CCM test #6 (RFC 3610 test vector #9):\n",
348 __func__);
349
350 result = do_test(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
351 data, sizeof(data), expected, sizeof(expected), mlen);
352
353 /**TESTPOINT: Check result*/
354 zassert_false(result, "CCM test #6 failed.");
355 }
356
ZTEST(tinycrypt,test_ccm_vector_7)357 ZTEST(tinycrypt, test_ccm_vector_7)
358 {
359 uint32_t result = TC_PASS;
360 /* Test based on RFC 3610 test vector #9 but with no associated data */
361 const uint8_t key[NUM_NIST_KEYS] = {
362 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
363 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
364 };
365 uint8_t nonce[NONCE_LEN] = {
366 0x00, 0x00, 0x00, 0x0B, 0x0A, 0x09, 0x08, 0xA0,
367 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
368 };
369 uint8_t *hdr = NULL;
370
371 uint8_t data[DATA_BUF_LEN25] = {
372 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
373 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
374 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
375 0x20
376 };
377 struct tc_ccm_mode_struct c;
378 struct tc_aes_key_sched_struct sched;
379 uint8_t decrypted[DECRYPTED_LEN];
380 uint8_t ciphertext[CIPHERTEXT_LEN];
381 uint16_t mlen = M_LEN10;
382
383 TC_PRINT("%s: Performing CCM test #7 (no associated data):\n",
384 __func__);
385
386 tc_aes128_set_encrypt_key(&sched, key);
387
388 /**TESTPOINT: Check CCM configuration*/
389 zassert_true(tc_ccm_config(&c, &sched, nonce, sizeof(nonce), mlen),
390 "ccm_config failed");
391
392 result = tc_ccm_generation_encryption(ciphertext, sizeof(ciphertext),
393 hdr, 0, data, sizeof(data), &c);
394 /**TESTPOINT: Check CCM encryption*/
395 zassert_true(result, "ccm_encryption failed");
396
397 result = tc_ccm_decryption_verification(decrypted, sizeof(decrypted),
398 hdr, 0, ciphertext,
399 sizeof(data) + mlen, &c);
400
401 if (result == 0U) {
402 TC_ERROR("ccm_decrypt failed in %s.\n", __func__);
403 show_str("\t\tExpected", data, sizeof(data));
404 show_str("\t\tComputed", decrypted, sizeof(decrypted));
405
406 /**TESTPOINT: Check CCM decryption, and assert*/
407 zassert_true(result, "ccm_decryption failed");
408
409 }
410
411 result = TC_PASS;
412
413 /**TESTPOINT: Check result*/
414 zassert_false(result, "CCM test #7 failed.");
415
416 }
417
ZTEST(tinycrypt,test_ccm_vector_8)418 ZTEST(tinycrypt, test_ccm_vector_8)
419 {
420 uint32_t result = TC_PASS;
421 /* Test based on RFC 3610 test vector #9 but with no payload data */
422 const uint8_t key[NUM_NIST_KEYS] = {
423 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
424 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
425 };
426 uint8_t nonce[NONCE_LEN] = {
427 0x00, 0x00, 0x00, 0x0B, 0x0A, 0x09, 0x08, 0xA0,
428 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
429 };
430 const uint8_t hdr[8] = {
431 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
432 };
433 uint8_t data[] = {};
434 struct tc_ccm_mode_struct c;
435 struct tc_aes_key_sched_struct sched;
436 uint8_t decrypted[DECRYPTED_LEN];
437 uint8_t ciphertext[CIPHERTEXT_LEN];
438 uint16_t mlen = M_LEN10;
439
440 TC_PRINT("%s: Performing CCM test #8 (no payload data):\n", __func__);
441
442 tc_aes128_set_encrypt_key(&sched, key);
443
444 /**TESTPOINT: Check CCM configuration*/
445 zassert_true(tc_ccm_config(&c, &sched, nonce, sizeof(nonce), mlen),
446 "CCM config failed");
447
448 result = tc_ccm_generation_encryption(ciphertext, sizeof(ciphertext),
449 hdr, sizeof(hdr), data,
450 sizeof(data), &c);
451 /**TESTPOINT: Check CCM encryption*/
452 zassert_true(result, "ccm_encrypt failed");
453
454 result = tc_ccm_decryption_verification(decrypted, sizeof(decrypted),
455 hdr, sizeof(hdr),
456 ciphertext, mlen, &c);
457 /**TESTPOINT: Check CCM decryption*/
458 if (result == 0U) {
459 show_str("\t\tExpected", data, sizeof(data));
460 show_str("\t\tComputed", decrypted, sizeof(decrypted));
461
462 /**ASSERTION: Decrypt failed, so exit by assert*/
463 zassert_true(0, "ccm_decrypt failed");
464 }
465
466 result = TC_PASS;
467 TC_END_RESULT(result);
468
469 /**TESTPOINT: Check result*/
470 zassert_false(result, "CCM test #8 (no payload data) failed.");
471 }
472