AESCCMCC26X4_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_aesccm_AESCCMCC26X4_s__include
34 #define ti_drivers_aesccm_AESCCMCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/AESCCM.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 CCM 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  * For optimal performance, non-secure clients must use the
61  * AESCCM_s_oneStepDecryptFast and AESCCM_s_oneStepDecryptFast veneers
62  * instead of PSA calls with AESCCM_S_MSG_TYPE_ONE_STEP_ENCRYPT
63  * or AESCCM_S_MSG_TYPE_ONE_STEP_DECRYPT.
64  */
65 #define AESCCM_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
66 #define AESCCM_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
67 #define AESCCM_S_MSG_TYPE_REGISTER_CALLBACK \
68  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
69 #define AESCCM_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
70 #define AESCCM_S_MSG_TYPE_ONE_STEP_ENCRYPT \
71  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
72 #define AESCCM_S_MSG_TYPE_ONE_STEP_DECRYPT \
73  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
74 #define AESCCM_S_MSG_TYPE_SETUP_ENCRYPT \
75  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
76 #define AESCCM_S_MSG_TYPE_SETUP_DECRYPT \
77  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 7U)))
78 #define AESCCM_S_MSG_TYPE_SET_LENGTHS (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 8U)))
79 #define AESCCM_S_MSG_TYPE_SET_NONCE (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 9U)))
80 #define AESCCM_S_MSG_TYPE_ADD_AAD (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 10U)))
81 #define AESCCM_S_MSG_TYPE_ADD_DATA (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 11U)))
82 #define AESCCM_S_MSG_TYPE_FINALIZE_ENCRYPT \
83  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 12U)))
84 #define AESCCM_S_MSG_TYPE_FINALIZE_DECRYPT \
85  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 13U)))
86 #define AESCCM_S_MSG_TYPE_CANCEL_OPERATION \
87  (CRYPTO_S_MSG_TYPE_INDEX_AESCCM | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 14U)))
88 
89 /*
90  * Config pool size determines how many dynamic driver instances can be created
91  * by the non-secure client using AESCCM_construct().
92  */
93 #ifndef CONFIG_AESCCM_S_CONFIG_POOL_SIZE
94  #define CONFIG_AESCCM_S_CONFIG_POOL_SIZE 1
95 #endif
96 
97 #define AESCCM_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_AESCCM_COUNT + CONFIG_AESCCM_S_CONFIG_POOL_SIZE)
98 
99 /*
100  * ========= AES CCM Secure Callback struct =========
101  */
102 typedef struct
103 {
105  /* AES CCM callback fxn parameters */
107  int_fast16_t returnValue;
111 
112 /*
113  * ========= AES CCM Secure Message Structs =========
114  * These secure message structs correspond to the secure message types defined
115  * above. Together, they are used by non-secure client to make PSA calls to the
116  * AES CCM secure service. There is a single input vector for the PSA call
117  * which is a pointer to secure message struct. If the underlying function
118  * has a return value, there is a single output vector which is a pointer to
119  * storage for the return value.
120  */
121 typedef struct
122 {
126 
127 typedef struct
128 {
129  uint_least8_t index;
132 
133 typedef struct
134 {
138 
139 typedef struct
140 {
143 
144 typedef struct
145 {
149 
150 typedef struct
151 {
153  const CryptoKey *key;
154  size_t aadLength;
156  size_t macLength;
158 
159 typedef struct
160 {
162  size_t aadLength;
164  size_t macLength;
166 
167 typedef struct
168 {
170  const uint8_t *nonce;
171  size_t nonceLength;
173 
174 typedef struct
175 {
179 
180 typedef struct
181 {
185 
186 typedef struct
187 {
191 
192 typedef struct
193 {
196 
209 int_fast16_t AESCCM_s_oneStepEncryptFast(AESCCM_Handle handle, AESCCM_Operation *operation);
210 
223 int_fast16_t AESCCM_s_oneStepDecryptFast(AESCCM_Handle handle, AESCCM_Operation *operation);
224 
235 psa_status_t AESCCM_s_handlePsaMsg(psa_msg_t *msg);
236 
242 void AESCCM_s_init(void);
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* ti_drivers_aesccm_AESCCMCC26X4_s__include */
Definition: AESCCMCC26X4_s.h:121
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:141
size_t plaintextLength
Definition: AESCCMCC26X4_s.h:155
AESCCM_OperationType operationType
Definition: AESCCMCC26X4_s.h:109
Definition: AESCCMCC26X4_s.h:167
const AESCCM_Params * params
Definition: AESCCMCC26X4_s.h:124
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:161
Definition: SecureCallback.h:51
int_fast16_t returnValue
Definition: AESCCMCC26X4_s.h:107
Struct containing the parameters required for encrypting/decrypting a message in a segmented operatio...
Definition: AESCCM.h:947
Definition: AESCCMCC26X4_s.h:144
Struct containing the parameters required for finalizing an encryption/decryption and authentication/...
Definition: AESCCM.h:972
size_t aadLength
Definition: AESCCMCC26X4_s.h:162
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:106
uint_least8_t index
Definition: AESCCMCC26X4_s.h:129
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:194
Struct containing the parameters required for encrypting/decrypting and authenticating/verifying a me...
Definition: AESCCM.h:870
AESCCM_SegmentedDataOperation * operation
Definition: AESCCMCC26X4_s.h:183
const uint8_t * nonce
Definition: AESCCMCC26X4_s.h:170
AES Global configuration.
Definition: AESCommon.h:154
size_t nonceLength
Definition: AESCCMCC26X4_s.h:171
CCM Parameters.
Definition: AESCCM.h:1072
CryptoKey datastructure.
Definition: CryptoKey.h:198
psa_status_t AESCCM_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for AES CCM secure driver.
int_fast16_t AESCCM_s_oneStepDecryptFast(AESCCM_Handle handle, AESCCM_Operation *operation)
Fast veneer to perform a single-step AESCCM decryption & verification operation in polling mode witho...
AESCCM_s_SecureCallback * callback
Definition: AESCCMCC26X4_s.h:136
AESCCM_SegmentedFinalizeOperation * operation
Definition: AESCCMCC26X4_s.h:189
Secure Crypto Service.
const CryptoKey * key
Definition: AESCCMCC26X4_s.h:153
Struct containing the parameters required for authenticating/verifying additional data in a segmented...
Definition: AESCCM.h:929
size_t macLength
Definition: AESCCMCC26X4_s.h:164
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:152
Definition: AESCCMCC26X4_s.h:139
Definition: AESCCMCC26X4_s.h:192
Definition: AESCCMCC26X4_s.h:102
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:176
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:188
size_t aadLength
Definition: AESCCMCC26X4_s.h:154
Definition: AESCCMCC26X4_s.h:174
Definition: AESCCMCC26X4_s.h:127
AESCCM_SegmentedAADOperation * operation
Definition: AESCCMCC26X4_s.h:177
size_t plaintextLength
Definition: AESCCMCC26X4_s.h:163
Definition: AESCCMCC26X4_s.h:180
size_t macLength
Definition: AESCCMCC26X4_s.h:156
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:182
Union containing a reference to a one step, segmented AAD, segmented data, or segmented finalize oper...
Definition: AESCCM.h:1017
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:146
AESCCM_Config * config
Definition: AESCCMCC26X4_s.h:123
void AESCCM_s_init(void)
Initializes the AES CCM secure driver.
Definition: AESCCMCC26X4_s.h:186
AESCCM_OperationType
Enum for the operation types supported by the driver.
Definition: AESCCM.h:1029
AESCCM_OperationUnion * operation
Definition: AESCCMCC26X4_s.h:108
AESCCM driver header.
AESCCM_OneStepOperation * operation
Definition: AESCCMCC26X4_s.h:147
Definition: AESCCMCC26X4_s.h:133
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:135
const AESCCM_Params * params
Definition: AESCCMCC26X4_s.h:130
SecureCallback_Object object
Definition: AESCCMCC26X4_s.h:104
AESCCM_Handle handle
Definition: AESCCMCC26X4_s.h:169
int_fast16_t AESCCM_s_oneStepEncryptFast(AESCCM_Handle handle, AESCCM_Operation *operation)
Fast veneer to perform a single-step AESCCM encryption & authentication operation in polling mode wit...
Definition: AESCCMCC26X4_s.h:150
Definition: AESCCMCC26X4_s.h:159
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale