AESCCM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2024, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, 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 Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software 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,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file AESCCM.h
34  *
35  * @brief AESCCM driver header
36  *
37  * @anchor ti_drivers_AESCCM_Overview
38  * # Overview #
39  * The Counter with CBC-MAC (CCM) mode of operation is a generic
40  * authenticated encryption block cipher mode. It can be used with
41  * any block cipher.
42  * AESCCM combines CBC-MAC with an AES block cipher in CTR mode of operation.
43  *
44  * This combination of block cipher modes enables CCM to encrypt messages of any
45  * length and not only multiples of the block cipher block size.
46  *
47  * CTR provides confidentiality. The defined application of CBC-MAC provides
48  * message integrity and authentication.
49  *
50  * AESCCM has the following inputs and outputs:
51  *
52  * <table>
53  * <caption id="AESCCM_multi_row">AES-CCM input and output parameters</caption>
54  * <tr><th>Encryption</th><th>Decryption</th></tr>
55  * <tr><th colspan=2>Input</th></tr>
56  * <tr><td>Shared AES key</td><td> Shared AES key</td></tr>
57  * <tr><td>Nonce</td><td>Nonce</td></tr>
58  * <tr><td>Cleartext</td><td>Ciphertext</td></tr>
59  * <tr><td></td><td>MAC</td></tr>
60  * <tr><td>AAD (optional)</td><td>AAD (optional)</td></tr>
61  * <tr><th colspan=2>Output</th></tr>
62  * <tr><td>Ciphertext</td><td>Cleartext</td></tr>
63  * <tr><td>MAC</td><td></td></tr>
64  * </table>
65  *
66  * The AES key is a shared secret between the two parties and has a length
67  * of 128, 192, or 256 bits.
68  *
69  * The nonce is generated by the party performing the authenticated
70  * encryption operation. Within the scope of any authenticated
71  * encryption key, the nonce value must be unique. That is, the set of
72  * nonce values used with any given key must not contain any duplicate
73  * values. Using the same nonce for two different messages encrypted
74  * with the same key destroys the security properties.
75  *
76  * The length of the nonce determines the maximum number of messages that may
77  * be encrypted and authenticated before you must regenerate the key.
78  * Reasonable session key rotation schemes will regenerate the key before reaching
79  * this limit.
80  * There is a trade-off between the nonce-length and the maximum length of
81  * the plaintext to encrypt and authenticate per nonce. This is because
82  * CTR concatenates the nonce and an internal counter into one 16-byte
83  * IV. The counter is incremented after generating an AES-block-sized
84  * pseudo-random bitstream. This bitstream is XOR'd with the plaintext.
85  * The counter would eventually roll over for a sufficiently long message.
86  * This is must not happen. Hence, the longer the nonce and the more messages
87  * you can send before needing to rotate the key, the shorter the
88  * lengths of individual messages sent may be. The minimum and maximum
89  * nonce length defined by the CCM standard provide for both a reasonable
90  * number of messages before key rotation and a reasonable maximum message length.
91  * Check NIST SP 800-38C for details.
92  *
93  * The optional additional authentication data (AAD) is authenticated
94  * but not encrypted. Thus, the AAD is not included in the AES-CCM output.
95  * It can be used to authenticate packet headers.
96  *
97  * After the encryption operation, the ciphertext contains the encrypted
98  * data. The message authentication code (MAC) is also provided.
99  *
100  * # CCM Variations #
101  * The AESCCM driver supports both classic CCM as defined by NIST SP 800-38C and
102  * the CCM* variant used in IEEE 802.15.4.
103  * CCM* allows for unauthenticated encryption using CCM by permitting a MAC length
104  * of 0. It also imposes the requirement that the MAC length be embedded in
105  * the nonce used for each message if the MAC length varies within the protocol
106  * using CCM*.
107  *
108  * @anchor ti_drivers_AESCCM_Usage
109  * # Usage #
110  *
111  * ## Before starting a CCM operation #
112  *
113  * Before starting a CCM operation, the application must do the following:
114  * - Call AESCCM_init() to initialize the driver
115  * - Call AESCCM_Params_init() to initialize the AESCCM_Params to default values.
116  * - Modify the AESCCM_Params as desired
117  * - Call AESCCM_open() to open an instance of the driver
118  * - Initialize a CryptoKey. These opaque data structures are representations
119  * of keying material and its storage. Depending on how the keying material
120  * is stored (RAM or flash, key store), the CryptoKey must be
121  * initialized differently. The AESCCM API can handle all types of CryptoKey.
122  * However, not all device-specific implementations support all types of CryptoKey.
123  * Devices without a key store will not support CryptoKeys with keying material
124  * stored in a key store for example.
125  * All devices support plaintext CryptoKeys.
126  * - Initialize the appropriate AESCCM operation struct using the relevant
127  * operation init functions and set all fields. For example, one-step (one-shot
128  * or single call) operations should initialize AESCCM_Operation or
129  * AESCCM_OneStepOperation using AESCCM_Operation_init() or
130  * AESCCM_OneStepOperation_init(). For multi-step (segmented or multiple call)
131  * operations, AESCCM_SegmentedAADOperation must be initialized and set when
132  * processing AAD. AESCCM_SegmentedDataOperation must be initialized and set when
133  * dealing with payload data (plaintext or ciphertext). AESCCM_SegmentedFinalizeOperation
134  * must be initialized and set when finalizing the segmented operation.
135  *
136  * ## Device-Specific Requirements #
137  *
138  * For CC27XX devices, the output buffer address must be 32-bit aligned.
139  *
140  * ## Starting a CCM operation #
141  *
142  * The AESCCM_oneStepEncrypt and AESCCM_oneStepDecrypt functions do a CCM operation in a single call.
143  * They will always be the most highly optimized routines with the least overhead and the fastest
144  * runtime. However, they require all AAD and plaintext or ciphertext data to be
145  * available to the function at the start of the call.
146  * All devices support single call operations.
147  *
148  * When performing a decryption operation with AESCCM_oneStepDecrypt(), the MAC is
149  * automatically verified.
150  *
151  * ## After the CCM operation completes #
152  *
153  * After the CCM operation completes, the application should either start another operation
154  * or close the driver by calling AESCCM_close()
155  *
156  * @anchor ti_drivers_AESCCM_Synopsis
157  * ## Synopsis
158  *
159  * @anchor ti_drivers_AESCCM_Synopsis_Code
160  * @code
161  *
162  * // Import AESCCM Driver definitions
163  * #include <ti/drivers/AESCCM.h>
164  *
165  * // Define name for AESCCM channel index
166  * #define AESCCM_INSTANCE 0
167  *
168  * AESCCM_init();
169  *
170  * handle = AESCCM_open(AESCCM_INSTANCE, NULL);
171  *
172  * // Initialize symmetric key
173  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
174  *
175  * // Set up AESCCM_OneStepOperation
176  * AESCCM_OneStepOperation_init(&operation);
177  * operation.key = &cryptoKey;
178  * operation.aad = aad;
179  * operation.aadLength = sizeof(aad);
180  * operation.input = plaintext;
181  * operation.output = ciphertext;
182  * operation.inputLength = sizeof(plaintext);
183  * operation.nonce = nonce;
184  * operation.nonceLength = sizeof(nonce);
185  * operation.mac = mac;
186  * operation.macLength = sizeof(mac);
187  *
188  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
189  *
190  * AESCCM_close(handle);
191  * @endcode
192  *
193  * @anchor ti_drivers_AESCCM_Examples
194  * ## Examples
195  *
196  * ### Single call CCM encryption + authentication with plaintext CryptoKey in blocking return mode #
197  * @code
198  *
199  * #include <ti/drivers/AESCCM.h>
200  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
201  *
202  * ...
203  *
204  * AESCCM_Handle handle;
205  * CryptoKey cryptoKey;
206  * int_fast16_t encryptionResult;
207  * uint8_t nonce[] = "Thisisanonce";
208  * uint8_t aad[] = "This string will be authenticated but not encrypted.";
209  * uint8_t plaintext[] = "This string will be encrypted and authenticated.";
210  * uint8_t mac[16];
211  * uint8_t ciphertext[sizeof(plaintext)];
212  * uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
213  * 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
214  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
215  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
216  *
217  * handle = AESCCM_open(0, NULL);
218  *
219  * if (handle == NULL) {
220  * // handle error
221  * }
222  *
223  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
224  *
225  * AESCCM_OneStepOperation operation;
226  * AESCCM_OneStepOperation_init(&operation);
227  *
228  * operation.key = &cryptoKey;
229  * operation.aad = aad;
230  * operation.aadLength = sizeof(aad);
231  * operation.input = plaintext;
232  * operation.output = ciphertext;
233  * operation.inputLength = sizeof(plaintext);
234  * operation.nonce = nonce;
235  * operation.nonceLength = sizeof(nonce);
236  * operation.mac = mac;
237  * operation.macLength = sizeof(mac);
238  *
239  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
240  *
241  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
242  * // handle error
243  * }
244  *
245  * AESCCM_close(handle);
246  *
247  * @endcode
248  * ### The following code snippet is for CC27XX devices only and leverages the HSM
249  * which is a seperate Hardware Accelerator ###
250  * ### Single call CCM encryption + authentication with plaintext HSM CryptoKey in Polling Mode ###
251  *
252  * @code
253  *
254  * #include <ti/drivers/AESCCM.h>
255  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
256  *
257  * ...
258  *
259  * AESCCM_Params params;
260  * AESCCM_Handle handle;
261  * CryptoKey cryptoKey;
262  * int_fast16_t encryptionResult;
263  * uint8_t nonce[] = "Thisisanonce";
264  * uint8_t aad[] = "This string will be authenticated but not encrypted.";
265  * uint8_t plaintext[] = "This string will be encrypted and authenticated.";
266  * uint8_t mac[16];
267  * uint8_t ciphertext[sizeof(plaintext)];
268  * uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
269  * 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
270  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
271  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
272  *
273  * AESCCM_Params_init(&params)
274  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_POLLING;
275  *
276  * handle = AESCCM_open(0, &params);
277  *
278  * if (handle == NULL) {
279  * // handle error
280  * }
281  *
282  * CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
283  *
284  * AESCCM_OneStepOperation operation;
285  * AESCCM_OneStepOperation_init(&operation);
286  *
287  * operation.key = &cryptoKey;
288  * operation.aad = aad;
289  * operation.aadLength = sizeof(aad);
290  * operation.input = plaintext;
291  * operation.output = ciphertext;
292  * operation.inputLength = sizeof(plaintext);
293  * operation.nonce = nonce;
294  * operation.nonceLength = sizeof(nonce);
295  * operation.mac = mac;
296  * operation.macLength = sizeof(mac);
297  *
298  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
299  *
300  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
301  * // handle error
302  * }
303  *
304  * AESCCM_close(handle);
305  *
306  * @endcode
307  *
308  * ### Single call CCM decryption + verification with plaintext CryptoKey in callback return mode #
309  * @code
310  *
311  * #include <ti/drivers/AESCCM.h>
312  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
313  *
314  * ...
315  *
316  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
317  *
318  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
319  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
320  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
321  * uint8_t mac[] = {0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0};
322  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
323  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
324  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
325  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
326  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
327  * uint8_t plaintext[sizeof(ciphertext)];
328  *
329  * // The plaintext should be the following after the decryption operation:
330  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
331  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
332  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
333  *
334  *
335  * void ccmCallback(AESCCM_Handle handle,
336  * int_fast16_t returnValue,
337  * AESCCM_OperationUnion *operation,
338  * AESCCM_OperationType operationType) {
339  *
340  * if (returnValue != AESCCM_STATUS_SUCCESS) {
341  * // handle error
342  * }
343  * }
344  *
345  * AESCCM_OneStepOperation operation;
346  *
347  * void ccmStartFunction(void) {
348  * AESCCM_Handle handle;
349  * AESCCM_Params params;
350  * CryptoKey cryptoKey;
351  * int_fast16_t decryptionResult;
352  *
353  * AESCCM_Params_init(&params);
354  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
355  * params.callbackFxn = ccmCallback;
356  *
357  * handle = AESCCM_open(0, &params);
358  *
359  * if (handle == NULL) {
360  * // handle error
361  * }
362  *
363  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
364  *
365  * AESCCM_OneStepOperation_init(&operation);
366  *
367  * operation.key = &cryptoKey;
368  * operation.aad = aad;
369  * operation.aadLength = sizeof(aad);
370  * operation.input = ciphertext;
371  * operation.output = plaintext;
372  * operation.inputLength = sizeof(ciphertext);
373  * operation.nonce = nonce;
374  * operation.nonceLength = sizeof(nonce);
375  * operation.mac = mac;
376  * operation.macLength = sizeof(mac);
377  *
378  * decryptionResult = AESCCM_oneStepDecrypt(handle, &operation);
379  *
380  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
381  * // handle error
382  * }
383  *
384  * // do other things while CCM operation completes in the background
385  *
386  * }
387  *
388  *
389  * @endcode
390  *
391  * ### Multi-step CCM encryption + authentication with plaintext CryptoKey in blocking return mode #
392  * @code
393  *
394  * #include <ti/drivers/AESCCM.h>
395  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
396  *
397  * ...
398  *
399  * #define AES_BLOCK_SIZE 16 // bytes
400  *
401  * AESCCM_Handle handle;
402  * CryptoKey cryptoKey;
403  * int_fast16_t encryptionResult;
404  *
405  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
406  *
407  * uint8_t keyingMaterial[16] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
408  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
409  * uint8_t aad[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
410  * uint8_t plaintext[23] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
411  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
412  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E};
413  * uint8_t nonce[13] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
414  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
415  * uint8_t mac[8];
416  * uint8_t ciphertext[sizeof(plaintext)];
417  *
418  * // The ciphertext should be the following after the encryption operation:
419  * // {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
420  * // 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
421  * // 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84}
422  *
423  * handle = AESCCM_open(0, NULL);
424  *
425  * if (handle == NULL) {
426  * // handle error
427  * }
428  *
429  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
430  *
431  *
432  * encryptionResult = AESCCM_setupEncrypt(handle, &cryptoKey, sizeof(aad), sizeof(plaintext), sizeof(mac));
433  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
434  * // handle error
435  * }
436  *
437  * encryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
438  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
439  * // handle error
440  * }
441  *
442  * #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) // and the HSM is the engine of choice
443  *
444  * CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
445  *
446  * // You will also need to populate the mac in handle->object->mac because HSM needs the mac to construct each
447  * // segmented token.
448  * encryptionResult = AESCCMLPF3HSM_setMac(handle, &mac[0], 8);
449  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
450  * // handle error
451  * }
452  *
453  * #endif
454  *
455  * AESCCM_SegmentedAADOperation segmentedAADOperation;
456  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
457  * segmentedAADOperation.aad = aad;
458  * segmentedAADOperation.aadLength = sizeof(aad);
459  *
460  * encryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
461  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
462  * // handle error
463  * }
464  *
465  * AESCCM_SegmentedDataOperation segmentedDataOperation;
466  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
467  * segmentedDataOperation.input = plaintext;
468  * segmentedDataOperation.output = ciphertext;
469  * // One should pass in data that is a block-sized multiple length
470  * // until passing in the last segment of data.
471  * // In that case, the input length simply needs to be a non-zero value.
472  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
473  *
474  * encryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
475  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
476  * // handle error
477  * }
478  *
479  * segmentedDataOperation.input = plaintext + AES_BLOCK_SIZE;
480  * segmentedDataOperation.output = ciphertext + AES_BLOCK_SIZE;
481  * segmentedDataOperation.inputLength = sizeof(plaintext) - AES_BLOCK_SIZE;
482  *
483  * encryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
484  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
485  * // handle error
486  * }
487  *
488  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
489  * AESCCM_SegmentedFinalizeOperation_init(&segmentedFinalizeOperation);
490  * segmentedFinalizeOperation.input = plaintext;
491  * segmentedFinalizeOperation.output = ciphertext;
492  *
493  * // You can finalize with no new data
494  * segmentedFinalizeOperation.inputLength = 0;
495  * segmentedFinalizeOperation.mac = mac;
496  * segmentedFinalizeOperation.macLength = sizeof(mac);
497  * encryptionResult = AESCCM_finalizeEncrypt(handle, &segmentedFinalizeOperation);
498  *
499  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
500  * // handle error
501  * }
502  *
503  * AESCCM_close(handle);
504  *
505  * @endcode
506  *
507  * ### Multi-step CCM decryption + verification with plaintext CryptoKey in callback return mode #
508  * @code
509  *
510  * #include <ti/drivers/AESCCM.h>
511  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
512  *
513  * ...
514  *
515  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
516  *
517  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
518  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
519  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
520  * uint8_t mac[] = {0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0};
521  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
522  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
523  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
524  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
525  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
526  * uint8_t plaintext[sizeof(ciphertext)];
527  *
528  * // The plaintext should be the following after the decryption operation:
529  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
530  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
531  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
532  *
533  *
534  * void ccmCallback(AESCCM_Handle handle,
535  * int_fast16_t returnValue,
536  * AESCCM_OperationUnion *operation,
537  * AESCCM_OperationType operationType) {
538  *
539  * if (returnValue != AESCCM_STATUS_SUCCESS) {
540  * // handle error
541  * }
542  *
543  * if(operationType == AESCCM_OPERATION_TYPE_DECRYPT ||
544  * operationType == AESCCM_OPERATION_TYPE_ENCRYPT)
545  * {
546  * // Callback fxn only used for one-shot operations
547  * // Use operation->oneStepOperation
548  * }
549  * else if(operationType == AESCCM_OP_TYPE_AAD_DECRYPT ||
550  * operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)
551  * {
552  * // Callback fxn only used for segmented AAD operations
553  * // Use operation->segmentedAADOperation
554  * }
555  * else if(operationType == AESCCM_OP_TYPE_DATA_DECRYPT ||
556  * operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)
557  * {
558  * // Callback fxn only used for segmented data operations
559  * // Use operation->segmentedDataOperation
560  * }
561  * else
562  * {
563  * // Callback fxn only used for segmented finalize operations
564  * // Use operation->segmentedFinalizeOperation
565  * }
566  * }
567  *
568  * void ccmStartFunction(void) {
569  * AESCCM_Handle handle;
570  * AESCCM_Params params;
571  * CryptoKey cryptoKey;
572  * int_fast16_t decryptionResult;
573  *
574  * AESCCM_Params_init(&params);
575  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
576  * params.callbackFxn = ccmCallback;
577  *
578  * handle = AESCCM_open(0, &params);
579  *
580  * if (handle == NULL) {
581  * // handle error
582  * }
583  *
584  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
585  *
586  * decryptionResult = AESCCM_setupDecrypt(handle, &cryptoKey, 0, 0, 0);
587  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
588  * // handle error
589  * }
590  *
591  * // setLengths must be called if the AAD, input, and MAC lengths aren't provided in setupXXXX.
592  * decryptionResult = AESCCM_setLengths(handle, sizeof(aad), sizeof(ciphertext), sizeof(mac));
593  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
594  * // handle error
595  * }
596  *
597  * decryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
598  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
599  * // handle error
600  * }
601  *
602  * AESCCM_SegmentedAADOperation segmentedAADOperation;
603  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
604  * segmentedAADOperation.aad = aad;
605  * segmentedAADOperation.aadLength = sizeof(aad);
606  *
607  * decryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
608  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
609  * // handle error
610  * }
611  *
612  * AESCCM_SegmentedDataOperation segmentedDataOperation;
613  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
614  * segmentedDataOperation.input = ciphertext;
615  * segmentedDataOperation.output = plaintext;
616  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
617  *
618  * decryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
619  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
620  * // handle error
621  * }
622  *
623  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
624  * AESCCM_SegmentedFinalizeOperation_init(&segmentedFinalizeOperation);
625  * segmentedFinalizeOperation.input = ciphertext + AES_BLOCK_SIZE;
626  * segmentedFinalizeOperation.output = plaintext + AES_BLOCK_SIZE;
627  * segmentedFinalizeOperation.inputLength = sizeof(ciphertext) - AES_BLOCK_SIZE;
628  * segmentedFinalizeOperation.mac = mac;
629  * segmentedFinalizeOperation.macLength = sizeof(mac);
630  *
631  * decryptionResult = AESCCM_finalizeDecrypt(handle, &segmentedFinalizeOperation);
632  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
633  * // handle error
634  * }
635  *
636  * // do other things while CCM operation completes in the background
637  *
638  * }
639  *
640  * @endcode
641  *
642  * ### Multi-step CCM* decryption + verification with plaintext CryptoKey in callback return mode #
643  * @code
644  *
645  * #include <ti/drivers/AESCCM.h>
646  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
647  *
648  * ...
649  *
650  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
651  *
652  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
653  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
654  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
655  * uint8_t mac[] = {0};
656  *
657  * // CCM* allows for unauthenticated encryption using CCM by allowing a MAC length of 0
658  * uint8_t macLength = 0;
659  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
660  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
661  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
662  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
663  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
664  * uint8_t plaintext[sizeof(ciphertext)];
665  *
666  * // The plaintext should be the following after the decryption operation:
667  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
668  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
669  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
670  *
671  *
672  * void ccmCallback(AESCCM_Handle handle,
673  * int_fast16_t returnValue,
674  * AESCCM_OperationUnion *operation,
675  * AESCCM_OperationType operationType) {
676  *
677  * if (returnValue != AESCCM_STATUS_SUCCESS) {
678  * // handle error
679  * }
680  *
681  * if(operationType == AESCCM_OPERATION_TYPE_DECRYPT ||
682  * operationType == AESCCM_OPERATION_TYPE_ENCRYPT)
683  * {
684  * // Callback fxn only used for one-shot operations
685  * // Use operation->oneStepOperation
686  * }
687  * else if(operationType == AESCCM_OP_TYPE_AAD_DECRYPT ||
688  * operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)
689  * {
690  * // Callback fxn only used for segmented AAD operations
691  * // Use operation->segmentedAADOperation
692  * }
693  * else if(operationType == AESCCM_OP_TYPE_DATA_DECRYPT ||
694  * operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)
695  * {
696  * // Callback fxn only used for segmented data operations
697  * // Use operation->segmentedDataOperation
698  * }
699  * else
700  * {
701  * // Callback fxn only used for segmented finalize operations
702  * // Use operation->segmentedFinalizeOperation
703  * }
704  * }
705  *
706  * void ccmStartFunction(void) {
707  * AESCCM_Handle handle;
708  * AESCCM_Params params;
709  * CryptoKey cryptoKey;
710  * int_fast16_t decryptionResult;
711  *
712  * AESCCM_Params_init(&params);
713  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
714  * params.callbackFxn = ccmCallback;
715  *
716  * handle = AESCCM_open(0, &params);
717  *
718  * if (handle == NULL) {
719  * // handle error
720  * }
721  *
722  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
723  *
724  * decryptionResult = AESCCM_setupDecrypt(handle, &cryptoKey, 0, 0, 0);
725  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
726  * // handle error
727  * }
728  *
729  * // setLengths must be called if the AAD, input, and MAC lengths aren't provided in setupXXXX.
730  * decryptionResult = AESCCM_setLengths(handle, sizeof(aad), sizeof(ciphertext), macLength);
731  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
732  * // handle error
733  * }
734  *
735  * decryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
736  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
737  * // handle error
738  * }
739  *
740  * AESCCM_SegmentedAADOperation segmentedAADOperation;
741  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
742  * segmentedAADOperation.aad = aad;
743  * segmentedAADOperation.aadLength = sizeof(aad);
744  *
745  * decryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
746  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
747  * // handle error
748  * }
749  *
750  * AESCCM_SegmentedDataOperation segmentedDataOperation;
751  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
752  * segmentedDataOperation.input = ciphertext;
753  * segmentedDataOperation.output = plaintext;
754  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
755  *
756  * decryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
757  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
758  * // handle error
759  * }
760  *
761  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
762  * AESCCM_SegmentedFinalizeOperation_init(&segmentedFinalizeOperation);
763  * segmentedFinalizeOperation.input = ciphertext + AES_BLOCK_SIZE;
764  * segmentedFinalizeOperation.output = plaintext + AES_BLOCK_SIZE;
765  * segmentedFinalizeOperation.inputLength = sizeof(ciphertext) - AES_BLOCK_SIZE;
766  * segmentedFinalizeOperation.mac = mac;
767  * segmentedFinalizeOperation.macLength = macLength;
768  *
769  * decryptionResult = AESCCM_finalizeDecrypt(handle, &segmentedFinalizeOperation);
770  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
771  * // handle error
772  * }
773  *
774  * // do other things while CCM operation completes in the background
775  *
776  * }
777  *
778  * @endcode
779  */
780 
781 #ifndef ti_drivers_AESCCM__include
782 #define ti_drivers_AESCCM__include
783 
784 #include <stdbool.h>
785 #include <stddef.h>
786 #include <stdint.h>
787 
788 #include <ti/drivers/AESCommon.h>
790 
791 #ifdef __cplusplus
792 extern "C" {
793 #endif
794 
807 #define AESCCM_STATUS_RESERVED AES_STATUS_RESERVED
808 
815 #define AESCCM_STATUS_SUCCESS AES_STATUS_SUCCESS
816 
823 #define AESCCM_STATUS_ERROR AES_STATUS_ERROR
824 
833 #define AESCCM_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
834 
838 #define AESCCM_STATUS_CANCELED AES_STATUS_CANCELED
839 
847 #define AESCCM_STATUS_MAC_INVALID AES_STATUS_MAC_INVALID
848 
853 #define AESCCM_STATUS_FEATURE_NOT_SUPPORTED AES_STATUS_FEATURE_NOT_SUPPORTED
854 
858 #define AESCCM_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
859 
864 #define AESCCM_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
865 
872 #define AESCCM_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
873 
886 
890 typedef AESCCM_Config *AESCCM_Handle;
891 
913 typedef enum
914 {
933 
937 typedef enum
938 {
941 } AESCCM_Mode;
942 
947 typedef struct
948 {
950  uint8_t *aad;
954  uint8_t *input;
959  uint8_t *output;
967  uint8_t *nonce;
972  uint8_t *mac;
978  size_t aadLength;
986  size_t inputLength;
992  uint8_t nonceLength;
995  uint8_t macLength;
1005 
1011 typedef struct
1012 {
1013  uint8_t *aad;
1017  size_t aadLength;
1026 
1032 typedef struct
1033 {
1034  uint8_t *input;
1039  uint8_t *output;
1047  size_t inputLength;
1053 
1059 typedef struct
1060 {
1061  uint8_t *input;
1066  uint8_t *output;
1074  uint8_t *mac;
1080  size_t inputLength;
1086  uint8_t macLength;
1092 
1101 
1107 {
1108  AESCCM_OneStepOperation oneStepOperation; /* One-step operation element of the operation union */
1109  AESCCM_SegmentedAADOperation segmentedAADOperation; /* Segmented AAD operation element of the operation union */
1110  AESCCM_SegmentedDataOperation segmentedDataOperation; /* Segmented data operation element of the operation union */
1111  AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation; /* Segmented finalize operation element of the
1112  operation union */
1114 
1118 typedef enum
1119 {
1120  AESCCM_OPERATION_TYPE_ENCRYPT = 1, /* Fields 1 and 2 are for backward compatibility */
1122  AESCCM_OP_TYPE_ONESTEP_ENCRYPT = 1, /* Names changed to _OP_TYPE_ to avoid MISRA deviation from first 31 chars not
1123  being unique */
1132 
1148 typedef void (*AESCCM_CallbackFxn)(AESCCM_Handle handle,
1149  int_fast16_t returnValue,
1150  AESCCM_OperationUnion *operation,
1151  AESCCM_OperationType operationType);
1152 
1161 typedef struct
1162 {
1163  AESCCM_ReturnBehavior returnBehavior;
1165  uint32_t timeout;
1168  void *custom;
1171 } AESCCM_Params;
1172 
1178 extern const AESCCM_Params AESCCM_defaultParams;
1179 
1188 void AESCCM_init(void);
1189 
1202 void AESCCM_Params_init(AESCCM_Params *params);
1203 
1221 AESCCM_Handle AESCCM_open(uint_least8_t index, const AESCCM_Params *params);
1222 
1232 void AESCCM_close(AESCCM_Handle handle);
1233 
1265 int_fast16_t AESCCM_setupEncrypt(AESCCM_Handle handle,
1266  const CryptoKey *key,
1267  size_t totalAADLength,
1268  size_t totalPlaintextLength,
1269  size_t macLength);
1270 
1302 int_fast16_t AESCCM_setupDecrypt(AESCCM_Handle handle,
1303  const CryptoKey *key,
1304  size_t totalAADLength,
1305  size_t totalPlaintextLength,
1306  size_t macLength);
1307 
1335 int_fast16_t AESCCM_setLengths(AESCCM_Handle handle, size_t aadLength, size_t plaintextLength, size_t macLength);
1336 
1357 int_fast16_t AESCCM_setNonce(AESCCM_Handle handle, const uint8_t *nonce, size_t nonceLength);
1358 
1383 int_fast16_t AESCCM_generateNonce(AESCCM_Handle handle, uint8_t *nonce, size_t nonceSize, size_t *nonceLength);
1384 
1419 int_fast16_t AESCCM_addAAD(AESCCM_Handle handle, AESCCM_SegmentedAADOperation *operation);
1420 
1452 int_fast16_t AESCCM_addData(AESCCM_Handle handle, AESCCM_SegmentedDataOperation *operation);
1453 
1479 int_fast16_t AESCCM_finalizeEncrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation);
1480 
1510 int_fast16_t AESCCM_finalizeDecrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation);
1511 
1523 void AESCCM_Operation_init(AESCCM_Operation *operationStruct);
1524 
1534 
1544 
1554 
1564 
1585 int_fast16_t AESCCM_oneStepEncrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct);
1586 
1608 int_fast16_t AESCCM_oneStepDecrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct);
1609 
1624 int_fast16_t AESCCM_cancelOperation(AESCCM_Handle handle);
1625 
1649 AESCCM_Handle AESCCM_construct(AESCCM_Config *config, const AESCCM_Params *params);
1650 
1651 #ifdef __cplusplus
1652 }
1653 #endif
1654 
1655 #endif /* ti_drivers_AESCCM__include */
int_fast16_t AESCCM_oneStepDecrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct)
Function to perform an AESCCM decryption + verification operation in one call.
uint8_t * output
Definition: AESCCM.h:1039
int_fast16_t AESCCM_generateNonce(AESCCM_Handle handle, uint8_t *nonce, size_t nonceSize, size_t *nonceLength)
Function to generate a nonce for an AES CCM segmented encryption operation.
int_fast16_t AESCCM_finalizeDecrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation)
Finalize the MAC and plaintext and verify it.
The CryptoKey type is an opaque representation of a cryptographic key.
uint8_t * aad
Definition: AESCCM.h:1013
Struct containing the parameters required for encrypting/decrypting a message in a segmented operatio...
Definition: AESCCM.h:1032
Struct containing the parameters required for finalizing an encryption/decryption and authentication/...
Definition: AESCCM.h:1059
uint8_t * output
Definition: AESCCM.h:1066
Definition: AESCCM.h:1124
Definition: AESCCM.h:1126
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESCCM.h:947
void AESCCM_OneStepOperation_init(AESCCM_OneStepOperation *operationStruct)
Function to initialize an AESCCM_OneStepOperation struct to its defaults.
uint32_t timeout
Definition: AESCCM.h:1165
AESCCM_SegmentedDataOperation segmentedDataOperation
Definition: AESCCM.h:1110
void * custom
Definition: AESCCM.h:1168
uint8_t macLength
Definition: AESCCM.h:1086
Definition: AESCCM.h:1122
Definition: AESCCM.h:922
size_t inputLength
Definition: AESCCM.h:1047
AESCCM_Handle AESCCM_open(uint_least8_t index, const AESCCM_Params *params)
This function opens a given CCM peripheral.
const AESCCM_Params AESCCM_defaultParams
Default AESCCM_Params structure.
AES Global configuration.
Definition: AESCommon.h:154
Definition: AESCCM.h:940
AESCCM_SegmentedAADOperation segmentedAADOperation
Definition: AESCCM.h:1109
Definition: AESCCM.h:1121
int_fast16_t AESCCM_setupDecrypt(AESCCM_Handle handle, const CryptoKey *key, size_t totalAADLength, size_t totalPlaintextLength, size_t macLength)
Function to prepare a segmented AESCCM decryption operation.
CCM Parameters.
Definition: AESCCM.h:1161
CryptoKey datastructure.
Definition: CryptoKey.h:211
uint8_t nonceLength
Definition: AESCCM.h:992
uint8_t * mac
Definition: AESCCM.h:1074
int_fast16_t AESCCM_cancelOperation(AESCCM_Handle handle)
Cancels an ongoing AESCCM operation.
Definition: AESCommon.h:186
bool nonceInternallyGenerated
Definition: AESCCM.h:1000
Definition: AESCommon.h:196
void AESCCM_SegmentedFinalizeOperation_init(AESCCM_SegmentedFinalizeOperation *operationStruct)
Function to initialize an AESCCM_SegmentedFinalizeOperation struct to its defaults.
int_fast16_t AESCCM_setLengths(AESCCM_Handle handle, size_t aadLength, size_t plaintextLength, size_t macLength)
Function to set the lengths of the message, additional data, and MAC.
Definition: AESCCM.h:915
void AESCCM_Params_init(AESCCM_Params *params)
Function to initialize the AESCCM_Params struct to its defaults.
Definition: AESCCM.h:1130
Struct containing the parameters required for authenticating/verifying additional data in a segmented...
Definition: AESCCM.h:1011
uint8_t * input
Definition: AESCCM.h:1061
int_fast16_t AESCCM_setNonce(AESCCM_Handle handle, const uint8_t *nonce, size_t nonceLength)
Function to set the nonce for an AES CCM segmented operation.
CryptoKey * key
Definition: AESCCM.h:949
size_t aadLength
Definition: AESCCM.h:978
size_t inputLength
Definition: AESCCM.h:986
size_t aadLength
Definition: AESCCM.h:1017
Definition: AESCommon.h:192
Definition: AESCCM.h:927
uint8_t * output
Definition: AESCCM.h:959
int_fast16_t AESCCM_setupEncrypt(AESCCM_Handle handle, const CryptoKey *key, size_t totalAADLength, size_t totalPlaintextLength, size_t macLength)
Function to prepare a segmented AESCCM encryption operation.
size_t inputLength
Definition: AESCCM.h:1080
union AESCCM_OperationUnion AESCCM_OperationUnion
Union containing a reference to a one step, segmented AAD, segmented data, or segmented finalize oper...
void(* AESCCM_CallbackFxn)(AESCCM_Handle handle, int_fast16_t returnValue, AESCCM_OperationUnion *operation, AESCCM_OperationType operationType)
The definition of a callback function used by the AESCCM driver when used in AESCCM_RETURN_BEHAVIOR_C...
Definition: AESCCM.h:1148
AESCCM_Handle AESCCM_construct(AESCCM_Config *config, const AESCCM_Params *params)
Constructs a new AESCCM object.
int_fast16_t AESCCM_oneStepEncrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct)
Function to perform an AESCCM encryption + authentication operation in one call.
Definition: AESCCM.h:1128
uint8_t * aad
Definition: AESCCM.h:950
AESCCM_ReturnBehavior returnBehavior
Definition: AESCCM.h:1163
void AESCCM_Operation_init(AESCCM_Operation *operationStruct)
Function to initialize an AESCCM_Operation struct to its defaults.
Union containing a reference to a one step, segmented AAD, segmented data, or segmented finalize oper...
Definition: AESCCM.h:1106
int_fast16_t AESCCM_addData(AESCCM_Handle handle, AESCCM_SegmentedDataOperation *operation)
Adds a segment of data with a length in bytes to the plaintext/ciphertext output and generated MAC...
void AESCCM_close(AESCCM_Handle handle)
Function to close a CCM peripheral specified by the CCM handle.
AESCCM_CallbackFxn callbackFxn
Definition: AESCCM.h:1164
Definition: AESCCM.h:1127
AESCCM_Mode
Enum for the direction of the CCM operation.
Definition: AESCCM.h:937
uint8_t * mac
Definition: AESCCM.h:972
AESCCM_OperationType
Enum for the operation types supported by the driver.
Definition: AESCCM.h:1118
AESCCM_Config * AESCCM_Handle
A handle that is returned from an AESCCM_open() call.
Definition: AESCCM.h:890
uint8_t * input
Definition: AESCCM.h:1034
AESCCM_ReturnBehavior
The way in which CCM function calls return after performing an encryption + authentication or decrypt...
Definition: AESCCM.h:913
Definition: AESCCM.h:939
void AESCCM_init(void)
This function initializes the CCM module.
Definition: AESCCM.h:1125
uint8_t macLength
Definition: AESCCM.h:995
int_fast16_t AESCCM_addAAD(AESCCM_Handle handle, AESCCM_SegmentedAADOperation *operation)
Adds a segment of aad with a length in bytes to the generated MAC. The length must be a multiple of a...
void AESCCM_SegmentedAADOperation_init(AESCCM_SegmentedAADOperation *operationStruct)
Function to initialize an AESCCM_SegmentedAADOperation struct to its defaults.
AES common module header for all devices.
uint8_t * input
Definition: AESCCM.h:954
AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation
Definition: AESCCM.h:1111
Definition: AESCCM.h:1129
AESCCM_OneStepOperation oneStepOperation
Definition: AESCCM.h:1108
Definition: AESCCM.h:1120
void AESCCM_SegmentedDataOperation_init(AESCCM_SegmentedDataOperation *operationStruct)
Function to initialize an AESCCM_SegmentedDataOperation struct to its defaults.
AESCommon_Config AESCCM_Config
AESCCM Global configuration.
Definition: AESCCM.h:885
uint8_t * nonce
Definition: AESCCM.h:967
AESCCM_OneStepOperation AESCCM_Operation
Definition: AESCCM.h:1100
int_fast16_t AESCCM_finalizeEncrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation)
Finalize the MAC and ciphertext.
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale