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