MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClCss_Hash.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2021 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 MCUXCLCSS_HASH_H_
33 #define MCUXCLCSS_HASH_H_
34 
35 #include <mcuxClCss_Common.h> // Common functionality
36 
37 /**********************************************
38  * CONSTANTS
39  **********************************************/
40 
55 #define MCUXCLCSS_HASH_INIT_ENABLE 1U
56 #define MCUXCLCSS_HASH_INIT_DISABLE 0U
57 
58 #define MCUXCLCSS_HASH_LOAD_ENABLE 1U
59 #define MCUXCLCSS_HASH_LOAD_DISABLE 0U
60 
61 #define MCUXCLCSS_HASH_OUTPUT_ENABLE 1U
62 #define MCUXCLCSS_HASH_OUTPUT_DISABLE 0U
63 
64 #define MCUXCLCSS_HASH_RTF_UPDATE_ENABLE 1U
65 #define MCUXCLCSS_HASH_RTF_UPDATE_DISABLE 0U
66 
67 #define MCUXCLCSS_HASH_RTF_OUTPUT_ENABLE 1U
68 #define MCUXCLCSS_HASH_RTF_OUTPUT_DISABLE 0U
69 
70 #define MCUXCLCSS_HASH_MODE_SHA_224 1U
71 #define MCUXCLCSS_HASH_MODE_SHA_256 0U
72 #define MCUXCLCSS_HASH_MODE_SHA_384 2U
73 #define MCUXCLCSS_HASH_MODE_SHA_512 3U
74 
75 
85 #define MCUXCLCSS_HASH_BLOCK_SIZE_SHA_224 64U
86 #define MCUXCLCSS_HASH_BLOCK_SIZE_SHA_256 64U
87 #define MCUXCLCSS_HASH_BLOCK_SIZE_SHA_384 128U
88 #define MCUXCLCSS_HASH_BLOCK_SIZE_SHA_512 128U
89 
99 #define MCUXCLCSS_HASH_STATE_SIZE_SHA_224 32U
100 #define MCUXCLCSS_HASH_STATE_SIZE_SHA_256 32U
101 #define MCUXCLCSS_HASH_STATE_SIZE_SHA_384 64U
102 #define MCUXCLCSS_HASH_STATE_SIZE_SHA_512 64U
103 
113 #define MCUXCLCSS_HASH_OUTPUT_SIZE_SHA_224 28U
114 #define MCUXCLCSS_HASH_OUTPUT_SIZE_SHA_256 32U
115 #define MCUXCLCSS_HASH_OUTPUT_SIZE_SHA_384 48U
116 #define MCUXCLCSS_HASH_OUTPUT_SIZE_SHA_512 64U
117 
125 #define MCUXCLCSS_HASH_RTF_OUTPUT_SIZE ((size_t)32U)
126 
132 /**********************************************
133  * TYPEDEFS
134  **********************************************/
135 
148 typedef union
149 {
150  struct
151  {
152  uint32_t value;
153  } word;
154  struct
155  {
156  uint32_t :2;
157  uint32_t hashini :1;
158  uint32_t hashld :1;
159  uint32_t hashmd :2;
160  uint32_t hashoe :1;
161  uint32_t rtfupd :1;
162  uint32_t rtfoe :1;
163  uint32_t :23;
164  } bits;
166 
171 /**********************************************
172  * FUNCTIONS
173  **********************************************/
174 
227  mcuxClCss_HashOption_t options,
228  uint8_t const * pInput,
229  size_t inputLength,
230  uint8_t * pDigest
231  );
232 
254  void);
255 
269  void);
270 
319  mcuxClCss_HashOption_t options,
320  uint8_t const * pInput,
321  size_t inputLength,
322  uint8_t * pDigest,
324  void * pCallerData
325  );
326 
327 #endif /* MCUXCLCSS_HASH_H_ */
328 
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hash_Async(mcuxClCss_HashOption_t options, uint8_t const *pInput, size_t inputLength, uint8_t *pDigest)
Computes the hash of a message.
#define MCUXCLCSS_API
Marks a function as a public API function of the mcuxClCss component.
Definition: mcuxClCss_Common.h:40
uint32_t rtfupd
RTF (Runtime Fingerprint) Update.
Definition: mcuxClCss_Hash.h:161
uint32_t hashmd
Defines which hash algorithm shall be used.
Definition: mcuxClCss_Hash.h:159
CSSv2 header for common functionality.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Hash.h:152
uint32_t hashld
Defines if the hash engine shall be initialized with an externally provided digest.
Definition: mcuxClCss_Hash.h:158
uint32_t rtfoe
RTF (Runtime Fingerprint) Output Enabled.
Definition: mcuxClCss_Hash.h:162
mcuxClCss_Status_t(* mcuxClCss_TransferToRegisterFunction_t)(uint32_t volatile *destRegister, uint8_t const *source, size_t size, void *pCallerData)
Function type for transfer of data to a memory-mapped register.
Definition: mcuxClCss_Types.h:250
uint32_t hashini
Defines if the hash engine shall be initialized.
Definition: mcuxClCss_Hash.h:157
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ShaDirect_Enable(void)
Enables SHA-direct mode.
Command option bit field for mcuxClCss_Hash_Async and mcuxClCss_Hash_ShaDirect.
Definition: mcuxClCss_Hash.h:148
uint32_t hashoe
Defines if the hash digest shall be moved to the output buffer.
Definition: mcuxClCss_Hash.h:160
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ShaDirect_Disable(void)
Disables SHA-direct mode.
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
uint64_t mcuxClCss_Status_Protected_t
Type for CSS driver protected status codes.
Definition: mcuxClCss_Types.h:183
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Hash_ShaDirect(mcuxClCss_HashOption_t options, uint8_t const *pInput, size_t inputLength, uint8_t *pDigest, mcuxClCss_TransferToRegisterFunction_t pCallback, void *pCallerData)
Calculates the hash of a message using SHA-Direct mode.