AESCBCCC26X4_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_aescbc_AESCBCCC26X4_s__include
34 #define ti_drivers_aescbc_AESCBCCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/AESCBC.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 CBC 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 AESCBC_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
61 #define AESCBC_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
62 #define AESCBC_S_MSG_TYPE_REGISTER_CALLBACK \
63  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
64 #define AESCBC_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
65 #define AESCBC_S_MSG_TYPE_ONE_STEP_ENCRYPT \
66  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
67 #define AESCBC_S_MSG_TYPE_ONE_STEP_DECRYPT \
68  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
69 #define AESCBC_S_MSG_TYPE_SETUP_ENCRYPT \
70  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
71 #define AESCBC_S_MSG_TYPE_SETUP_DECRYPT \
72  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 7U)))
73 #define AESCBC_S_MSG_TYPE_SET_IV (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 8U)))
74 #define AESCBC_S_MSG_TYPE_ADD_DATA (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 9U)))
75 #define AESCBC_S_MSG_TYPE_FINALIZE (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 10U)))
76 #define AESCBC_S_MSG_TYPE_CANCEL_OPERATION \
77  (CRYPTO_S_MSG_TYPE_INDEX_AESCBC | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 11U)))
78 
79 /*
80  * Config pool size determines how many dynamic driver instances can be created
81  * by the non-secure client using AESCBC_construct().
82  */
83 #ifndef CONFIG_AESCBC_S_CONFIG_POOL_SIZE
84  #define CONFIG_AESCBC_S_CONFIG_POOL_SIZE 1
85 #endif
86 
87 #define AESCBC_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_AESCBC_COUNT + CONFIG_AESCBC_S_CONFIG_POOL_SIZE)
88 
89 /*
90  * ========= AES CBC Secure Callback struct =========
91  */
92 typedef struct
93 {
95  /* AES CBC callback fxn parameters */
97  int_fast16_t returnValue;
101 
102 /*
103  * ========= AES CBC Secure Message Structs =========
104  * These secure message structs correspond to the secure message types defined
105  * above. Together, they are used by non-secure client to make PSA calls to the
106  * AES CBC secure service. There is a single input vector for the PSA call
107  * which is a pointer to secure message struct. If the underlying function
108  * has a return value, there is a single output vector which is a pointer to
109  * storage for the return value.
110  */
111 typedef struct
112 {
116 
117 typedef struct
118 {
119  uint_least8_t index;
122 
123 typedef struct
124 {
128 
129 typedef struct
130 {
133 
134 typedef struct
135 {
139 
140 typedef struct
141 {
143  const CryptoKey *key;
145 
146 typedef struct
147 {
149  const uint8_t *iv;
150  size_t ivLength;
152 
153 typedef struct
154 {
158 
160 
161 typedef struct
162 {
165 
176 psa_status_t AESCBC_s_handlePsaMsg(psa_msg_t *msg);
177 
183 void AESCBC_s_init(void);
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* ti_drivers_aescbc_AESCBCCC26X4_s__include */
AESCBC driver header.
Definition: SecureCallback.h:51
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:163
Definition: AESCBCCC26X4_s.h:134
Definition: AESCBCCC26X4_s.h:153
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:148
AES Global configuration.
Definition: AESCommon.h:154
const CryptoKey * key
Definition: AESCBCCC26X4_s.h:143
CryptoKey datastructure.
Definition: CryptoKey.h:198
size_t ivLength
Definition: AESCBCCC26X4_s.h:150
Definition: AESCBCCC26X4_s.h:123
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:142
AESCBC_Config * config
Definition: AESCBCCC26X4_s.h:113
Definition: AESCBCCC26X4_s.h:92
const uint8_t * iv
Definition: AESCBCCC26X4_s.h:149
AESCBC_s_AddDataMsg AESCBC_s_FinalizeMsg
Definition: AESCBCCC26X4_s.h:159
Struct containing the parameters required for encrypting/decrypting a message in a segmented operatio...
Definition: AESCBC.h:770
Secure Crypto Service.
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:155
Struct containing the parameters required for encrypting/decrypting a message in a single-step operat...
Definition: AESCBC.h:730
Definition: AESCBCCC26X4_s.h:161
AESCBC_s_SecureCallback * callback
Definition: AESCBCCC26X4_s.h:126
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:96
Definition: AESCBCCC26X4_s.h:117
int_fast16_t returnValue
Definition: AESCBCCC26X4_s.h:97
Definition: AESCBCCC26X4_s.h:111
SecureCallback_Object object
Definition: AESCBCCC26X4_s.h:94
AESCBC_OperationUnion * operation
Definition: AESCBCCC26X4_s.h:98
Definition: AESCBCCC26X4_s.h:129
const AESCBC_Params * params
Definition: AESCBCCC26X4_s.h:120
AESCBC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCBC.h:815
AESCBC_OperationType operationType
Definition: AESCBCCC26X4_s.h:99
Union containing a reference to a one step or segmented operation.
Definition: AESCBC.h:806
uint_least8_t index
Definition: AESCBCCC26X4_s.h:119
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:136
void AESCBC_s_init(void)
Initializes the AES CBC secure driver.
psa_status_t AESCBC_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for AES CBC secure driver.
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:131
AESCBC_OneStepOperation * operation
Definition: AESCBCCC26X4_s.h:137
Definition: AESCBCCC26X4_s.h:140
CBC Parameters.
Definition: AESCBC.h:856
Definition: AESCBCCC26X4_s.h:146
AESCBC_Handle handle
Definition: AESCBCCC26X4_s.h:125
AESCBC_SegmentedOperation * operation
Definition: AESCBCCC26X4_s.h:156
const AESCBC_Params * params
Definition: AESCBCCC26X4_s.h:114
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale