SHA2CC26X4_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_sha2_SHA2CC26X4_s__include
34 #define ti_drivers_sha2_SHA2CC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/SHA2.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  * SHA2 secure message types
56  */
57 #define SHA2_S_MSG_TYPE_CONSTRUCT SHA2_S_MSG_TYPE(0U)
58 #define SHA2_S_MSG_TYPE_OPEN SHA2_S_MSG_TYPE(1U)
59 #define SHA2_S_MSG_TYPE_REGISTER_CALLBACK SHA2_S_MSG_TYPE(2U)
60 #define SHA2_S_MSG_TYPE_CLOSE SHA2_S_MSG_TYPE(3U)
61 #define SHA2_S_MSG_TYPE_HASH_DATA SHA2_S_MSG_TYPE(4U)
62 #define SHA2_S_MSG_TYPE_HMAC SHA2_S_MSG_TYPE(5U)
63 #define SHA2_S_MSG_TYPE_SET_HASH_TYPE SHA2_S_MSG_TYPE(6U)
64 #define SHA2_S_MSG_TYPE_SETUP_HMAC SHA2_S_MSG_TYPE(7U)
65 #define SHA2_S_MSG_TYPE_ADD_DATA SHA2_S_MSG_TYPE(8U)
66 #define SHA2_S_MSG_TYPE_FINALIZE SHA2_S_MSG_TYPE(9U)
67 #define SHA2_S_MSG_TYPE_FINALIZE_HMAC SHA2_S_MSG_TYPE(10U)
68 #define SHA2_S_MSG_TYPE_CANCEL_OPERATION SHA2_S_MSG_TYPE(11U)
69 #define SHA2_S_MSG_TYPE_RESET SHA2_S_MSG_TYPE(12U)
70 
71 /*
72  * Config pool size determines how many dynamic driver instances can be created
73  * by the non-secure client using SHA2_construct().
74  */
75 #ifndef CONFIG_SHA2_S_CONFIG_POOL_SIZE
76  #define CONFIG_SHA2_S_CONFIG_POOL_SIZE 1
77 #endif
78 
79 #define SHA2_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_SHA2_COUNT + CONFIG_SHA2_S_CONFIG_POOL_SIZE)
80 
81 /*
82  * ========= SHA2 Secure Callback struct =========
83  * Non-secure clients must register their callback after opening or
84  * constructing a driver instance with blocking or callback return behavior.
85  */
86 typedef struct
87 {
89  /* SHA2 callback fxn parameters */
91  int_fast16_t returnStatus;
93 
94 /*
95  * ========= SHA2 Secure Message Structs =========
96  * These secure message structs correspond to the secure message types defined
97  * above. Together, they are used by non-secure client to make PSA calls to the
98  * SHA2 secure service. There is a single input vector for the PSA call
99  * which is a pointer to secure message struct. If the underlying function
100  * has a return value, there is a single output vector which is a pointer to
101  * storage for the return value.
102  */
103 typedef struct
104 {
108 
109 typedef struct
110 {
111  uint_least8_t index;
114 
115 typedef struct
116 {
120 
121 typedef struct
122 {
125 
126 typedef struct
127 {
129  const void *data;
130  size_t dataLength;
131  void *digest;
133 
134 typedef struct
135 {
138  const void *data;
139  size_t dataLength;
140  void *hmac;
142 
143 typedef struct
144 {
148 
149 typedef struct
150 {
154 
155 typedef struct
156 {
158  const void *data;
159  size_t length;
161 
162 /* For SHA2_S_MSG_TYPE_FINALIZE or SHA2_S_MSG_TYPE_FINALIZE_HMAC */
163 typedef struct
164 {
168 
169 typedef struct
170 {
173 
174 typedef struct
175 {
178 
189 psa_status_t SHA2_s_handlePsaMsg(psa_msg_t *msg);
190 
196 void SHA2_s_init(void);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif /* ti_drivers_sha2_SHA2CC26X4_s__include */
const void * data
Definition: SHA2CC26X4_s.h:138
Definition: SHA2CC26X4_s.h:86
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:157
psa_status_t SHA2_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for SHA2 secure driver.
Definition: SecureCallback.h:51
SHA2_s_SecureCallback * callback
Definition: SHA2CC26X4_s.h:118
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:176
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:123
int_fast16_t returnStatus
Definition: SHA2CC26X4_s.h:91
Definition: SHA2CC26X4_s.h:149
void * digest
Definition: SHA2CC26X4_s.h:131
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:171
const SHA2_Params * params
Definition: SHA2CC26X4_s.h:106
SHA2 Global configuration.
Definition: SHA2.h:446
CryptoKey datastructure.
Definition: CryptoKey.h:196
SHA2_HashType type
Definition: SHA2CC26X4_s.h:146
const void * data
Definition: SHA2CC26X4_s.h:129
size_t dataLength
Definition: SHA2CC26X4_s.h:139
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:165
uint_least8_t index
Definition: SHA2CC26X4_s.h:111
Definition: SHA2CC26X4_s.h:155
Secure Crypto Service.
Definition: SHA2CC26X4_s.h:163
Definition: SHA2CC26X4_s.h:143
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:128
const SHA2_Params * params
Definition: SHA2CC26X4_s.h:112
void * hmac
Definition: SHA2CC26X4_s.h:140
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:136
Definition: SHA2CC26X4_s.h:174
Definition: SHA2CC26X4_s.h:115
Definition: SHA2CC26X4_s.h:109
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:90
size_t dataLength
Definition: SHA2CC26X4_s.h:130
Definition: SHA2CC26X4_s.h:169
SHA2_HashType
Enum for the hash types supported by the driver.
Definition: SHA2.h:395
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:117
CryptoKey * key
Definition: SHA2CC26X4_s.h:152
CryptoKey * key
Definition: SHA2CC26X4_s.h:137
Definition: SHA2CC26X4_s.h:126
Definition: SHA2CC26X4_s.h:121
void SHA2_s_init(void)
Initializes the SHA2 secure driver.
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:151
SHA2 driver header.
void * digestOrHmac
Definition: SHA2CC26X4_s.h:166
SecureCallback_Object object
Definition: SHA2CC26X4_s.h:88
Definition: SHA2CC26X4_s.h:103
const void * data
Definition: SHA2CC26X4_s.h:158
SHA2 Parameters.
Definition: SHA2.h:480
SHA2_Config * config
Definition: SHA2CC26X4_s.h:105
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:145
size_t length
Definition: SHA2CC26X4_s.h:159
Definition: SHA2CC26X4_s.h:134
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale