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