SHA2CC26X4_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_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 
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  * SHA2 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 SHA2_S_MSG_TYPE_CONSTRUCT (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
59 #define SHA2_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
60 #define SHA2_S_MSG_TYPE_REGISTER_CALLBACK \
61  (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
62 #define SHA2_S_MSG_TYPE_CLOSE (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
63 #define SHA2_S_MSG_TYPE_HASH_DATA (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
64 #define SHA2_S_MSG_TYPE_HMAC (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
65 #define SHA2_S_MSG_TYPE_SET_HASH_TYPE (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 6U)))
66 #define SHA2_S_MSG_TYPE_SETUP_HMAC (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 7U)))
67 #define SHA2_S_MSG_TYPE_ADD_DATA (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 8U)))
68 #define SHA2_S_MSG_TYPE_FINALIZE (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 9U)))
69 #define SHA2_S_MSG_TYPE_FINALIZE_HMAC (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 10U)))
70 #define SHA2_S_MSG_TYPE_CANCEL_OPERATION \
71  (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 11U)))
72 #define SHA2_S_MSG_TYPE_RESET (CRYPTO_S_MSG_TYPE_INDEX_SHA2 | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 12U)))
73 
74 /*
75  * Config pool size determines how many dynamic driver instances can be created
76  * by the non-secure client using SHA2_construct().
77  */
78 #ifndef CONFIG_SHA2_S_CONFIG_POOL_SIZE
79  #define CONFIG_SHA2_S_CONFIG_POOL_SIZE 1
80 #endif
81 
82 #define SHA2_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_SHA2_COUNT + CONFIG_SHA2_S_CONFIG_POOL_SIZE)
83 
84 /*
85  * ========= SHA2 Secure Callback struct =========
86  */
87 typedef struct
88 {
89  SecureCB_Object object;
90  /* SHA2 callback fxn parameters */
92  int_fast16_t returnStatus;
94 
95 /*
96  * ========= SHA2 Secure Message Structs =========
97  * These secure message structs correspond to the secure message types defined
98  * above. Together, they are used by non-secure client to make PSA calls to the
99  * SHA2 secure service. There is a single input vector for the PSA call
100  * which is a pointer to secure message struct. If the underlying function
101  * has a return value, there is a single output vector which is a pointer to
102  * storage for the return value.
103  */
104 typedef struct
105 {
109 
110 typedef struct
111 {
112  uint_least8_t index;
115 
116 typedef struct
117 {
121 
122 typedef struct
123 {
126 
127 typedef struct
128 {
130  const void *data;
131  size_t dataLength;
132  void *digest;
134 
135 typedef struct
136 {
139  const void *data;
140  size_t dataLength;
141  void *hmac;
143 
144 typedef struct
145 {
149 
150 typedef struct
151 {
155 
156 typedef struct
157 {
159  const void *data;
160  size_t length;
162 
163 /* For SHA2_S_MSG_TYPE_FINALIZE or SHA2_S_MSG_TYPE_FINALIZE_HMAC */
164 typedef struct
165 {
169 
170 typedef struct
171 {
174 
175 typedef struct
176 {
179 
190 psa_status_t SHA2_s_handlePsaMsg(psa_msg_t *msg);
191 
197 void SHA2_s_init(void);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* ti_drivers_sha2_SHA2CC26X4_s__include */
const void * data
Definition: SHA2CC26X4_s.h:139
Definition: SHA2CC26X4_s.h:87
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:158
psa_status_t SHA2_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for SHA2 secure driver.
SHA2_s_SecureCallback * callback
Definition: SHA2CC26X4_s.h:119
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:177
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:124
int_fast16_t returnStatus
Definition: SHA2CC26X4_s.h:92
Definition: SHA2CC26X4_s.h:150
void * digest
Definition: SHA2CC26X4_s.h:132
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:172
const SHA2_Params * params
Definition: SHA2CC26X4_s.h:107
SHA2 Global configuration.
Definition: SHA2.h:438
CryptoKey datastructure.
Definition: CryptoKey.h:192
SHA2_HashType type
Definition: SHA2CC26X4_s.h:147
const void * data
Definition: SHA2CC26X4_s.h:130
size_t dataLength
Definition: SHA2CC26X4_s.h:140
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:166
uint_least8_t index
Definition: SHA2CC26X4_s.h:112
Definition: SHA2CC26X4_s.h:156
Secure Crypto Service.
Definition: SHA2CC26X4_s.h:164
Definition: SHA2CC26X4_s.h:144
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:129
const SHA2_Params * params
Definition: SHA2CC26X4_s.h:113
void * hmac
Definition: SHA2CC26X4_s.h:141
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:137
Definition: SHA2CC26X4_s.h:175
Definition: SHA2CC26X4_s.h:116
Definition: SHA2CC26X4_s.h:110
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:91
size_t dataLength
Definition: SHA2CC26X4_s.h:131
Definition: SHA2CC26X4_s.h:170
SHA2_HashType
Enum for the hash types supported by the driver.
Definition: SHA2.h:387
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:118
CryptoKey * key
Definition: SHA2CC26X4_s.h:153
CryptoKey * key
Definition: SHA2CC26X4_s.h:138
Definition: SHA2CC26X4_s.h:127
Definition: SHA2CC26X4_s.h:122
void SHA2_s_init(void)
Initializes the SHA2 secure driver.
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:152
SHA2 driver header.
void * digestOrHmac
Definition: SHA2CC26X4_s.h:167
Definition: SHA2CC26X4_s.h:104
const void * data
Definition: SHA2CC26X4_s.h:159
SHA2 Parameters.
Definition: SHA2.h:472
SHA2_Config * config
Definition: SHA2CC26X4_s.h:106
SHA2_Handle handle
Definition: SHA2CC26X4_s.h:146
size_t length
Definition: SHA2CC26X4_s.h:160
SecureCB_Object object
Definition: SHA2CC26X4_s.h:89
Definition: SHA2CC26X4_s.h:135
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale