AM263Px MCU+ SDK  11.00.00
dthe_aes.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022-24 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef DTHE_AES_H_
49 #define DTHE_AES_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 #include <stdint.h>
56 #include <kernel/dpl/SystemP.h>
57 #include <drivers/hw_include/cslr.h>
58 #include <security_common/drivers/crypto/dthe/hw_include/cslr_aes.h>
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* ========================================================================== */
65 /* Macros & Typedefs */
66 /* ========================================================================== */
68 #define DTHE_AES_ECB_MODE (0x00000000U)
69 
70 #define DTHE_AES_CBC_MODE (0x00000001U)
71 
72 #define DTHE_AES_CTR_MODE (0x00000002U)
73 
74 #define DTHE_AES_ICM_MODE (0x00000004U)
75 
76 #define DTHE_AES_CFB_MODE (0x00000008U)
77 
78 #define DTHE_AES_F8_MODE (0x00000010U)
79 
80 #define DTHE_AES_F9_MODE (0x00000020U)
81 
82 #define DTHE_AES_XTS_MODE (0x00000040U)
83 
84 #define DTHE_AES_CBC_MAC_MODE (0x00000080U)
85 
86 #define DTHE_AES_CMAC_MODE (0x00000100U)
87 
88 #define DTHE_AES_GCM_MODE (0x00000200U)
89 
90 #define DTHE_AES_GHASH_ONLY_MODE (0x00000400U)
91 
92 #define DTHE_AES_CCM_MODE (0x00000800U)
93 
95 #define DTHE_AES_KEY_128_SIZE (0x00000001U)
96 
97 #define DTHE_AES_KEY_192_SIZE (0x00000002U)
98 
99 #define DTHE_AES_KEY_256_SIZE (0x00000003U)
100 
102 #define DTHE_AES_ENCRYPT (0x016FE45DU)
103 
104 #define DTHE_AES_DECRYPT (0xDCBA4213U)
105 
107 #define DTHE_AES_CTR_WIDTH_16 (0x00000001U)
108 
109 #define DTHE_AES_CTR_WIDTH_32 (0x00000002U)
110 
111 #define DTHE_AES_CTR_WIDTH_64 (0x00000004U)
112 
113 #define DTHE_AES_CTR_WIDTH_96 (0x00000008U)
114 
115 #define DTHE_AES_CTR_WIDTH_128 (0x00000010U)
116 
118 #define DTHE_AES_ONE_SHOT_SUPPORT (0x00000000U)
119 
120 #define DTHE_AES_STREAM_INIT (0xAA11BB22U)
121 
122 #define DTHE_AES_STREAM_UPDATE (0x33CC44DDU)
123 
124 #define DTHE_AES_STREAM_FINISH (0xEE55FF66U)
125 
127 #define DTHE_AES_NO_MODE (0x0U)
128 
129 #define DTHE_AES_GCM_MODE_1 (0x1U)
130 
131 #define DTHE_AES_GCM_MODE_2 (0x2U)
132 
133 #define DTHE_AES_GCM_MODE_3 (0x3U)
134 
136 #define DTHE_AES_XTS_MODE_1 (0x1U)
137 
138 #define DTHE_AES_XTS_MODE_2 (0x2U)
139 
140 #define DTHE_AES_XTS_MODE_3 (0x3U)
141 
142 /* ========================================================================== */
143 /* Structure Declarations */
144 /* ========================================================================== */
145 
154 typedef enum DTHE_AES_Return_e
155 {
156  DTHE_AES_RETURN_SUCCESS = 0x62E699D9U,
157  DTHE_AES_RETURN_FAILURE = 0x904D041AU,
159 
184 typedef struct DTHE_AES_Params_t
185 {
187  uint32_t algoType;
188 
190  uint32_t opType;
191 
197 
202  uint32_t* ptrKey;
203 
207  uint32_t* ptrKey1;
208 
212  uint32_t* ptrKey2;
213 
217  uint8_t keyLen;
218 
222  uint32_t* ptrIV;
223 
229  uint32_t dataLenBytes;
230 
242  uint32_t* ptrEncryptedData;
243 
253  uint32_t* ptrPlainTextData;
254 
258  uint32_t* ptrTag;
259 
263  uint32_t counterWidth;
264 
265 
269  uint32_t streamState;
270 
280  uint32_t streamSize;
281 
285  uint32_t* ptrAAD;
286 
290  uint32_t aadLength;
291 
295  uint32_t ccmL;
296 
300  uint32_t ccmM;
301 
309  uint32_t modeSelect;
311 /* ========================================================================== */
312 /* Global Variables */
313 /* ========================================================================== */
314 
315 /* ========================================================================== */
316 /* Function Definitions */
317 /* ========================================================================== */
318 
328 
340 
350 
351 #ifdef __cplusplus
352 }
353 #endif
354 
355 #endif
356 
DTHE_AES_Params::counterWidth
uint32_t counterWidth
Definition: dthe_aes.h:263
DTHE_AES_Params
AES Driver Parameters This structure has all the parameters which are need by the AES Driver to perfo...
Definition: dthe_aes.h:185
DTHE_AES_Params::streamState
uint32_t streamState
Definition: dthe_aes.h:269
DTHE_AES_Params::keyLen
uint8_t keyLen
Length of the Key.
Definition: dthe_aes.h:217
dthe.h
This file contains the prototype of DTHE driver APIs.
SystemP.h
DTHE_AES_Params::ptrIV
uint32_t * ptrIV
Definition: dthe_aes.h:222
DTHE_AES_Params::ccmM
uint32_t ccmM
Definition: dthe_aes.h:300
DTHE_AES_Params::aadLength
uint32_t aadLength
Definition: dthe_aes.h:290
DTHE_AES_Params::modeSelect
uint32_t modeSelect
Definition: dthe_aes.h:309
DTHE_AES_Params::algoType
uint32_t algoType
Definition: dthe_aes.h:187
DTHE_AES_Params::streamSize
uint32_t streamSize
Definition: dthe_aes.h:280
DTHE_AES_Params::dataLenBytes
uint32_t dataLenBytes
Definition: dthe_aes.h:229
DTHE_AES_Params::opType
uint32_t opType
Operation to be performed by the AES Driver.
Definition: dthe_aes.h:190
DTHE_AES_Params::ptrPlainTextData
uint32_t * ptrPlainTextData
Definition: dthe_aes.h:253
DTHE_AES_Params::ptrTag
uint32_t * ptrTag
Definition: dthe_aes.h:258
DTHE_AES_execute
DTHE_AES_Return_t DTHE_AES_execute(DTHE_Handle handle, const DTHE_AES_Params *ptrParams)
The function is used to execute the AES Driver with the specified parameters.
DTHE_AES_close
DTHE_AES_Return_t DTHE_AES_close(DTHE_Handle handle)
Function to close DTHE AES Driver.
DTHE_AES_Return_t
DTHE_AES_Return_t
DTHE AES Driver Error code.
Definition: dthe_aes.h:155
DTHE_AES_Params::ccmL
uint32_t ccmL
Definition: dthe_aes.h:295
DTHE_AES_Params::ptrKey2
uint32_t * ptrKey2
Definition: dthe_aes.h:212
DTHE_AES_Params::ptrKey1
uint32_t * ptrKey1
Definition: dthe_aes.h:207
DTHE_Handle
void * DTHE_Handle
Handle to the DTHE driver.
Definition: dthe.h:85
DTHE_AES_Params::ptrAAD
uint32_t * ptrAAD
Definition: dthe_aes.h:285
DTHE_AES_Params::ptrKey
uint32_t * ptrKey
Definition: dthe_aes.h:202
DTHE_AES_RETURN_SUCCESS
@ DTHE_AES_RETURN_SUCCESS
Definition: dthe_aes.h:156
DTHE_AES_Params::ptrEncryptedData
uint32_t * ptrEncryptedData
Definition: dthe_aes.h:242
DTHE_AES_Params::useKEKMode
Bool useKEKMode
Definition: dthe_aes.h:196
DTHE_AES_RETURN_FAILURE
@ DTHE_AES_RETURN_FAILURE
Definition: dthe_aes.h:157
DTHE_AES_open
DTHE_AES_Return_t DTHE_AES_open(DTHE_Handle handle)
Function to Open DTHE AES Driver.