MCUX CLNS
MCUX Crypto Library Normal Secure
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
39 extern "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
101 
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
115 
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
129 
137 #define MCUXCLELS_HASH_RTF_OUTPUT_SIZE ((size_t)32U)
138 
144 /**********************************************
145  * TYPEDEFS
146  **********************************************/
147 
160 typedef 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 
239  mcuxClEls_HashOption_t options,
240  uint8_t const * pInput,
241  size_t inputLength,
242  uint8_t * pDigest
243  );
244 
245 
246 #ifdef __cplusplus
247 } /* extern "C" */
248 #endif
249 
250 #endif /* MCUXCLELS_HASH_H_ */
251 
uint32_t hashmd
Defines which hash algorithm shall be used.
Definition: mcuxClEls_Hash.h:171
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition: mcuxClEls_Types.h:211
uint32_t rtfupd
RTF (Runtime Fingerprint) Update.
Definition: mcuxClEls_Hash.h:173
uint32_t hashini
Defines if the hash engine shall be initialized.
Definition: mcuxClEls_Hash.h:169
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.
ELS header for common functionality.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClEls_Hash.h:164
uint32_t hashoe
Defines if the hash digest shall be moved to the output buffer.
Definition: mcuxClEls_Hash.h:172
uint32_t rtfoe
RTF (Runtime Fingerprint) Output Enabled.
Definition: mcuxClEls_Hash.h:174
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:125
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition: mcuxClEls_Common.h:47
Command option bit field for mcuxClEls_Hash_Async and #mcuxClEls_Hash_ShaDirect.
Definition: mcuxClEls_Hash.h:160
uint32_t hashld
Defines if the hash engine shall be initialized with an externally provided digest.
Definition: mcuxClEls_Hash.h:170
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition: mcuxCsslFlowProtection.h:81