AESCTRXXF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2026, 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  */
58 #ifndef ti_drivers_aesctr_AESCTRXXF3__include
59 #define ti_drivers_aesctr_AESCTRXXF3__include
60 
61 #include <stdbool.h>
62 #include <stdint.h>
63 
64 #include <ti/drivers/AESCTR.h>
67 
68 #include <ti/devices/DeviceFamily.h>
69 
70 #if (DeviceFamily_PARENT != DeviceFamily_PARENT_CC35XX)
71  #include DeviceFamily_constructPath(driverlib/aes.h)
72 #endif
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 /*
79  * Default AES CTR auto config:
80  * ECB SRC as BUF
81  * Trigger points for auto ECB as RDTX3 and WRBUF3S
82  * (the first encryption starts by writing BUF3, the successive ones by reading TXT3)
83  * Counter size as 128-bits
84  * Counter endianness as Big Endian
85  * BUSHALT enabled
86  */
87 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC23X0) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX)
88  #define AESCTRXXF3_DEFAULT_AUTOCFG \
89  ((uint32_t)AES_AUTOCFG_AESSRC_BUF | (uint32_t)AES_AUTOCFG_TRGAES_WRBUF3S | \
90  (uint32_t)AES_AUTOCFG_TRGAES_RDTXT3 | (uint32_t)AES_AUTOCFG_CTRSIZE_CTR128 | \
91  (uint32_t)AES_AUTOCFG_CTRENDN_BIGENDIAN | (uint32_t)AES_AUTOCFG_BUSHALT_EN)
92 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
93  /* Not used for CC35XX */
94 #else
95  #error "Unsupported DeviceFamily_Parent for AESCTRXXF3!"
96 #endif
97 
98 /*
99  * AES CTR auto config for handling processing of the last
100  * block of input to avoid starting encryption of the next counter block and
101  * incrementing the counter value when the output is read from TXT3.
102  *
103  * ECB SRC as BUF
104  * Trigger for auto ECB as WRBUF3S
105  * (the first encryption starts by writing BUF3)
106  * Counter size as 128-bits
107  * Counter endianness as Big Endian
108  * BUSHALT enabled
109  */
110 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC23X0) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX)
111  #define AESCTRXXF3_LAST_BLOCK_AUTOCFG \
112  ((uint32_t)AES_AUTOCFG_AESSRC_BUF | (uint32_t)AES_AUTOCFG_TRGAES_WRBUF3S | \
113  (uint32_t)AES_AUTOCFG_CTRSIZE_CTR128 | (uint32_t)AES_AUTOCFG_CTRENDN_BIGENDIAN | \
114  (uint32_t)AES_AUTOCFG_BUSHALT_EN)
115 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
116  /* Not used for CC35XX */
117 #else
118  #error "Unsupported DeviceFamily_Parent for AESCTRXXF3!"
119 #endif
120 
128 
134 typedef struct
135 {
136  /* Common member first to allow struct to be cast to the common type */
138  volatile uint32_t counter[AES_BLOCK_SIZE_WORDS];
139  const uint8_t *input;
140  uint8_t *output;
141  size_t inputLength;
147 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
148 
153  int_fast16_t hsmStatus;
154  uint32_t keyAssetID;
155  /* Intentionally use implementation-independent uint32_t datatype for
156  * keyLocation to avoid user dependencies on any implementation-specific
157  * headers (e.g. mbedTLS). This data type must be large enough to hold any
158  * implementation-specific keyLocation data.
159  */
160  uint32_t keyLocation;
161  /* To indicate whether a segmented operation is in progress */
163 #endif
165 
178 void AESCTRXXF3_processData(const uint8_t *input, uint8_t *output, size_t inputLength, bool isOneStepOrFinalOperation);
181 #if (DeviceFamily_PARENT != DeviceFamily_PARENT_CC35XX)
182 
195 size_t AESCTRXXF3_configDataDMA(AESCommonXXF3_Object *object,
196  const uint8_t *input,
197  uint8_t *output,
198  size_t inputLength);
199 
207 __STATIC_INLINE void AESCTRXXF3_readCounter(uint32_t counterOut[AES_BLOCK_SIZE_WORDS])
208 {
209  /* Read the latest counter value from the AES engine */
210  AESReadBUF32(&counterOut[0]);
211 }
212 
218 __STATIC_INLINE void AESCTRXXF3_writeCounter(uint32_t counterIn[AES_BLOCK_SIZE_WORDS])
219 {
220  AESWriteBUF32(&counterIn[0]);
221 }
222 
239 __STATIC_INLINE bool AESCTR_acquireLock(AESCTR_Handle handle, uint32_t timeout)
240 {
241  return CryptoResourceXXF3_acquireLock(timeout);
242 }
253 __STATIC_INLINE void AESCTR_releaseLock(AESCTR_Handle handle)
254 {
256 }
267 __STATIC_INLINE void AESCTR_enableThreadSafety(AESCTR_Handle handle)
268 {
269  AESCTRXXF3_Object *object = (AESCTRXXF3_Object *)handle->object;
270  object->threadSafe = true;
271 }
285 __STATIC_INLINE void AESCTR_disableThreadSafety(AESCTR_Handle handle)
286 {
287  AESCTRXXF3_Object *object = (AESCTRXXF3_Object *)handle->object;
288  object->threadSafe = false;
289 }
291 #endif /* (DeviceFamily_PARENT != DeviceFamily_PARENT_CC35XX) */
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif /* ti_drivers_aesctr_AESCTRXXF3__include */
AESCTR_CallbackFxn callbackFxn
Definition: AESCTRXXF3.h:144
size_t inputLength
Definition: AESCTRXXF3.h:141
void CryptoResourceXXF3_releaseLock(void)
AESCTR_OperationType operationType
Definition: AESCTRXXF3.h:145
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:758
uint32_t keyLocation
Definition: AESCTRXXF3.h:160
bool segmentedOperationInProgress
Definition: AESCTRXXF3.h:162
AES Global configuration.
Definition: AESCommon.h:154
AESCommon driver implementation for the Low Power F3 family.
Shared resources to arbitrate access to the AES engine.
AESCTR_OperationType
Enum for the operation types supported by the driver.
Definition: AESCTR.h:715
const uint8_t * input
Definition: AESCTRXXF3.h:139
size_t inputLengthRemaining
Definition: AESCTRXXF3.h:142
AESCTRXXF3 Object.
Definition: AESCTRXXF3.h:134
AESCommonXXF3_HWAttrs AESCTRXXF3_HWAttrs
AESCTRXXF3 Hardware Attributes.
Definition: AESCTRXXF3.h:127
#define AES_BLOCK_SIZE_WORDS
Definition: AESCommonXXF3.h:104
uint32_t keyAssetID
Definition: AESCTRXXF3.h:154
AESCTR_OperationUnion * operation
Definition: AESCTRXXF3.h:143
int_fast16_t hsmStatus
The status of the HSM Boot up process if HSMXXF3_STATUS_SUCCESS, the HSM booted properly. if HSMXXF3_STATUS_ERROR, the HSM did not boot properly.
Definition: AESCTRXXF3.h:153
AESCommonXXF3_Object common
Definition: AESCTRXXF3.h:137
AESCommonXXF3 Object.
Definition: AESCommonXXF3.h:143
bool CryptoResourceXXF3_acquireLock(uint32_t timeout)
void * object
Definition: AESCommon.h:157
bool threadSafe
Definition: AESCTRXXF3.h:146
Union containing a reference to a one-step and segmented operation structure.
Definition: AESCTR.h:677
uint8_t * output
Definition: AESCTRXXF3.h:140
AESCTR driver header.
AESCommonXXF3 Hardware Attributes.
Definition: AESCommonXXF3.h:121
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale