MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Hash.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2023 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
44
51
52#ifndef MCUXCLELS_HASH_H_
53#define MCUXCLELS_HASH_H_
54
55#include <mcuxClConfig.h> // Exported features flags header
56#include <mcuxClEls_Common.h> // Common functionality
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62/**********************************************
63 * CONSTANTS
64 **********************************************/
65
72
79
80#define MCUXCLELS_HASH_INIT_ENABLE 1U
81#define MCUXCLELS_HASH_INIT_DISABLE 0U
82
83#define MCUXCLELS_HASH_LOAD_ENABLE 1U
84#define MCUXCLELS_HASH_LOAD_DISABLE 0U
85
86#define MCUXCLELS_HASH_OUTPUT_ENABLE 1U
87#define MCUXCLELS_HASH_OUTPUT_DISABLE 0U
88
89#define MCUXCLELS_HASH_RTF_UPDATE_ENABLE 1U
90#define MCUXCLELS_HASH_RTF_UPDATE_DISABLE 0U
91
92#define MCUXCLELS_HASH_RTF_OUTPUT_ENABLE 1U
93#define MCUXCLELS_HASH_RTF_OUTPUT_DISABLE 0U
94
95#define MCUXCLELS_HASH_MODE_SHA_224 1U
96#define MCUXCLELS_HASH_MODE_SHA_256 0U
97#define MCUXCLELS_HASH_MODE_SHA_384 2U
98#define MCUXCLELS_HASH_MODE_SHA_512 3U
99
100
101#define MCUXCLELS_HASH_VALUE_MODE_SHA_224 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_224 << 4)
102#define MCUXCLELS_HASH_VALUE_MODE_SHA_256 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_256 << 4)
103#define MCUXCLELS_HASH_VALUE_MODE_SHA_384 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_384 << 4)
104#define MCUXCLELS_HASH_VALUE_MODE_SHA_512 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_512 << 4)
105
106
110
117#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_224 64U
118#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_256 64U
119#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_384 128U
120#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_512 128U
124
131#define MCUXCLELS_HASH_STATE_SIZE_SHA_224 32U
132#define MCUXCLELS_HASH_STATE_SIZE_SHA_256 32U
133#define MCUXCLELS_HASH_STATE_SIZE_SHA_384 64U
134#define MCUXCLELS_HASH_STATE_SIZE_SHA_512 64U
138
145#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_224 28U
146#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_256 32U
147#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_384 48U
148#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_512 64U
152
157#define MCUXCLELS_HASH_RTF_OUTPUT_SIZE ((size_t)32U)
163
164/**********************************************
165 * TYPEDEFS
166 **********************************************/
167
174
180typedef union
181{
182 struct
183 {
184 uint32_t value;
185 } word;
186 struct
187 {
188 uint32_t :2;
189 uint32_t hashini :1;
190 uint32_t hashld :1;
191 uint32_t hashmd :2;
192 uint32_t hashoe :1;
193 uint32_t rtfupd :1;
194 uint32_t rtfoe :1;
195 uint32_t :23;
196 } bits;
198
202
203/**********************************************
204 * FUNCTIONS
205 **********************************************/
206
213
260 uint8_t const * pInput,
261 size_t inputLength,
262 uint8_t * pDigest
263 );
264
265#ifdef MCUXCL_FEATURE_ELS_SHA_DIRECT
285MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_ShaDirect_Enable)
287 void);
288
300MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_ShaDirect_Disable)
302 void);
303
350MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_Hash_ShaDirect)
353 uint8_t const * pInput,
354 size_t inputLength,
355 uint8_t * pDigest,
357 void * pCallerData
358 );
359#endif /* MCUXCL_FEATURE_ELS_SHA_DIRECT */
360
361#ifdef __cplusplus
362} /* extern "C" */
363#endif
364
365#endif /* MCUXCLELS_HASH_H_ */
366
ELS header for common functionality.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:66
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Hash_Async(mcuxClEls_HashOption_t options, uint8_t const *pInput, size_t inputLength, uint8_t *pDigest)
Computes the hash of a message.
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition mcuxClEls_Types.h:232
mcuxClEls_Status_t(* mcuxClEls_TransferToRegisterFunction_t)(uint32_t volatile *pDestRegister, uint8_t const *pSource, size_t sourceLength, void *pCallerData)
Function type for transfer of data to a memory-mapped register.
Definition mcuxClEls_Types.h:310
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:145
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:101
Command option bit field for mcuxClEls_Hash_Async and mcuxClEls_Hash_ShaDirect.
Definition mcuxClEls_Hash.h:181
uint32_t rtfupd
RTF (Runtime Fingerprint) Update.
Definition mcuxClEls_Hash.h:193
uint32_t hashoe
Defines if the hash digest shall be moved to the output buffer.
Definition mcuxClEls_Hash.h:192
uint32_t hashld
Defines if the hash engine shall be initialized with an externally provided digest.
Definition mcuxClEls_Hash.h:190
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Hash.h:184
uint32_t rtfoe
RTF (Runtime Fingerprint) Output Enabled.
Definition mcuxClEls_Hash.h:194
uint32_t hashmd
Defines which hash algorithm shall be used.
Definition mcuxClEls_Hash.h:191
uint32_t hashini
Defines if the hash engine shall be initialized.
Definition mcuxClEls_Hash.h:189