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