AESGCMCC26X4_s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Texas Instruments Incorporated - https://www.ti.com
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 #ifndef ti_drivers_aesgcm_AESGCMCC26X4_s__include
34 #define ti_drivers_aesgcm_AESGCMCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/AESGCM.h>
40 
41 #include <ti/sysbios/psa/SecureCB.h>
42 
43 #include <third_party/tfm/interface/include/psa/crypto_types.h>
44 #include <third_party/tfm/interface/include/psa/service.h>
45 
46 #include "ti_drivers_config.h" /* Sysconfig generated header */
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  * AES GCM secure message types
54  *
55  * Non-secure clients must register their callback after opening or
56  * constructing a driver instance with blocking or callback return behavior.
57  */
58 #define AESGCM_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
59 #define AESGCM_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
60 #define AESGCM_S_MSG_TYPE_REGISTER_CALLBACK \
61  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
62 #define AESGCM_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
63 #define AESGCM_S_MSG_TYPE_ONE_STEP_ENCRYPT \
64  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
65 #define AESGCM_S_MSG_TYPE_ONE_STEP_DECRYPT \
66  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
67 #define AESGCM_S_MSG_TYPE_SETUP_ENCRYPT \
68  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
69 #define AESGCM_S_MSG_TYPE_SETUP_DECRYPT \
70  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 7U)))
71 #define AESGCM_S_MSG_TYPE_SET_LENGTHS (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 8U)))
72 #define AESGCM_S_MSG_TYPE_SET_IV (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 9U)))
73 #define AESGCM_S_MSG_TYPE_ADD_AAD (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 10U)))
74 #define AESGCM_S_MSG_TYPE_ADD_DATA (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 11U)))
75 #define AESGCM_S_MSG_TYPE_FINALIZE_ENCRYPT \
76  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 12U)))
77 #define AESGCM_S_MSG_TYPE_FINALIZE_DECRYPT \
78  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 13U)))
79 #define AESGCM_S_MSG_TYPE_CANCEL_OPERATION \
80  (CRYPTO_S_MSG_TYPE_INDEX_AESGCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 14U)))
81 
82 /*
83  * Config pool size determines how many dynamic driver instances can be created
84  * by the non-secure client using AESGCM_construct().
85  */
86 #ifndef CONFIG_AESGCM_S_CONFIG_POOL_SIZE
87  #define CONFIG_AESGCM_S_CONFIG_POOL_SIZE 1
88 #endif
89 
90 #define AESGCM_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_AESGCM_COUNT + CONFIG_AESGCM_S_CONFIG_POOL_SIZE)
91 
92 /*
93  * ========= AES GCM Secure Callback struct =========
94  */
95 typedef struct
96 {
97  SecureCB_Object object;
98  /* AES GCM callback fxn parameters */
100  int_fast16_t returnValue;
104 
105 /*
106  * ========= AES GCM Secure Message Structs =========
107  * These secure message structs correspond to the secure message types defined
108  * above. Together, they are used by non-secure client to make PSA calls to the
109  * AES GCM secure service. There is a single input vector for the PSA call
110  * which is a pointer to secure message struct. If the underlying function
111  * has a return value, there is a single output vector which is a pointer to
112  * storage for the return value.
113  */
114 typedef struct
115 {
119 
120 typedef struct
121 {
122  uint_least8_t index;
125 
126 typedef struct
127 {
131 
132 typedef struct
133 {
136 
137 typedef struct
138 {
142 
143 typedef struct
144 {
146  const CryptoKey *key;
150 
151 typedef struct
152 {
154  size_t aadLength;
157 
158 typedef struct
159 {
161  const uint8_t *iv;
162  size_t ivLength;
164 
165 typedef struct
166 {
170 
171 typedef struct
172 {
176 
177 typedef struct
178 {
182 
183 typedef struct
184 {
187 
198 psa_status_t AESGCM_s_handlePsaMsg(psa_msg_t *msg);
199 
205 void AESGCM_s_init(void);
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif /* ti_drivers_aesgcm_AESGCMCC26X4_s__include */
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:179
psa_status_t AESGCM_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for AES GCM secure driver.
Definition: AESGCMCC26X4_s.h:137
AESGCM_OperationType
Enum for the operation types supported by the driver.
Definition: AESGCM.h:860
Definition: AESGCMCC26X4_s.h:143
uint_least8_t index
Definition: AESGCMCC26X4_s.h:122
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:99
const uint8_t * iv
Definition: AESGCMCC26X4_s.h:161
Definition: AESGCMCC26X4_s.h:151
AES Global configuration.
Definition: AESCommon.h:154
AESGCM_OperationUnion * operation
Definition: AESGCMCC26X4_s.h:101
Definition: AESGCMCC26X4_s.h:171
AESGCM_SegmentedAADOperation * operation
Definition: AESGCMCC26X4_s.h:168
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:145
AESGCM driver header.
CryptoKey datastructure.
Definition: CryptoKey.h:192
Struct containing the parameters required for encrypting/decrypting a message in a segmented operatio...
Definition: AESGCM.h:781
size_t ivLength
Definition: AESGCMCC26X4_s.h:162
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:128
AESGCM_s_SecureCallback * callback
Definition: AESGCMCC26X4_s.h:129
AESGCM_OperationType operationType
Definition: AESGCMCC26X4_s.h:102
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:160
Struct containing the parameters required for authenticating/verifying additional data in a segmented...
Definition: AESGCM.h:763
int_fast16_t returnValue
Definition: AESGCMCC26X4_s.h:100
Secure Crypto Service.
const AESGCM_Params * params
Definition: AESGCMCC26X4_s.h:117
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:153
Definition: AESGCMCC26X4_s.h:114
size_t totalPlaintextLength
Definition: AESGCMCC26X4_s.h:148
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:167
Definition: AESGCMCC26X4_s.h:126
Struct containing the parameters required for finalizing an encryption/decryption and authentication/...
Definition: AESGCM.h:806
AESGCM_SegmentedFinalizeOperation * operation
Definition: AESGCMCC26X4_s.h:180
AESGCM_OneStepOperation * operation
Definition: AESGCMCC26X4_s.h:140
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESGCM.h:708
Definition: AESGCMCC26X4_s.h:183
size_t aadLength
Definition: AESGCMCC26X4_s.h:154
Definition: AESGCMCC26X4_s.h:158
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:139
AESGCM_Config * config
Definition: AESGCMCC26X4_s.h:116
Definition: AESGCMCC26X4_s.h:120
AESGCM_SegmentedDataOperation * operation
Definition: AESGCMCC26X4_s.h:174
Definition: AESGCMCC26X4_s.h:177
Definition: AESGCMCC26X4_s.h:165
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:134
Union containing a reference to a one step, segmented AAD, segmented data, or segmented finalize oper...
Definition: AESGCM.h:848
const CryptoKey * key
Definition: AESGCMCC26X4_s.h:146
const AESGCM_Params * params
Definition: AESGCMCC26X4_s.h:123
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:173
SecureCB_Object object
Definition: AESGCMCC26X4_s.h:97
AESGCM_Handle handle
Definition: AESGCMCC26X4_s.h:185
void AESGCM_s_init(void)
Initializes the AES GCM secure driver.
GCM Parameters.
Definition: AESGCM.h:903
Definition: AESGCMCC26X4_s.h:132
Definition: AESGCMCC26X4_s.h:95
size_t totalAADLength
Definition: AESGCMCC26X4_s.h:147
size_t plaintextLength
Definition: AESGCMCC26X4_s.h:155
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale