AESCommonLPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-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  */
41 #ifndef ti_drivers_aescommon_AESCommonLPF3__include
42 #define ti_drivers_aescommon_AESCommonLPF3__include
43 
44 #include <stdbool.h>
45 #include <stdint.h>
46 
47 #include <ti/drivers/AESCommon.h>
49 
50 #include <ti/drivers/dpl/HwiP.h>
51 
52 #include <ti/devices/DeviceFamily.h>
53 #include DeviceFamily_constructPath(inc/hw_types.h)
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /*
60  * Unaligned input/output pointer arguments are not supported by default
61  * because the performance will be up to 5x slower. Enabling unaligned I/O
62  * is strongly discouraged.
63  */
64 #ifndef AESCommonLPF3_UNALIGNED_IO_SUPPORT_ENABLE
65  #define AESCommonLPF3_UNALIGNED_IO_SUPPORT_ENABLE 0
66 #endif
67 
68 /* DMA Channel Numbers */
69 #define DMA_CH4 4U
70 #define DMA_CH5 5U
71 
72 /* DMA Channel 4 is reserved for AES Channel A (input) */
73 #define AESCommonLPF3_DMA_CHA_BITMASK ((uint32_t)1U << DMA_CH4)
74 /* DMA Channel 5 is reserved for AES Channel B (output) */
75 #define AESCommonLPF3_DMA_CHB_BITMASK ((uint32_t)1U << DMA_CH5)
76 
77 /* Max key length supported by HSM - needed for KeyStore material retrieval */
78 #define AESCommonLPF3_256_KEY_LENGTH_BYTES (256U / 8U)
79 
80 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)
81  /* For CC27XX and CC23XX devices, below AES defines come from driverlib headers.
82  * For CC35XX devices, driverlib does NOT contain these defines.
83  * So, below defines are added.
84  */
85  #define AES_BLOCK_SIZE 16U
86  #define AES_BLOCK_SIZE_WORDS (AES_BLOCK_SIZE / 4U)
87  #define AES_BLOCK_SIZE_MULTIPLE_MASK 0xFFFFFFF0U
88  #define AES_BLOCK_SIZE_MULTIPLE_LENGTH(len) ((len)&AES_BLOCK_SIZE_MULTIPLE_MASK)
89  #define AES_NON_BLOCK_SIZE_MULTIPLE_MASK 0x0000000FU
90  #define AES_NON_BLOCK_SIZE_MULTIPLE_LENGTH(len) ((len)&AES_NON_BLOCK_SIZE_MULTIPLE_MASK)
91 
92  #define AES_IV_LENGTH_BYTES AES_BLOCK_SIZE
93  #define AES_TAG_LENGTH_BYTES AES_BLOCK_SIZE
94 
95  #define AES_128_KEY_LENGTH_BYTES (128U / 8U)
96 
97  #define IS_WORD_ALIGNED(ptr) (((uintptr_t)(ptr) << 30) == 0U)
98 #endif
99 
103 typedef struct
104 {
117  uint8_t intPriority;
119 
125 typedef struct
126 {
129  volatile int_fast16_t returnStatus;
131  bool isOpen;
132  volatile bool cryptoResourceLocked;
133  volatile bool operationInProgress;
134  volatile bool powerConstraintSet;
136 
145 void AESCommonLPF3_init(void);
146 
160 int_fast16_t AESCommonLPF3_construct(AESCommonLPF3_Object *object, AES_ReturnBehavior returnBehavior, uint32_t timeout);
170 void AESCommonLPF3_loadKey(const CryptoKey *key);
181 void AESCommonLPF3_setupOperation(CryptoKey *key, uint32_t autoCfgVal);
192 void AESCommonLPF3_close(AESCommonLPF3_Object *object);
205 int_fast16_t AESCommonLPF3_setOperationInProgress(AESCommonLPF3_Object *object);
216 __STATIC_INLINE void AESCommonLPF3_clearOperationInProgress(AESCommonLPF3_Object *object)
217 {
218  object->operationInProgress = false;
219 }
233 void AESCommonLPF3_cleanup(AESCommonLPF3_Object *object);
244 int_fast16_t AESCommonLPF3_setupSegmentedOperation(AESCommonLPF3_Object *object, const CryptoKey *key);
259 bool AESCommonLPF3_isDMALengthValid(const void *input, const void *output, size_t length);
277 void AESCommonLPF3_configInputDMA(const void *input, size_t inputLength);
296 void AESCommonLPF3_configOutputDMA(void *output, size_t outputLength);
308 void AESCommonLPF3_cancelDMA(bool cancelChannelB);
323 void AESCommonLPF3_cancelOperation(AESCommonLPF3_Object *object, bool cancelDMAChannelB);
335 void AESCommonLPF3_setupHwi(HwiP_Fxn hwiFxn, uintptr_t hwiFxnArg, uint8_t intPriority);
345 void AESCommonLPF3_cleanupHwi(AESCommonLPF3_Object *object);
356 void AESCommonLPF3_setupDMA(AESCommonLPF3_Object *object, uint32_t dmaConfig);
359 #ifdef __cplusplus
360 }
361 #endif
362 
363 #endif /* ti_drivers_aescommon_AESCommonLPF3__include */
The CryptoKey type is an opaque representation of a cryptographic key.
volatile int_fast16_t returnStatus
Definition: AESCommonLPF3.h:129
AES_ReturnBehavior
The return behavior of AES functions.
Definition: AESCommon.h:184
AES_ReturnBehavior returnBehavior
Definition: AESCommonLPF3.h:130
CryptoKey datastructure.
Definition: CryptoKey.h:211
volatile bool operationInProgress
Definition: AESCommonLPF3.h:133
volatile bool powerConstraintSet
Definition: AESCommonLPF3.h:134
CryptoKey key
Definition: AESCommonLPF3.h:128
uint8_t intPriority
Crypto Peripheral&#39;s interrupt priority.
Definition: AESCommonLPF3.h:117
AESCommonLPF3 Hardware Attributes.
Definition: AESCommonLPF3.h:103
uint32_t semaphoreTimeout
Definition: AESCommonLPF3.h:127
AES common module header for all devices.
bool isOpen
Definition: AESCommonLPF3.h:131
volatile bool cryptoResourceLocked
Definition: AESCommonLPF3.h:132
AESCommonLPF3 Object.
Definition: AESCommonLPF3.h:125
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale