AESCTRCC26X4_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_aesctr_AESCTRCC26X4_s__include
34 #define ti_drivers_aesctr_AESCTRCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/AESCTR.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 CTR 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 #define AESCTR_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
59 #define AESCTR_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
60 #define AESCTR_S_MSG_TYPE_REGISTER_CALLBACK \
61  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
62 #define AESCTR_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
63 #define AESCTR_S_MSG_TYPE_ONE_STEP_ENCRYPT \
64  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
65 #define AESCTR_S_MSG_TYPE_ONE_STEP_DECRYPT \
66  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
67 #define AESCTR_S_MSG_TYPE_SETUP_ENCRYPT \
68  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
69 #define AESCTR_S_MSG_TYPE_SETUP_DECRYPT \
70  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 7U)))
71 #define AESCTR_S_MSG_TYPE_ADD_DATA (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 8U)))
72 #define AESCTR_S_MSG_TYPE_FINALIZE (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 9U)))
73 #define AESCTR_S_MSG_TYPE_CANCEL_OPERATION \
74  (CRYPTO_S_MSG_TYPE_INDEX_AESCTR | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 10U)))
75 
76 /*
77  * Config pool size determines how many dynamic driver instances can be created
78  * by the non-secure client using AESCTR_construct().
79  */
80 #ifndef CONFIG_AESCTR_S_CONFIG_POOL_SIZE
81  #define CONFIG_AESCTR_S_CONFIG_POOL_SIZE 1
82 #endif
83 
84 #define AESCTR_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_AESCTR_COUNT + CONFIG_AESCTR_S_CONFIG_POOL_SIZE)
85 
86 /*
87  * ========= AES CTR Secure Callback struct =========
88  */
89 typedef struct
90 {
91  SecureCB_Object object;
92  /* AES CTR callback fxn parameters */
94  int_fast16_t returnValue;
98 
99 /*
100  * ========= AES CTR Secure Message Structs =========
101  * These secure message structs correspond to the secure message types defined
102  * above. Together, they are used by non-secure client to make PSA calls to the
103  * AES CTR secure service. There is a single input vector for the PSA call
104  * which is a pointer to secure message struct. If the underlying function
105  * has a return value, there is a single output vector which is a pointer to
106  * storage for the return value.
107  */
108 typedef struct
109 {
113 
114 typedef struct
115 {
116  uint_least8_t index;
119 
120 typedef struct
121 {
125 
126 typedef struct
127 {
130 
131 typedef struct
132 {
136 
137 typedef struct
138 {
140  const CryptoKey *key;
141  const uint8_t *initialCounter;
143 
144 typedef struct
145 {
149 
151 
152 typedef struct
153 {
156 
167 psa_status_t AESCTR_s_handlePsaMsg(psa_msg_t *msg);
168 
174 void AESCTR_s_init(void);
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif /* ti_drivers_aesctr_AESCTRCC26X4_s__include */
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:146
Definition: AESCTRCC26X4_s.h:137
Definition: AESCTRCC26X4_s.h:152
Definition: AESCTRCC26X4_s.h:89
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:133
Definition: AESCTRCC26X4_s.h:131
CTR Parameters.
Definition: AESCTR.h:679
const uint8_t * initialCounter
Definition: AESCTRCC26X4_s.h:141
SecureCB_Object object
Definition: AESCTRCC26X4_s.h:91
Struct containing the parameters required for encrypting/decrypting a message using a one-step operat...
Definition: AESCTR.h:510
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:128
Definition: AESCTRCC26X4_s.h:126
AES Global configuration.
Definition: AESCommon.h:154
AESCTR_OperationType
Enum for the operation types supported by the driver.
Definition: AESCTR.h:623
CryptoKey datastructure.
Definition: CryptoKey.h:192
AESCTR_Config * config
Definition: AESCTRCC26X4_s.h:110
void AESCTR_s_init(void)
Initializes the AES CTR secure driver.
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:139
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:122
Definition: AESCTRCC26X4_s.h:114
Secure Crypto Service.
const CryptoKey * key
Definition: AESCTRCC26X4_s.h:140
AESCTR_OperationUnion * operation
Definition: AESCTRCC26X4_s.h:95
Struct containing the parameters required for encrypting/decrypting a message using a segmented opera...
Definition: AESCTR.h:549
Definition: AESCTRCC26X4_s.h:108
AESCTR_s_AddDataMsg AESCTR_s_FinalizeMsg
Definition: AESCTRCC26X4_s.h:150
AESCTR_OperationType operationType
Definition: AESCTRCC26X4_s.h:96
psa_status_t AESCTR_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for AES CTR secure driver.
Definition: AESCTRCC26X4_s.h:144
int_fast16_t returnValue
Definition: AESCTRCC26X4_s.h:94
AESCTR_s_SecureCallback * callback
Definition: AESCTRCC26X4_s.h:123
AESCTR_OneStepOperation * operation
Definition: AESCTRCC26X4_s.h:134
Definition: AESCTRCC26X4_s.h:120
uint_least8_t index
Definition: AESCTRCC26X4_s.h:116
const AESCTR_Params * params
Definition: AESCTRCC26X4_s.h:111
AESCTR_SegmentedOperation * operation
Definition: AESCTRCC26X4_s.h:147
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:154
Union containing a reference to a one-step and segmented operation structure.
Definition: AESCTR.h:585
const AESCTR_Params * params
Definition: AESCTRCC26X4_s.h:117
AESCTR_Handle handle
Definition: AESCTRCC26X4_s.h:93
AESCTR driver header.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale