AESCCM.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2023, 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  * ## Starting a CCM operation #
137  *
138  * The AESCCM_oneStepEncrypt and AESCCM_oneStepDecrypt functions do a CCM operation in a single call.
139  * They will always be the most highly optimized routines with the least overhead and the fastest
140  * runtime. However, they require all AAD and plaintext or ciphertext data to be
141  * available to the function at the start of the call.
142  * All devices support single call operations.
143  *
144  * When performing a decryption operation with AESCCM_oneStepDecrypt(), the MAC is
145  * automatically verified.
146  *
147  * ## After the CCM operation completes #
148  *
149  * After the CCM operation completes, the application should either start another operation
150  * or close the driver by calling AESCCM_close()
151  *
152  * @anchor ti_drivers_AESCCM_Synopsis
153  * ## Synopsis
154  *
155  * @anchor ti_drivers_AESCCM_Synopsis_Code
156  * @code
157  *
158  * // Import AESCCM Driver definitions
159  * #include <ti/drivers/AESCCM.h>
160  *
161  * // Define name for AESCCM channel index
162  * #define AESCCM_INSTANCE 0
163  *
164  * AESCCM_init();
165  *
166  * handle = AESCCM_open(AESCCM_INSTANCE, NULL);
167  *
168  * // Initialize symmetric key
169  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
170  *
171  * // Set up AESCCM_OneStepOperation
172  * AESCCM_OneStepOperation_init(&operation);
173  * operation.key = &cryptoKey;
174  * operation.aad = aad;
175  * operation.aadLength = sizeof(aad);
176  * operation.input = plaintext;
177  * operation.output = ciphertext;
178  * operation.inputLength = sizeof(plaintext);
179  * operation.nonce = nonce;
180  * operation.nonceLength = sizeof(nonce);
181  * operation.mac = mac;
182  * operation.macLength = sizeof(mac);
183  *
184  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
185  *
186  * AESCCM_close(handle);
187  * @endcode
188  *
189  * @anchor ti_drivers_AESCCM_Examples
190  * ## Examples
191  *
192  * ### Single call CCM encryption + authentication with plaintext CryptoKey in blocking return mode #
193  * @code
194  *
195  * #include <ti/drivers/AESCCM.h>
196  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
197  *
198  * ...
199  *
200  * AESCCM_Handle handle;
201  * CryptoKey cryptoKey;
202  * int_fast16_t encryptionResult;
203  * uint8_t nonce[] = "Thisisanonce";
204  * uint8_t aad[] = "This string will be authenticated but not encrypted.";
205  * uint8_t plaintext[] = "This string will be encrypted and authenticated.";
206  * uint8_t mac[16];
207  * uint8_t ciphertext[sizeof(plaintext)];
208  * uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
209  * 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
210  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
211  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
212  *
213  * handle = AESCCM_open(0, NULL);
214  *
215  * if (handle == NULL) {
216  * // handle error
217  * }
218  *
219  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
220  *
221  * AESCCM_OneStepOperation operation;
222  * AESCCM_OneStepOperation_init(&operation);
223  *
224  * operation.key = &cryptoKey;
225  * operation.aad = aad;
226  * operation.aadLength = sizeof(aad);
227  * operation.input = plaintext;
228  * operation.output = ciphertext;
229  * operation.inputLength = sizeof(plaintext);
230  * operation.nonce = nonce;
231  * operation.nonceLength = sizeof(nonce);
232  * operation.mac = mac;
233  * operation.macLength = sizeof(mac);
234  *
235  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
236  *
237  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
238  * // handle error
239  * }
240  *
241  * AESCCM_close(handle);
242  *
243  * @endcode
244  * ### The following code snippet is for CC27XX devices only and leverages the HSM
245  * which is a seperate Hardware Accelerator ###
246  * ### Single call CCM encryption + authentication with plaintext HSM CryptoKey in Polling Mode ###
247  *
248  * @code
249  *
250  * #include <ti/drivers/AESCCM.h>
251  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
252  *
253  * ...
254  *
255  * AESCCM_Params params;
256  * AESCCM_Handle handle;
257  * CryptoKey cryptoKey;
258  * int_fast16_t encryptionResult;
259  * uint8_t nonce[] = "Thisisanonce";
260  * uint8_t aad[] = "This string will be authenticated but not encrypted.";
261  * uint8_t plaintext[] = "This string will be encrypted and authenticated.";
262  * uint8_t mac[16];
263  * uint8_t ciphertext[sizeof(plaintext)];
264  * uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
265  * 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
266  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
267  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
268  *
269  * AESCCM_Params_init(&params)
270  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_POLLING;
271  *
272  * handle = AESCCM_open(0, &params);
273  *
274  * if (handle == NULL) {
275  * // handle error
276  * }
277  *
278  * CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
279  *
280  * AESCCM_OneStepOperation operation;
281  * AESCCM_OneStepOperation_init(&operation);
282  *
283  * operation.key = &cryptoKey;
284  * operation.aad = aad;
285  * operation.aadLength = sizeof(aad);
286  * operation.input = plaintext;
287  * operation.output = ciphertext;
288  * operation.inputLength = sizeof(plaintext);
289  * operation.nonce = nonce;
290  * operation.nonceLength = sizeof(nonce);
291  * operation.mac = mac;
292  * operation.macLength = sizeof(mac);
293  *
294  * encryptionResult = AESCCM_oneStepEncrypt(handle, &operation);
295  *
296  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
297  * // handle error
298  * }
299  *
300  * AESCCM_close(handle);
301  *
302  * @endcode
303  *
304  * ### Single call CCM decryption + verification with plaintext CryptoKey in callback return mode #
305  * @code
306  *
307  * #include <ti/drivers/AESCCM.h>
308  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
309  *
310  * ...
311  *
312  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
313  *
314  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
315  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
316  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
317  * uint8_t mac[] = {0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0};
318  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
319  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
320  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
321  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
322  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
323  * uint8_t plaintext[sizeof(ciphertext)];
324  *
325  * // The plaintext should be the following after the decryption operation:
326  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
327  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
328  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
329  *
330  *
331  * void ccmCallback(AESCCM_Handle handle,
332  * int_fast16_t returnValue,
333  * AESCCM_OperationUnion *operation,
334  * AESCCM_OperationType operationType) {
335  *
336  * if (returnValue != AESCCM_STATUS_SUCCESS) {
337  * // handle error
338  * }
339  * }
340  *
341  * AESCCM_OneStepOperation operation;
342  *
343  * void ccmStartFunction(void) {
344  * AESCCM_Handle handle;
345  * AESCCM_Params params;
346  * CryptoKey cryptoKey;
347  * int_fast16_t decryptionResult;
348  *
349  * AESCCM_Params_init(&params);
350  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
351  * params.callbackFxn = ccmCallback;
352  *
353  * handle = AESCCM_open(0, &params);
354  *
355  * if (handle == NULL) {
356  * // handle error
357  * }
358  *
359  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
360  *
361  * AESCCM_OneStepOperation_init(&operation);
362  *
363  * operation.key = &cryptoKey;
364  * operation.aad = aad;
365  * operation.aadLength = sizeof(aad);
366  * operation.input = ciphertext;
367  * operation.output = plaintext;
368  * operation.inputLength = sizeof(ciphertext);
369  * operation.nonce = nonce;
370  * operation.nonceLength = sizeof(nonce);
371  * operation.mac = mac;
372  * operation.macLength = sizeof(mac);
373  *
374  * decryptionResult = AESCCM_oneStepDecrypt(handle, &operation);
375  *
376  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
377  * // handle error
378  * }
379  *
380  * // do other things while CCM operation completes in the background
381  *
382  * }
383  *
384  *
385  * @endcode
386  *
387  * ### Multi-step CCM encryption + authentication with plaintext CryptoKey in blocking return mode #
388  * @code
389  *
390  * #include <ti/drivers/AESCCM.h>
391  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
392  *
393  * ...
394  *
395  * #define AES_BLOCK_SIZE 16 // bytes
396  *
397  * AESCCM_Handle handle;
398  * CryptoKey cryptoKey;
399  * int_fast16_t encryptionResult;
400  *
401  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
402  *
403  * uint8_t keyingMaterial[16] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
404  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
405  * uint8_t aad[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
406  * uint8_t plaintext[23] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
407  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
408  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E};
409  * uint8_t nonce[13] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
410  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
411  * uint8_t mac[8];
412  * uint8_t ciphertext[sizeof(plaintext)];
413  *
414  * // The ciphertext should be the following after the encryption operation:
415  * // {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
416  * // 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
417  * // 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84}
418  *
419  * handle = AESCCM_open(0, NULL);
420  *
421  * if (handle == NULL) {
422  * // handle error
423  * }
424  *
425  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
426  *
427  *
428  * encryptionResult = AESCCM_setupEncrypt(handle, &cryptoKey, sizeof(aad), sizeof(plaintext), sizeof(mac));
429  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
430  * // handle error
431  * }
432  *
433  * encryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
434  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
435  * // handle error
436  * }
437  *
438  * #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) // and the HSM is the engine of choice
439  *
440  * CryptoKeyPlaintextHSM_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
441  *
442  * // You will also need to populate the mac in handle->object->mac because HSM needs the mac to construct each
443  * // segmented token.
444  * encryptionResult = AESCCMLPF3HSM_setMac(handle, &mac[0], 8);
445  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
446  * // handle error
447  * }
448  *
449  * #endif
450  *
451  * AESCCM_SegmentedAADOperation segmentedAADOperation;
452  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
453  * segmentedAADOperation.aad = aad;
454  * segmentedAADOperation.aadLength = sizeof(aad);
455  *
456  * encryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
457  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
458  * // handle error
459  * }
460  *
461  * AESCCM_SegmentedDataOperation segmentedDataOperation;
462  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
463  * segmentedDataOperation.input = plaintext;
464  * segmentedDataOperation.output = ciphertext;
465  * // One should pass in data that is a block-sized multiple length
466  * // until passing in the last segment of data.
467  * // In that case, the input length simply needs to be a non-zero value.
468  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
469  *
470  * encryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
471  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
472  * // handle error
473  * }
474  *
475  * segmentedDataOperation.input = plaintext + AES_BLOCK_SIZE;
476  * segmentedDataOperation.output = ciphertext + AES_BLOCK_SIZE;
477  * segmentedDataOperation.inputLength = sizeof(plaintext) - AES_BLOCK_SIZE;
478  *
479  * encryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
480  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
481  * // handle error
482  * }
483  *
484  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
485  * AESCCM_SegmentedFinalizeOperation_init(&egmentedFinalizeOperation);
486  * segmentedFinalizeOperation.input = plaintext;
487  * segmentedFinalizeOperation.output = ciphertext;
488  *
489  * // You can finalize with no new data
490  * segmentedFinalizeOperation.inputLength = 0;
491  * segmentedFinalizeOperation.mac = mac;
492  * segmentedFinalizeOperation.macLength = sizeof(mac);
493  * encryptionResult = AESCCM_finalizeEncrypt(handle, &segmentedFinalizeOperation);
494  *
495  * if (encryptionResult != AESCCM_STATUS_SUCCESS) {
496  * // handle error
497  * }
498  *
499  * AESCCM_close(handle);
500  *
501  * @endcode
502  *
503  * ### Multi-step CCM decryption + verification with plaintext CryptoKey in callback return mode #
504  * @code
505  *
506  * #include <ti/drivers/AESCCM.h>
507  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
508  *
509  * ...
510  *
511  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
512  *
513  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
514  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
515  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
516  * uint8_t mac[] = {0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0};
517  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
518  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
519  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
520  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
521  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
522  * uint8_t plaintext[sizeof(ciphertext)];
523  *
524  * // The plaintext should be the following after the decryption operation:
525  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
526  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
527  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
528  *
529  *
530  * void ccmCallback(AESCCM_Handle handle,
531  * int_fast16_t returnValue,
532  * AESCCM_OperationUnion *operation,
533  * AESCCM_OperationType operationType) {
534  *
535  * if (returnValue != AESCCM_STATUS_SUCCESS) {
536  * // handle error
537  * }
538  *
539  * if(operationType == AESCCM_OPERATION_TYPE_DECRYPT ||
540  * operationType == AESCCM_OPERATION_TYPE_ENCRYPT)
541  * {
542  * // Callback fxn only used for one-shot operations
543  * // Use operation->oneStepOperation
544  * }
545  * else if(operationType == AESCCM_OP_TYPE_AAD_DECRYPT ||
546  * operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)
547  * {
548  * // Callback fxn only used for segmented AAD operations
549  * // Use operation->segmentedAADOperation
550  * }
551  * else if(operationType == AESCCM_OP_TYPE_DATA_DECRYPT ||
552  * operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)
553  * {
554  * // Callback fxn only used for segmented data operations
555  * // Use operation->segmentedDataOperation
556  * }
557  * else
558  * {
559  * // Callback fxn only used for segmented finalize operations
560  * // Use operation->segmentedFinalizeOperation
561  * }
562  * }
563  *
564  * void ccmStartFunction(void) {
565  * AESCCM_Handle handle;
566  * AESCCM_Params params;
567  * CryptoKey cryptoKey;
568  * int_fast16_t decryptionResult;
569  *
570  * AESCCM_Params_init(&params);
571  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
572  * params.callbackFxn = ccmCallback;
573  *
574  * handle = AESCCM_open(0, &params);
575  *
576  * if (handle == NULL) {
577  * // handle error
578  * }
579  *
580  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
581  *
582  * decryptionResult = AESCCM_setupDecrypt(handle, &cryptoKey, 0, 0, 0);
583  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
584  * // handle error
585  * }
586  *
587  * // setLengths must be called if the AAD, input, and MAC lengths aren't provided in setupXXXX.
588  * decryptionResult = AESCCM_setLengths(handle, sizeof(aad), sizeof(ciphertext), sizeof(mac));
589  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
590  * // handle error
591  * }
592  *
593  * decryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
594  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
595  * // handle error
596  * }
597  *
598  * AESCCM_SegmentedAADOperation segmentedAADOperation;
599  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
600  * segmentedAADOperation.aad = aad;
601  * segmentedAADOperation.aadLength = sizeof(aad);
602  *
603  * decryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
604  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
605  * // handle error
606  * }
607  *
608  * AESCCM_SegmentedDataOperation segmentedDataOperation;
609  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
610  * segmentedDataOperation.input = ciphertext;
611  * segmentedDataOperation.output = plaintext;
612  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
613  *
614  * decryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
615  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
616  * // handle error
617  * }
618  *
619  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
620  * AESCCM_SegmentedFinalizeOperation_init(&egmentedFinalizeOperation);
621  * segmentedFinalizeOperation.input = ciphertext + AES_BLOCK_SIZE;
622  * segmentedFinalizeOperation.output = plaintext + AES_BLOCK_SIZE;
623  * segmentedFinalizeOperation.inputLength = sizeof(ciphertext) - AES_BLOCK_SIZE;
624  * segmentedFinalizeOperation.mac = mac;
625  * segmentedFinalizeOperation.macLength = sizeof(mac);
626  *
627  * decryptionResult = AESCCM_finalizeDecrypt(handle, &segmentedFinalizeOperation);
628  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
629  * // handle error
630  * }
631  *
632  * // do other things while CCM operation completes in the background
633  *
634  * }
635  *
636  * @endcode
637  *
638  * ### Multi-step CCM* decryption + verification with plaintext CryptoKey in callback return mode #
639  * @code
640  *
641  * #include <ti/drivers/AESCCM.h>
642  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
643  *
644  * ...
645  *
646  * // The following test vector is Packet Vector 1 from RFC 3610 of the IETF.
647  *
648  * uint8_t nonce[] = {0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
649  * 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
650  * uint8_t aad[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
651  * uint8_t mac[] = {0};
652  *
653  * // CCM* allows for unauthenticated encryption using CCM by allowing a MAC length of 0
654  * uint8_t macLength = 0;
655  * uint8_t ciphertext[] = {0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
656  * 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
657  * 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84};
658  * uint8_t keyingMaterial[] = {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
659  * 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF};
660  * uint8_t plaintext[sizeof(ciphertext)];
661  *
662  * // The plaintext should be the following after the decryption operation:
663  * // {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
664  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
665  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E}
666  *
667  *
668  * void ccmCallback(AESCCM_Handle handle,
669  * int_fast16_t returnValue,
670  * AESCCM_OperationUnion *operation,
671  * AESCCM_OperationType operationType) {
672  *
673  * if (returnValue != AESCCM_STATUS_SUCCESS) {
674  * // handle error
675  * }
676  *
677  * if(operationType == AESCCM_OPERATION_TYPE_DECRYPT ||
678  * operationType == AESCCM_OPERATION_TYPE_ENCRYPT)
679  * {
680  * // Callback fxn only used for one-shot operations
681  * // Use operation->oneStepOperation
682  * }
683  * else if(operationType == AESCCM_OP_TYPE_AAD_DECRYPT ||
684  * operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)
685  * {
686  * // Callback fxn only used for segmented AAD operations
687  * // Use operation->segmentedAADOperation
688  * }
689  * else if(operationType == AESCCM_OP_TYPE_DATA_DECRYPT ||
690  * operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)
691  * {
692  * // Callback fxn only used for segmented data operations
693  * // Use operation->segmentedDataOperation
694  * }
695  * else
696  * {
697  * // Callback fxn only used for segmented finalize operations
698  * // Use operation->segmentedFinalizeOperation
699  * }
700  * }
701  *
702  * void ccmStartFunction(void) {
703  * AESCCM_Handle handle;
704  * AESCCM_Params params;
705  * CryptoKey cryptoKey;
706  * int_fast16_t decryptionResult;
707  *
708  * AESCCM_Params_init(&params);
709  * params.returnBehavior = AESCCM_RETURN_BEHAVIOR_CALLBACK;
710  * params.callbackFxn = ccmCallback;
711  *
712  * handle = AESCCM_open(0, &params);
713  *
714  * if (handle == NULL) {
715  * // handle error
716  * }
717  *
718  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
719  *
720  * decryptionResult = AESCCM_setupDecrypt(handle, &cryptoKey, 0, 0, 0);
721  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
722  * // handle error
723  * }
724  *
725  * // setLengths must be called if the AAD, input, and MAC lengths aren't provided in setupXXXX.
726  * decryptionResult = AESCCM_setLengths(handle, sizeof(aad), sizeof(ciphertext), macLength);
727  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
728  * // handle error
729  * }
730  *
731  * decryptionResult = AESCCM_setNonce(handle, nonce, sizeof(nonce));
732  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
733  * // handle error
734  * }
735  *
736  * AESCCM_SegmentedAADOperation segmentedAADOperation;
737  * AESCCM_SegmentedAADOperation_init(&segmentedAADOperation);
738  * segmentedAADOperation.aad = aad;
739  * segmentedAADOperation.aadLength = sizeof(aad);
740  *
741  * decryptionResult = AESCCM_addAAD(handle, &segmentedAADOperation);
742  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
743  * // handle error
744  * }
745  *
746  * AESCCM_SegmentedDataOperation segmentedDataOperation;
747  * AESCCM_SegmentedDataOperation_init(&segmentedDataOperation);
748  * segmentedDataOperation.input = ciphertext;
749  * segmentedDataOperation.output = plaintext;
750  * segmentedDataOperation.inputLength = AES_BLOCK_SIZE;
751  *
752  * decryptionResult = AESCCM_addData(handle, &segmentedDataOperation);
753  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
754  * // handle error
755  * }
756  *
757  * AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation;
758  * AESCCM_SegmentedFinalizeOperation_init(&egmentedFinalizeOperation);
759  * segmentedFinalizeOperation.input = ciphertext + AES_BLOCK_SIZE;
760  * segmentedFinalizeOperation.output = plaintext + AES_BLOCK_SIZE;
761  * segmentedFinalizeOperation.inputLength = sizeof(ciphertext) - AES_BLOCK_SIZE;
762  * segmentedFinalizeOperation.mac = mac;
763  * segmentedFinalizeOperation.macLength = macLength;
764  *
765  * decryptionResult = AESCCM_finalizeDecrypt(handle, &segmentedFinalizeOperation);
766  * if (decryptionResult != AESCCM_STATUS_SUCCESS) {
767  * // handle error
768  * }
769  *
770  * // do other things while CCM operation completes in the background
771  *
772  * }
773  *
774  * @endcode
775  */
776 
777 #ifndef ti_drivers_AESCCM__include
778 #define ti_drivers_AESCCM__include
779 
780 #include <stdbool.h>
781 #include <stddef.h>
782 #include <stdint.h>
783 
784 #include <ti/drivers/AESCommon.h>
786 
787 #ifdef __cplusplus
788 extern "C" {
789 #endif
790 
803 #define AESCCM_STATUS_RESERVED AES_STATUS_RESERVED
804 
811 #define AESCCM_STATUS_SUCCESS AES_STATUS_SUCCESS
812 
819 #define AESCCM_STATUS_ERROR AES_STATUS_ERROR
820 
829 #define AESCCM_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
830 
834 #define AESCCM_STATUS_CANCELED AES_STATUS_CANCELED
835 
843 #define AESCCM_STATUS_MAC_INVALID AES_STATUS_MAC_INVALID
844 
849 #define AESCCM_STATUS_FEATURE_NOT_SUPPORTED AES_STATUS_FEATURE_NOT_SUPPORTED
850 
854 #define AESCCM_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
855 
860 #define AESCCM_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
861 
868 #define AESCCM_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
869 
882 
886 typedef AESCCM_Config *AESCCM_Handle;
887 
909 typedef enum
910 {
929 
933 typedef enum
934 {
937 } AESCCM_Mode;
938 
943 typedef struct
944 {
946  uint8_t *aad;
950  uint8_t *input;
955  uint8_t *output;
961  uint8_t *nonce;
966  uint8_t *mac;
972  size_t aadLength;
977  size_t inputLength;
983  uint8_t nonceLength;
986  uint8_t macLength;
996 
1002 typedef struct
1003 {
1004  uint8_t *aad;
1008  size_t aadLength;
1014 
1020 typedef struct
1021 {
1022  uint8_t *input;
1027  uint8_t *output;
1033  size_t inputLength;
1039 
1045 typedef struct
1046 {
1047  uint8_t *input;
1052  uint8_t *output;
1058  uint8_t *mac;
1064  size_t inputLength;
1070  uint8_t macLength;
1076 
1085 
1091 {
1092  AESCCM_OneStepOperation oneStepOperation; /* One-step operation element of the operation union */
1093  AESCCM_SegmentedAADOperation segmentedAADOperation; /* Segmented AAD operation element of the operation union */
1094  AESCCM_SegmentedDataOperation segmentedDataOperation; /* Segmented data operation element of the operation union */
1095  AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation; /* Segmented finalize operation element of the
1096  operation union */
1098 
1102 typedef enum
1103 {
1104  AESCCM_OPERATION_TYPE_ENCRYPT = 1, /* Fields 1 and 2 are for backward compatibility */
1106  AESCCM_OP_TYPE_ONESTEP_ENCRYPT = 1, /* Names changed to _OP_TYPE_ to avoid MISRA deviation from first 31 chars not
1107  being unique */
1116 
1132 typedef void (*AESCCM_CallbackFxn)(AESCCM_Handle handle,
1133  int_fast16_t returnValue,
1134  AESCCM_OperationUnion *operation,
1135  AESCCM_OperationType operationType);
1136 
1145 typedef struct
1146 {
1147  AESCCM_ReturnBehavior returnBehavior;
1149  uint32_t timeout;
1152  void *custom;
1155 } AESCCM_Params;
1156 
1162 extern const AESCCM_Params AESCCM_defaultParams;
1163 
1172 void AESCCM_init(void);
1173 
1187 
1205 AESCCM_Handle AESCCM_open(uint_least8_t index, const AESCCM_Params *params);
1206 
1216 void AESCCM_close(AESCCM_Handle handle);
1217 
1249 int_fast16_t AESCCM_setupEncrypt(AESCCM_Handle handle,
1250  const CryptoKey *key,
1251  size_t totalAADLength,
1252  size_t totalPlaintextLength,
1253  size_t macLength);
1254 
1286 int_fast16_t AESCCM_setupDecrypt(AESCCM_Handle handle,
1287  const CryptoKey *key,
1288  size_t totalAADLength,
1289  size_t totalPlaintextLength,
1290  size_t macLength);
1291 
1319 int_fast16_t AESCCM_setLengths(AESCCM_Handle handle, size_t aadLength, size_t plaintextLength, size_t macLength);
1320 
1341 int_fast16_t AESCCM_setNonce(AESCCM_Handle handle, const uint8_t *nonce, size_t nonceLength);
1342 
1367 int_fast16_t AESCCM_generateNonce(AESCCM_Handle handle, uint8_t *nonce, size_t nonceSize, size_t *nonceLength);
1368 
1403 int_fast16_t AESCCM_addAAD(AESCCM_Handle handle, AESCCM_SegmentedAADOperation *operation);
1404 
1436 int_fast16_t AESCCM_addData(AESCCM_Handle handle, AESCCM_SegmentedDataOperation *operation);
1437 
1463 int_fast16_t AESCCM_finalizeEncrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation);
1464 
1494 int_fast16_t AESCCM_finalizeDecrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation);
1495 
1507 void AESCCM_Operation_init(AESCCM_Operation *operationStruct);
1508 
1518 
1528 
1538 
1548 
1569 int_fast16_t AESCCM_oneStepEncrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct);
1570 
1592 int_fast16_t AESCCM_oneStepDecrypt(AESCCM_Handle handle, AESCCM_OneStepOperation *operationStruct);
1593 
1608 int_fast16_t AESCCM_cancelOperation(AESCCM_Handle handle);
1609 
1633 AESCCM_Handle AESCCM_construct(AESCCM_Config *config, const AESCCM_Params *params);
1634 
1635 #ifdef __cplusplus
1636 }
1637 #endif
1638 
1639 #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:1027
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.
ADC_Params params
Definition: Driver_Init.h:11
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:1004
Struct containing the parameters required for encrypting/decrypting a message in a segmented operatio...
Definition: AESCCM.h:1020
Struct containing the parameters required for finalizing an encryption/decryption and authentication/...
Definition: AESCCM.h:1045
uint8_t * output
Definition: AESCCM.h:1052
Definition: AESCCM.h:1108
Definition: AESCCM.h:1110
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESCCM.h:943
void AESCCM_OneStepOperation_init(AESCCM_OneStepOperation *operationStruct)
Function to initialize an AESCCM_OneStepOperation struct to its defaults.
uint32_t timeout
Definition: AESCCM.h:1149
AESCCM_SegmentedDataOperation segmentedDataOperation
Definition: AESCCM.h:1094
void * custom
Definition: AESCCM.h:1152
uint8_t macLength
Definition: AESCCM.h:1070
Definition: AESCCM.h:1106
Definition: AESCCM.h:918
size_t inputLength
Definition: AESCCM.h:1033
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:936
AESCCM_SegmentedAADOperation segmentedAADOperation
Definition: AESCCM.h:1093
Definition: AESCCM.h:1105
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:1145
CryptoKey datastructure.
Definition: CryptoKey.h:208
uint8_t nonceLength
Definition: AESCCM.h:983
uint8_t * mac
Definition: AESCCM.h:1058
int_fast16_t AESCCM_cancelOperation(AESCCM_Handle handle)
Cancels an ongoing AESCCM operation.
Definition: AESCommon.h:186
bool nonceInternallyGenerated
Definition: AESCCM.h:991
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:911
void AESCCM_Params_init(AESCCM_Params *params)
Function to initialize the AESCCM_Params struct to its defaults.
Definition: AESCCM.h:1114
Struct containing the parameters required for authenticating/verifying additional data in a segmented...
Definition: AESCCM.h:1002
uint8_t * input
Definition: AESCCM.h:1047
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:945
size_t aadLength
Definition: AESCCM.h:972
size_t inputLength
Definition: AESCCM.h:977
size_t aadLength
Definition: AESCCM.h:1008
Definition: AESCommon.h:192
Definition: AESCCM.h:923
uint8_t * output
Definition: AESCCM.h:955
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:1064
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:1132
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:1112
uint8_t * aad
Definition: AESCCM.h:946
AESCCM_ReturnBehavior returnBehavior
Definition: AESCCM.h:1147
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:1090
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:1148
Definition: AESCCM.h:1111
AESCCM_Mode
Enum for the direction of the CCM operation.
Definition: AESCCM.h:933
uint8_t * mac
Definition: AESCCM.h:966
AESCCM_OperationType
Enum for the operation types supported by the driver.
Definition: AESCCM.h:1102
AESCCM_Config * AESCCM_Handle
A handle that is returned from an AESCCM_open() call.
Definition: AESCCM.h:886
uint8_t * input
Definition: AESCCM.h:1022
AESCCM_ReturnBehavior
The way in which CCM function calls return after performing an encryption + authentication or decrypt...
Definition: AESCCM.h:909
Definition: AESCCM.h:935
void AESCCM_init(void)
This function initializes the CCM module.
Definition: AESCCM.h:1109
uint8_t macLength
Definition: AESCCM.h:986
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:950
AESCCM_SegmentedFinalizeOperation segmentedFinalizeOperation
Definition: AESCCM.h:1095
Definition: AESCCM.h:1113
AESCCM_OneStepOperation oneStepOperation
Definition: AESCCM.h:1092
Definition: AESCCM.h:1104
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:881
uint8_t * nonce
Definition: AESCCM.h:961
AESCCM_OneStepOperation AESCCM_Operation
Definition: AESCCM.h:1084
int_fast16_t AESCCM_finalizeEncrypt(AESCCM_Handle handle, AESCCM_SegmentedFinalizeOperation *operation)
Finalize the MAC and ciphertext.
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale