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/* NXP Confidential. This software is owned or controlled by NXP and may */
5/* only be used strictly in accordance with the applicable license terms. */
6/* By expressly accepting such terms or by downloading, installing, */
7/* activating and/or otherwise using the software, you are agreeing that */
8/* you have read, and that you agree to comply with and are bound by, such */
9/* license terms. If you do not agree to be bound by the applicable license */
10/* terms, then you may not retain, install, activate or otherwise use the */
11/* software. */
12/*--------------------------------------------------------------------------*/
13
32#ifndef MCUXCLELS_HASH_H_
33#define MCUXCLELS_HASH_H_
34
35#include <mcuxClConfig.h> // Exported features flags header
36#include <mcuxClEls_Common.h> // Common functionality
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/**********************************************
43 * CONSTANTS
44 **********************************************/
45
60#define MCUXCLELS_HASH_INIT_ENABLE 1U
61#define MCUXCLELS_HASH_INIT_DISABLE 0U
62
63#define MCUXCLELS_HASH_LOAD_ENABLE 1U
64#define MCUXCLELS_HASH_LOAD_DISABLE 0U
65
66#define MCUXCLELS_HASH_OUTPUT_ENABLE 1U
67#define MCUXCLELS_HASH_OUTPUT_DISABLE 0U
68
69#define MCUXCLELS_HASH_RTF_UPDATE_ENABLE 1U
70#define MCUXCLELS_HASH_RTF_UPDATE_DISABLE 0U
71
72#define MCUXCLELS_HASH_RTF_OUTPUT_ENABLE 1U
73#define MCUXCLELS_HASH_RTF_OUTPUT_DISABLE 0U
74
75#define MCUXCLELS_HASH_MODE_SHA_224 1U
76#define MCUXCLELS_HASH_MODE_SHA_256 0U
77#define MCUXCLELS_HASH_MODE_SHA_384 2U
78#define MCUXCLELS_HASH_MODE_SHA_512 3U
79
80
81#define MCUXCLELS_HASH_VALUE_MODE_SHA_224 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_224 << 4)
82#define MCUXCLELS_HASH_VALUE_MODE_SHA_256 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_256 << 4)
83#define MCUXCLELS_HASH_VALUE_MODE_SHA_384 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_384 << 4)
84#define MCUXCLELS_HASH_VALUE_MODE_SHA_512 ((uint32_t) MCUXCLELS_HASH_MODE_SHA_512 << 4)
85
86
97#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_224 64U
98#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_256 64U
99#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_384 128U
100#define MCUXCLELS_HASH_BLOCK_SIZE_SHA_512 128U
111#define MCUXCLELS_HASH_STATE_SIZE_SHA_224 32U
112#define MCUXCLELS_HASH_STATE_SIZE_SHA_256 32U
113#define MCUXCLELS_HASH_STATE_SIZE_SHA_384 64U
114#define MCUXCLELS_HASH_STATE_SIZE_SHA_512 64U
125#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_224 28U
126#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_256 32U
127#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_384 48U
128#define MCUXCLELS_HASH_OUTPUT_SIZE_SHA_512 64U
137#define MCUXCLELS_HASH_RTF_OUTPUT_SIZE ((size_t)32U)
144/**********************************************
145 * TYPEDEFS
146 **********************************************/
147
160typedef union
161{
162 struct
163 {
164 uint32_t value;
165 } word;
166 struct
167 {
168 uint32_t :2;
169 uint32_t hashini :1;
170 uint32_t hashld :1;
171 uint32_t hashmd :2;
172 uint32_t hashoe :1;
173 uint32_t rtfupd :1;
174 uint32_t rtfoe :1;
175 uint32_t :23;
176 } bits;
178
183/**********************************************
184 * FUNCTIONS
185 **********************************************/
186
240 uint8_t const * pInput,
241 size_t inputLength,
242 uint8_t * pDigest
243 );
244
245#ifdef MCUXCL_FEATURE_ELS_SHA_DIRECT
265MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_ShaDirect_Enable)
267 void);
268
280MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_ShaDirect_Disable)
282 void);
283
330MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_Hash_ShaDirect)
333 uint8_t const * pInput,
334 size_t inputLength,
335 uint8_t * pDigest,
337 void * pCallerData
338 );
339#endif /* MCUXCL_FEATURE_ELS_SHA_DIRECT */
340
341#ifdef __cplusplus
342} /* extern "C" */
343#endif
344
345#endif /* MCUXCLELS_HASH_H_ */
346
ELS header for common functionality.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:46
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:212
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:290
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:125
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:81
Command option bit field for mcuxClEls_Hash_Async and #mcuxClEls_Hash_ShaDirect.
Definition mcuxClEls_Hash.h:161
uint32_t rtfupd
RTF (Runtime Fingerprint) Update.
Definition mcuxClEls_Hash.h:173
uint32_t hashoe
Defines if the hash digest shall be moved to the output buffer.
Definition mcuxClEls_Hash.h:172
uint32_t hashld
Defines if the hash engine shall be initialized with an externally provided digest.
Definition mcuxClEls_Hash.h:170
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Hash.h:164
uint32_t rtfoe
RTF (Runtime Fingerprint) Output Enabled.
Definition mcuxClEls_Hash.h:174
uint32_t hashmd
Defines which hash algorithm shall be used.
Definition mcuxClEls_Hash.h:171
uint32_t hashini
Defines if the hash engine shall be initialized.
Definition mcuxClEls_Hash.h:169