AESCTR.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021, 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 AESCTR.h
34  *
35  * @brief AESCTR driver header
36  *
37  * @anchor ti_drivers_AESCTR_Overview
38  * <h3> Overview </h3>
39  * The Counter (CTR) mode of operation is a generic block cipher mode of operation
40  * that can be used with any block cipher including AES which is used in this
41  * implementation.
42  *
43  * CTR mode encrypts and decrypts messages. It is not required for the message
44  * length to be evenly divisible by the cipher block size. This also means
45  * that padding the message is not required.
46  *
47  * <h3> Operation </h3>
48  * CTR encryption and decryption perform the following steps:
49  * -# Set the counter value to the initial counter value
50  * -# Encrypt the counter value under the symmetric key
51  * -# XOR the encrypted counter value with the input block (plaintext or ciphertext)
52  * -# Increment the counter value. Interpret the byte array as a big-endian number.
53  * -# Repeat steps 2 to 4 until the input is completely processed. If the
54  * input is not evenly divisible by the block size, XOR the last
55  * (u = input length % block size) input bytes with the most significant
56  * u bytes of the last encrypted counter value.
57  *
58  * CTR performs the same steps regardless of whether it is used to
59  * encrypt or decrypt a message. The input merely changes.
60  *
61  * <h3> Choosing Initial Counter Values </h3>
62  * CTR requires that each counter value used to encrypt a block of a message
63  * is unique for each key used. If this requirement is not kept, the
64  * confidentiality of that message block may be compromised.
65  *
66  * There are two general strategies when choosing the initial counter value
67  * of a CTR operation to ensure this requirement holds.
68  *
69  * The first is to choose an initial counter value for the first message
70  * and increment the initial counter value for a subsequent message by
71  * by message length % block length (16-bytes for AES). This effectively
72  * turns a sequence of messages into one long message. If 0 is chosen
73  * as the initial counter value, up to 2^128 - 1 blocks may be encrypted before
74  * key rotation is mandatory.
75  *
76  * The second is to split the initial counter value into a nonce and
77  * counter section. The nonce of length n bits must be unique per message.
78  * This allows for up to 2^n - 1 messages to be encrypted before
79  * key rotation is required. The counter section of length c is incremented
80  * as usual. This limits messages to a length of at most 2^c - 1 blocks.
81  * n and c must be chosen such that n + c = block length in bits
82  * (128 bits for AES) holds.
83  *
84  * @anchor ti_drivers_AESCTR_Usage
85  * <h3> Usage </h3>
86  * <h4> Before starting a CTR operation </h4>
87  *
88  * Before starting a CTR operation, the application must do the following:
89  * - Call #AESCTR_init() to initialize the driver
90  * - Call #AESCTR_Params_init() to initialize the #AESCTR_Params to default values.
91  * - Modify the #AESCTR_Params as desired
92  * - Call #AESCTR_open() to open an instance of the driver
93  * - Initialize a CryptoKey. These opaque data structures are representations
94  * of keying material and its storage. Depending on how the keying material
95  * is stored (RAM or flash, key store), the CryptoKey must be
96  * initialized differently. The AESCTR API can handle all types of CryptoKey.
97  * However, not all device-specific implementations support all types of CryptoKey.
98  * Devices without a key store will not support CryptoKeys with keying material
99  * stored in a key store for example.
100  * All devices support plaintext CryptoKeys.
101  * - Initialize a single-step AESCTR operation using #AESCTR_OneStepOperation_init()
102  * which is equivalent to the deprecated #AESCTR_Operation_init(). If it's
103  * a segmented AESCTR operation, use #AESCTR_SegmentedOperation_init() instead.
104  * Then set all the fields of the one-step or segmented operation struct accordingly.
105  *
106  * <h4> Starting a CTR operation </h4>
107  *
108  * The AESCTR_oneStepEncrypt() and AESCTR_oneStepDecrypt() functions perform a CTR operation
109  * in a single call.
110  *
111  * <h4> After the CTR operation completes </h4>
112  *
113  * After the CTR operation completes, the application should either start
114  * another operation or close the driver by calling #AESCTR_close().
115  *
116  * @anchor ti_drivers_AESCTR_Synopsis
117  * ## Synopsis
118  *
119  * @anchor ti_drivers_AESCTR_Synopsis_Code
120  * @code
121  *
122  * // Import AESCTR Driver definitions
123  * #include <ti/drivers/AESCTR.h>
124  *
125  * // Define name for AESCTR channel index
126  * #define AESCTR_INSTANCE 0
127  *
128  * AESCTR_init();
129  *
130  * handle = AESCTR_open(AESCTR_INSTANCE, NULL);
131  *
132  * // Initialize symmetric key
133  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
134  *
135  * // Set up AESCTR_Operation
136  * AESCTR_OneStepOperation_init(&operation);
137  * operation.key = &cryptoKey;
138  * operation.input = plaintext;
139  * operation.output = ciphertext;
140  * operation.inputLength = sizeof(plaintext);
141  * operation.initialCounter = initialCounter;
142  *
143  * encryptionResult = AESCTR_oneStepEncrypt(handle, &operation);
144  *
145  * AESCTR_close(handle);
146  * @endcode
147  *
148  * @anchor ti_drivers_AESCTR_Examples
149  * <h4> Examples </h4>
150  *
151  * <h5> One step CTR encryption with plaintext CryptoKey in blocking return mode </h5>
152  * @code
153  *
154  * #include <ti/drivers/AESCTR.h>
155  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
156  *
157  * ...
158  *
159  * AESCTR_Handle handle;
160  * CryptoKey cryptoKey;
161  * int_fast16_t encryptionResult;
162  *
163  * // For example purposes only. Generate IVs in a non-static way in practice.
164  * // Test vector from NIST SP 800-38A
165  * uint8_t initialCounter[16] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
166  * 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
167  * uint8_t plaintext[64] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
168  * 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
169  * 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
170  * 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
171  * 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
172  * 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
173  * 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
174  * 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10};
175  * uint8_t ciphertext[sizeof(plaintext)];
176  * uint8_t keyingMaterial[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
177  * 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
178  *
179  * handle = AESCTR_open(0, NULL);
180  *
181  * if (handle == NULL) {
182  * // handle error
183  * while(1);
184  * }
185  *
186  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
187  *
188  * AESCTR_OneStepOperation operation;
189  * AESCTR_OneStepOperation_init(&operation);
190  *
191  * operation.key = &cryptoKey;
192  * operation.input = plaintext;
193  * operation.output = ciphertext;
194  * operation.inputLength = sizeof(plaintext);
195  * operation.initialCounter = initialCounter;
196  *
197  * encryptionResult = AESCTR_oneStepEncrypt(handle, &operation);
198  *
199  * if (encryptionResult != AESCTR_STATUS_SUCCESS) {
200  * // handle error
201  * while(1);
202  * }
203  *
204  * // The ciphertext should be the following after the encryption operation:
205  * // 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26,
206  * // 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce,
207  * // 0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff,
208  * // 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff,
209  * // 0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e,
210  * // 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab,
211  * // 0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1,
212  * // 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee
213  *
214  * AESCTR_close(handle);
215  *
216  * @endcode
217  *
218  * <h5> One step CTR decryption with plaintext CryptoKey in callback return mode </h5>
219  * @code
220  *
221  * #include <ti/drivers/AESCTR.h>
222  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
223  *
224  * ...
225  *
226  *
227  * void ctrCallback(AESCTR_Handle handle,
228  * int_fast16_t returnValue,
229  * AESCTR_OperationUnion *operation,
230  * AESCTR_OperationType operationType) {
231  *
232  * if (returnValue != AESCTR_STATUS_SUCCESS) {
233  * // handle error
234  * while(1);
235  * }
236  * }
237  * AESCTR_Operation operation;
238  *
239  * void ctrStartFunction(void) {
240  * uint8_t initialCounter[16] = {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F,
241  * 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01};
242  * uint8_t ciphertext[] = {0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9,
243  * 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7,
244  * 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36,
245  * 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53,
246  * 0x25, 0xB2, 0x07, 0x2F};
247  * uint8_t keyingMaterial[] = {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
248  * 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC};
249  * uint8_t plaintext[sizeof(ciphertext)];
250  *
251  * AESCTR_Handle handle;
252  * AESCTR_Params params;
253  * CryptoKey cryptoKey;
254  * int_fast16_t decryptionResult;
255  *
256  * AESCTR_OneStepOperation operation;
257  *
258  * AESCTR_Params_init(&params);
259  * params.returnBehavior = AESCTR_RETURN_BEHAVIOR_CALLBACK;
260  * params.callbackFxn = ctrCallback;
261  *
262  * handle = AESCTR_open(0, &params);
263  *
264  * if (handle == NULL) {
265  * // handle error
266  * while(1);
267  * }
268  *
269  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
270  *
271  * AESCTR_OneStepOperation_init(&operation); // Optional as all struct members will be set before use.
272  *
273  * operation.key = &cryptoKey;
274  * operation.input = ciphertext;
275  * operation.output = plaintext;
276  * operation.inputLength = sizeof(ciphertext);
277  * operation.initialCounter = initialCounter;
278  *
279  * decryptionResult = AESCTR_oneStepDecrypt(handle, &operation);
280  *
281  * if (decryptionResult != AESCTR_STATUS_SUCCESS) {
282  * // handle error
283  * while(1);
284  * }
285  *
286  * // do other things while CTR operation completes in the background
287  *
288  * // After the operation completes and the callback is invoked, the resultant
289  * // plaintext should be:
290  * // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
291  * // 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
292  * // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
293  * // 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
294  * // 0x20, 0x21, 0x22, 0x23
295  *
296  * AESCTR_close(handle);
297  * }
298  *
299  * @endcode
300  *
301  * <h5> Multi-step AES CTR encrypt with plaintext CryptoKey in polling return mode </h5>
302  * @code
303  *
304  * #include <ti/drivers/AESCTR.h>
305  * #include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
306  *
307  * #define AES_BLOCK_SIZE 16 // bytes
308  * ...
309  *
310  * AESCTR_Params params;
311  * AESCTR_Handle handle;
312  * CryptoKey cryptoKey;
313  * int_fast16_t retVal;
314  *
315  * // For example purposes only.
316  * uint8_t plaintext[36] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
317  * 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
318  * 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
319  * 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
320  * 0x20, 0x21, 0x22, 0x23};
321  * uint8_t initialCounter[] = {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F,
322  * 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01};
323  * uint8_t keyingMaterial[] = {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
324  * 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC};
325  * uint8_t ciphertext[sizeof(plaintext)];
326  *
327  * AESCTR_Params_init(&params)
328  * params.returnBehavior = AESCTR_RETURN_BEHAVIOR_POLLING;
329  *
330  * handle = AESCTR_open(0, &params);
331  *
332  * if (handle == NULL) {
333  * // handle error
334  * }
335  *
336  * CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
337  *
338  * AESCTR_SegmentedOperation operation;
339  * AESCTR_SegmentedOperation_init(&operation); // Optional as all struct members will be set before use.
340  *
341  * retVal = AESCTR_setupEncrypt(handle, &cryptoKey, initialCounter);
342  *
343  * if (retVal != AESCTR_STATUS_SUCCESS) {
344  * // handle error
345  * }
346  *
347  * operation.input = plaintext;
348  * operation.inputLength = AES_BLOCK_SIZE; // Only block multiple lengths are permitted when adding data.
349  * operation.output = ciphertext;
350  *
351  * retVal = AESCTR_addData(handle, &operation);
352  *
353  * if (retVal != AESCTR_STATUS_SUCCESS) {
354  * // handle error
355  * }
356  *
357  * operation.input = plaintext + AES_BLOCK_SIZE;
358  * operation.inputLength = sizeof(plaintext) - AES_BLOCK_SIZE; // Non-block multiple length permitted during finalization.
359  * operation.output = ciphertext + AES_BLOCK_SIZE;
360  *
361  * retVal = AESCTR_finalize(handle, &operation);
362  *
363  * if (retVal != AESCTR_STATUS_SUCCESS) {
364  * // handle error
365  * }
366  *
367  * // Upon successful return, the resulting ciphertext should be:
368  * // 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9,
369  * // 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7,
370  * // 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36,
371  * // 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53,
372  * // 0x25, 0xB2, 0x07, 0x2F
373  *
374  * AESCTR_close(handle);
375  *
376  * @endcode
377  */
378 
379 #ifndef ti_drivers_AESCTR__include
380 #define ti_drivers_AESCTR__include
381 
382 #include <stddef.h>
383 #include <stdint.h>
384 
385 #include <ti/drivers/AESCommon.h>
387 
388 #ifdef __cplusplus
389 extern "C" {
390 #endif
391 
392 
405 #define AESCTR_STATUS_RESERVED AES_STATUS_RESERVED
406 
413 #define AESCTR_STATUS_SUCCESS AES_STATUS_SUCCESS
414 
421 #define AESCTR_STATUS_ERROR AES_STATUS_ERROR
422 
431 #define AESCTR_STATUS_RESOURCE_UNAVAILABLE AES_STATUS_RESOURCE_UNAVAILABLE
432 
436 #define AESCTR_STATUS_CANCELED AES_STATUS_CANCELED
437 
441 #define AESCTR_STATUS_FEATURE_NOT_SUPPORTED AES_STATUS_FEATURE_NOT_SUPPORTED
442 
446 #define AESCTR_STATUS_KEYSTORE_INVALID_ID AES_STATUS_KEYSTORE_INVALID_ID
447 
452 #define AESCTR_STATUS_KEYSTORE_GENERIC_ERROR AES_STATUS_KEYSTORE_GENERIC_ERROR
453 
460 #define AESCTR_STATUS_UNALIGNED_IO_NOT_SUPPORTED AES_STATUS_UNALIGNED_IO_NOT_SUPPORTED
461 
462 
484 typedef enum {
503 
511 typedef struct {
512  const CryptoKey *key;
513  const uint8_t *input;
518  uint8_t *output;
526  const uint8_t *initialCounter;
533  size_t inputLength;
539 
549 typedef struct {
550  const uint8_t *input;
555  uint8_t *output;
563  size_t inputLength;
571 
579 
584 typedef union {
585  AESCTR_OneStepOperation oneStepOperation; /* One-step operation element of the operation union */
586  AESCTR_SegmentedOperation segmentedOperation; /* Segmented operation element of the operation union */
588 
589 
593 typedef enum {
596 } AESCTR_Mode;
597 
601 #define AESCTR_OP_MODE_MASK 0x0F
602 
606 #define AESCTR_OP_FLAG_SEGMENTED 0x10 /* bit 4 */
607 
611 #define AESCTR_OP_FLAG_FINALIZE 0x20 /* bit 5 */
612 
616 #define AESCTR_OP_FLAGS_MASK (AESCTR_OP_FLAG_SEGMENTED | AESCTR_OP_FLAG_FINALIZE)
617 
621 typedef enum {
629 
642 
646 typedef AESCTR_Config *AESCTR_Handle;
647 
663 typedef void (*AESCTR_CallbackFxn)(AESCTR_Handle handle,
664  int_fast16_t returnValue,
665  AESCTR_OperationUnion *operation,
666  AESCTR_OperationType operationType);
667 
676 typedef struct {
677  AESCTR_ReturnBehavior returnBehavior;
679  uint32_t timeout;
682  void *custom;
685 } AESCTR_Params;
686 
693 
702 void AESCTR_init(void);
703 
717 
735 AESCTR_Handle AESCTR_open(uint_least8_t index, const AESCTR_Params *params);
736 
746 void AESCTR_close(AESCTR_Handle handle);
747 
766 int_fast16_t AESCTR_setupEncrypt(AESCTR_Handle handle, const CryptoKey *key,
767  const uint8_t *initialCounter);
768 
787 int_fast16_t AESCTR_setupDecrypt(AESCTR_Handle handle, const CryptoKey *key,
788  const uint8_t *initialCounter);
789 
816 int_fast16_t AESCTR_addData(AESCTR_Handle handle,
817  AESCTR_SegmentedOperation *operation);
818 
844 int_fast16_t AESCTR_finalize(AESCTR_Handle handle,
845  AESCTR_SegmentedOperation *operation);
846 
847 
857 void AESCTR_Operation_init(AESCTR_Operation *operation);
858 
866 
874 
875 
894 int_fast16_t AESCTR_oneStepEncrypt(AESCTR_Handle handle, AESCTR_OneStepOperation *operation);
895 
914 int_fast16_t AESCTR_oneStepDecrypt(AESCTR_Handle handle, AESCTR_OneStepOperation *operation);
915 
928 int_fast16_t AESCTR_cancelOperation(AESCTR_Handle handle);
929 
955 AESCTR_Handle AESCTR_construct(AESCTR_Config *config, const AESCTR_Params *params);
956 
957 #ifdef __cplusplus
958 }
959 #endif
960 
961 #endif /* ti_drivers_AESCTR__include */
void AESCTR_SegmentedOperation_init(AESCTR_SegmentedOperation *operation)
Function to initialize an AESCTR_SegmentedOperation struct to its defaults (all zeroes) ...
const AESCTR_Params AESCTR_defaultParams
Default AESCTR_Params structure.
Definition: AESCTR.h:594
ADC_Params params
Definition: Driver_Init.h:11
The CryptoKey type is an opaque representation of a cryptographic key.
AESCTR_Config * AESCTR_Handle
A handle that is returned from an AESCTR_open() call.
Definition: AESCTR.h:646
AESCommon_Config AESCTR_Config
AESCTR Global configuration.
Definition: AESCTR.h:641
int_fast16_t AESCTR_oneStepDecrypt(AESCTR_Handle handle, AESCTR_OneStepOperation *operation)
Function to perform an AESCTR decryption operation in one call.
void AESCTR_init(void)
This function initializes the CTR module.
const CryptoKey * key
Definition: AESCTR.h:512
int_fast16_t AESCTR_setupEncrypt(AESCTR_Handle handle, const CryptoKey *key, const uint8_t *initialCounter)
Function to prepare a segmented AESCTR encryption operation.
void AESCTR_OneStepOperation_init(AESCTR_OneStepOperation *operation)
Function to initialize an AESCTR_OneStepOperation struct to its defaults (all zeroes) ...
void(* AESCTR_CallbackFxn)(AESCTR_Handle handle, int_fast16_t returnValue, AESCTR_OperationUnion *operation, AESCTR_OperationType operationType)
The definition of a callback function used by the AESCTR driver when used in AESCTR_RETURN_BEHAVIOR_C...
Definition: AESCTR.h:663
CTR Parameters.
Definition: AESCTR.h:676
Struct containing the parameters required for encrypting/decrypting a message using a one-step operat...
Definition: AESCTR.h:511
AES Global configuration.
Definition: AESCommon.h:154
const uint8_t * input
Definition: AESCTR.h:513
AESCTR_OperationType
Enum for the operation types supported by the driver.
Definition: AESCTR.h:621
CryptoKey datastructure.
Definition: CryptoKey.h:192
AESCTR_ReturnBehavior
The way in which CTR function calls return after performing an encryption or decryption operation...
Definition: AESCTR.h:484
Definition: AESCommon.h:184
Definition: AESCommon.h:194
Definition: AESCTR.h:497
Definition: AESCTR.h:622
AESCTR_Mode
Enum for the direction of the CTR operation.
Definition: AESCTR.h:593
#define AESCTR_OP_FLAG_SEGMENTED
Flag indicating a segmented operation.
Definition: AESCTR.h:606
AESCTR_OneStepOperation oneStepOperation
Definition: AESCTR.h:585
void AESCTR_Params_init(AESCTR_Params *params)
Function to initialize the AESCTR_Params struct to its defaults.
Definition: AESCTR.h:595
Definition: AESCommon.h:190
uint8_t * output
Definition: AESCTR.h:518
size_t inputLength
Definition: AESCTR.h:563
Definition: AESCTR.h:485
Struct containing the parameters required for encrypting/decrypting a message using a segmented opera...
Definition: AESCTR.h:549
AESCTR_CallbackFxn callbackFxn
Definition: AESCTR.h:678
void * custom
Definition: AESCTR.h:682
AESCTR_SegmentedOperation segmentedOperation
Definition: AESCTR.h:586
int_fast16_t AESCTR_addData(AESCTR_Handle handle, AESCTR_SegmentedOperation *operation)
Encrypts or decrypts a segment of data with a length.
int_fast16_t AESCTR_cancelOperation(AESCTR_Handle handle)
Cancels an ongoing AESCTR operation.
AESCTR_ReturnBehavior returnBehavior
Definition: AESCTR.h:677
Definition: AESCTR.h:492
AESCTR_Handle AESCTR_open(uint_least8_t index, const AESCTR_Params *params)
This function opens a given AESCTR peripheral.
size_t inputLength
Definition: AESCTR.h:533
const uint8_t * input
Definition: AESCTR.h:550
uint8_t * output
Definition: AESCTR.h:555
#define AESCTR_OP_FLAG_FINALIZE
Flag indicating a finalize operation.
Definition: AESCTR.h:611
int_fast16_t AESCTR_finalize(AESCTR_Handle handle, AESCTR_SegmentedOperation *operation)
Finalize the AES operation. If new data needs to be added, inputLength will be used to govern how man...
void AESCTR_Operation_init(AESCTR_Operation *operation)
Function to initialize an AESCTR_Operation struct to its defaults (all zeroes)
int_fast16_t AESCTR_oneStepEncrypt(AESCTR_Handle handle, AESCTR_OneStepOperation *operation)
Function to perform an AESCTR encryption operation in one call.
AES common module header for all devices.
Union containing a reference to a one-step and segmented operation structure.
Definition: AESCTR.h:584
uint32_t timeout
Definition: AESCTR.h:679
AESCTR_Handle AESCTR_construct(AESCTR_Config *config, const AESCTR_Params *params)
Constructs a new AESCTR object.
const uint8_t * initialCounter
Definition: AESCTR.h:526
AESCTR_OneStepOperation AESCTR_Operation
Definition: AESCTR.h:578
int_fast16_t AESCTR_setupDecrypt(AESCTR_Handle handle, const CryptoKey *key, const uint8_t *initialCounter)
Function to prepare a segmented AESCTR decryption operation.
Definition: AESCTR.h:623
void AESCTR_close(AESCTR_Handle handle)
Function to close a CTR peripheral specified by the AESCTR handle.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale