MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClCss_Common.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 
27 #ifndef MCUXCLCSS_COMMON_H_
28 #define MCUXCLCSS_COMMON_H_
29 
30 #include <mcuxClCss_Types.h> // Common types
31 #include <mcuxCsslFlowProtection.h>
32 
40 #define MCUXCLCSS_API
41 
42 /**********************************************
43  * CONSTANTS
44  **********************************************/
45 
57 #define MCUXCLCSS_HW_VERSION ((mcuxClCss_HwVersion_t) { \
58  .bits = { \
59  .level = (uint32_t) 0, \
60  .major = (uint32_t) 2, \
61  .minor = (uint32_t) 19, \
62  .revision = (uint32_t) 0 \
63  } \
64  })
65 
72 #define MCUXCLCSS_CSS_INTERRUPT_ENABLE ((uint32_t) 1U)
73 #define MCUXCLCSS_CSS_INTERRUPT_DISABLE ((uint32_t) 0U)
74 
82 #define MCUXCLCSS_CSS_RESET_CLEAR ((uint32_t) 1U)
83 #define MCUXCLCSS_CSS_RESET_KEEP ((uint32_t) 0U)
84 
92 #define MCUXCLCSS_CSS_INTERRUPT_SET ((uint32_t) 1U)
93 #define MCUXCLCSS_CSS_INTERRUPT_KEEP ((uint32_t) 0U)
94 
102 #define MCUXCLCSS_ERROR_FLAGS_KEEP ((mcuxClCss_ErrorHandling_t) 0x0u)
103 #define MCUXCLCSS_ERROR_FLAGS_CLEAR ((mcuxClCss_ErrorHandling_t) 0x1u)
104 
112 #define MCUXCLCSS_RESET_DO_NOT_CANCEL ((mcuxClCss_ResetOption_t) 0x0u)
113 #define MCUXCLCSS_RESET_CANCEL ((mcuxClCss_ResetOption_t) 0x1u)
114 
127 #define MCUXCLCSS_STATUS_PPROT_UNPRIVILEGED_SECURE ((uint32_t) 0x0u)
128 #define MCUXCLCSS_STATUS_PPROT_PRIVILEGED_SECURE ((uint32_t) 0x1u)
129 #define MCUXCLCSS_STATUS_PPROT_UNPRIVILEGED_NONSECURE ((uint32_t) 0x2u)
130 #define MCUXCLCSS_STATUS_PPROT_PRIVILEGED_NONSECURE ((uint32_t) 0x3u)
131 
139 #define MCUXCLCSS_STATUS_ECDSAVFY_NORUN ((uint32_t) 0x0u)
140 #define MCUXCLCSS_STATUS_ECDSAVFY_FAIL ((uint32_t) 0x1u)
141 #define MCUXCLCSS_STATUS_ECDSAVFY_OK ((uint32_t) 0x2u)
142 #define MCUXCLCSS_STATUS_ECDSAVFY_ERROR ((uint32_t) 0x3u)
143 
150 #define MCUXCLCSS_STATUS_DRBGENTLVL_NONE ((uint32_t) 0x0u)
151 #define MCUXCLCSS_STATUS_DRBGENTLVL_LOW ((uint32_t) 0x1u)
152 #define MCUXCLCSS_STATUS_DRBGENTLVL_HIGH ((uint32_t) 0x2u)
153 
163 /**********************************************
164  * TYPEDEFS
165  **********************************************/
166 
179 typedef union
180 {
181  struct
182  {
183  uint32_t value;
184  } word;
185  struct
186  {
187  uint32_t revision :4;
188  uint32_t minor :8;
189  uint32_t major :4;
190  uint32_t level :4;
191  uint32_t :12;
192  } bits;
194 
200 typedef union
201 {
202  struct
203  {
204  uint32_t value;
205  } word;
206  struct
207  {
208  uint32_t busy :1;
209  uint32_t irq :1;
210  uint32_t err :1;
211  uint32_t prngready :1;
212  uint32_t ecdsavfy :2;
213  uint32_t pprot :2;
214  uint32_t drbgentlvl :2;
215  uint32_t dtrng_busy: 1;
216  uint32_t :2;
217  uint32_t :3;
218  uint32_t :1;
219  uint32_t :15;
220  } bits;
222 
228 typedef uint32_t mcuxClCss_ErrorHandling_t;
229 
235 typedef uint32_t mcuxClCss_ResetOption_t;
236 
242 typedef union
243 {
244  struct
245  {
246  uint32_t value;
247  } word;
248  struct
249  {
250  uint32_t cssint :1;
251  uint32_t :1;
252  uint32_t :30;
253  } bits;
255 
259 typedef union
260 {
261  struct
262  {
263  uint32_t value;
264  } word;
265  struct
266  {
267  uint32_t cssint :1;
268  uint32_t :1;
269  uint32_t :30;
270  } bits;
272 
276 typedef union
277 {
278  struct
279  {
280  uint32_t value;
281  } word;
282  struct
283  {
284  uint32_t cssint :1;
285  uint32_t :2;
286  uint32_t :29;
287  } bits;
289 
295 typedef union
296 {
297  struct
298  {
299  uint32_t value;
300  } word;
301  struct
302  {
303  uint32_t ciphersup :1;
304  uint32_t authciphersup :1;
305  uint32_t ecsignsup :1;
306  uint32_t ecvfysup :1;
307  uint32_t eckxchsup :1;
308  uint32_t keygensup :1;
309  uint32_t keyinsup :1;
310  uint32_t keyoutsup :1;
311  uint32_t kdeletesup :1;
312  uint32_t keyprovsup :1;
313  uint32_t ckdfsup :1;
314  uint32_t hkdfsup :1;
315  uint32_t tlsinitsup :1;
316  uint32_t hashsup :1;
317  uint32_t hmacsup :1;
318  uint32_t cmacsup :1;
319  uint32_t drbgreqsup :1;
320  uint32_t drbgtestsup :1;
321  uint32_t dtrgncfgloadsup :1;
322  uint32_t dtrngevalsup :1;
323  uint32_t gdetcfgloadsup :1;
324  uint32_t gdettrimsup :1;
325  uint32_t :10;
326  } bits;
328 
329 #define drbgreqsub drbgreqsup
330 
331 
332 
337 /**********************************************
338  * FUNCTIONS
339  **********************************************/
361  mcuxClCss_HwVersion_t * result
362  );
363 
377  mcuxClCss_HwConfig_t * result
378  );
379 
393  mcuxClCss_HwState_t * result
394  );
395 
409  void
410  );
411 
439  );
440 
454  void
455 );
456 
471  );
472 
487  );
488 
503  );
504 
519  );
520 
540  mcuxClCss_ErrorHandling_t errorHandling
541  );
542 
566  uint32_t counterLimit,
567  mcuxClCss_ErrorHandling_t errorHandling
568  );
569 
581  void);
582 
598  mcuxClCss_ErrorHandling_t errorHandling
599  );
600 
618  mcuxClCss_ErrorHandling_t errorHandling,
619  uint32_t *errorLevel
620  );
621 
637  uint32_t delay
638  );
639 
655  uint32_t * delay
656  );
657 
658 
659 
660 
661 
662 
663 
664 
665 
666 #endif /* MCUXCLCSS_COMMON_H_ */
667 
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwVersion(mcuxClCss_HwVersion_t *result)
Determines the version of the underlying CSS hardware IP.
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetIntEnableFlags(mcuxClCss_InterruptOptionEn_t *result)
Get interrupt enable flags.
uint32_t prngready
CSS PRNG is seeded and ready to use.
Definition: mcuxClCss_Common.h:211
#define MCUXCLCSS_API
Marks a function as a public API function of the mcuxClCss component.
Definition: mcuxClCss_Common.h:40
uint32_t dtrng_busy
Indicates the DTRNG is gathering entropy.
Definition: mcuxClCss_Common.h:215
Type to control which CSS interrupts should be reset when calling mcuxClCss_ResetIntFlags.
Definition: mcuxClCss_Common.h:259
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:183
uint32_t keyprovsup
Indicates whether the keyprov command is supported.
Definition: mcuxClCss_Common.h:312
uint32_t authciphersup
Indicates whether the auth_cipher command is supported.
Definition: mcuxClCss_Common.h:304
uint32_t gdettrimsup
Indicates whether the gdet_trim command is supported.
Definition: mcuxClCss_Common.h:324
uint32_t ciphersup
Indicates whether the cipher command is supported.
Definition: mcuxClCss_Common.h:303
uint32_t pprot
The privilege/security level of the most recently started CSS command (For possible values of this fi...
Definition: mcuxClCss_Common.h:213
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:204
uint32_t keyoutsup
Indicates whether the keyout command is supported.
Definition: mcuxClCss_Common.h:310
uint32_t dtrngevalsup
Indicates whether the dtrng_eval command is supported.
Definition: mcuxClCss_Common.h:322
Result type of mcuxClCss_GetHwState.
Definition: mcuxClCss_Common.h:200
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetRandomStartDelay(uint32_t delay)
Set the random start delay for AES based operations.
uint32_t major
Major version.
Definition: mcuxClCss_Common.h:189
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Disable(void)
Disable the CSSv2.
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwConfig(mcuxClCss_HwConfig_t *result)
Determines the hardware configuration of the underlying CSS hardware IP.
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_LimitedWaitForOperation(uint32_t counterLimit, mcuxClCss_ErrorHandling_t errorHandling)
Await the completion of a CSS operation for a limited amount of time and optionally clear the error s...
uint32_t drbgtestsup
Indicates whether the drbg_test command is supported.
Definition: mcuxClCss_Common.h:320
uint32_t cssint
Whether CSS interrupt should be reset. (For possible values of this field, see mcuxClCss_InterruptOpt...
Definition: mcuxClCss_Common.h:267
uint32_t eckxchsup
Indicates whether the dhkey_xch command is supported.
Definition: mcuxClCss_Common.h:307
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ResetErrorFlags(void)
Resets all error flags that have been set by a previous operation.
uint32_t hkdfsup
Indicates whether the hkdf command is supported.
Definition: mcuxClCss_Common.h:314
uint32_t revision
Revision number.
Definition: mcuxClCss_Common.h:187
CSSv2 type header.
uint32_t mcuxClCss_ErrorHandling_t
Type to handle CSS error clearing options.
Definition: mcuxClCss_Common.h:228
uint32_t drbgreqsup
Indicates whether the drbg_req command is supported.
Definition: mcuxClCss_Common.h:319
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetRandomStartDelay(uint32_t *delay)
Get the random start delay for AES based operations.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:299
uint32_t ecsignsup
Indicates whether the ecsign command is supported.
Definition: mcuxClCss_Common.h:305
uint32_t drbgentlvl
Entropy quality of the current DRBG instance (For possible values of this field, see MCUXCLCSS_STATUS...
Definition: mcuxClCss_Common.h:214
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetErrorCode(mcuxClCss_ErrorHandling_t errorHandling)
Get the last CSS error code and optionally clear the error status.
Type to control which CSS interrupts should be set when calling mcuxClCss_SetIntFlags.
Definition: mcuxClCss_Common.h:276
uint32_t kdeletesup
Indicates whether the kdelete command is supported.
Definition: mcuxClCss_Common.h:311
uint32_t hmacsup
Indicates whether the hmac command is supported.
Definition: mcuxClCss_Common.h:317
uint32_t keyinsup
Indicates whether the keyin command is supported.
Definition: mcuxClCss_Common.h:309
uint32_t irq
CSS interrupt activated.
Definition: mcuxClCss_Common.h:209
uint32_t minor
Minor version.
Definition: mcuxClCss_Common.h:188
uint32_t tlsinitsup
Indicates whether the tls_init command is supported.
Definition: mcuxClCss_Common.h:315
uint32_t ecvfysup
Indicates whether the ecvfy command is supported.
Definition: mcuxClCss_Common.h:306
uint32_t hashsup
Indicates whether the hash command is supported.
Definition: mcuxClCss_Common.h:316
uint32_t keygensup
Indicates whether the keygen command is supported.
Definition: mcuxClCss_Common.h:308
uint32_t level
Release level version.
Definition: mcuxClCss_Common.h:190
uint32_t dtrgncfgloadsup
Indicates whether the dtrng_cfg_load command is is supported.
Definition: mcuxClCss_Common.h:321
uint32_t busy
CSS is busy.
Definition: mcuxClCss_Common.h:208
uint32_t ckdfsup
Indicates whether the ckdf command is supported.
Definition: mcuxClCss_Common.h:313
Result type of mcuxClCss_GetHwConfig.
Definition: mcuxClCss_Common.h:295
uint32_t gdetcfgloadsup
Indicates whether the gdet_cfg_load command is supported.
Definition: mcuxClCss_Common.h:323
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetErrorLevel(mcuxClCss_ErrorHandling_t errorHandling, uint32_t *errorLevel)
Get the last CSS error code and level and optionally clear the error status.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:246
Result type of mcuxClCss_GetHwVersion.
Definition: mcuxClCss_Common.h:179
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetIntFlags(mcuxClCss_InterruptOptionSet_t options)
Set the interrupt status register, for debug and testing purposes.
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwState(mcuxClCss_HwState_t *result)
Determines the current state of the CSS.
Command option type for mcuxClCss_SetIntEnableFlags and mcuxClCss_GetIntEnableFlags.
Definition: mcuxClCss_Common.h:242
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_WaitForOperation(mcuxClCss_ErrorHandling_t errorHandling)
Wait for a CSS operation and optionally clear the error status.
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ResetIntFlags(mcuxClCss_InterruptOptionRst_t options)
Clear the interrupt status register.
Provides the API for the CSSL flow protection mechanism.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:280
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetIntEnableFlags(mcuxClCss_InterruptOptionEn_t options)
Set interrupt enable flags.
uint32_t ecdsavfy
ECDSA verify operation state (For possible values of this field, see MCUXCLCSS_STATUS_ECDSAVFY_)
Definition: mcuxClCss_Common.h:212
uint32_t cssint
Whether CSS interrupt should be set. (For possible values of this field, see mcuxClCss_InterruptOptio...
Definition: mcuxClCss_Common.h:284
uint32_t mcuxClCss_ResetOption_t
Type to handle CSS reset options.
Definition: mcuxClCss_Common.h:235
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Enable_Async(void)
Enables the CSS.
uint32_t cssint
Whether CSS interrupt should be used. (For possible values of this field, see mcuxClCss_InterruptOpti...
Definition: mcuxClCss_Common.h:250
uint32_t cmacsup
Indicates whether the cmac command is supported.
Definition: mcuxClCss_Common.h:318
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Reset_Async(mcuxClCss_ResetOption_t options)
Perform a synchronous reset of the CSS.
uint64_t mcuxClCss_Status_Protected_t
Type for CSS driver protected status codes.
Definition: mcuxClCss_Types.h:183
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClCss_Common.h:263
uint32_t err
CSS is in error state.
Definition: mcuxClCss_Common.h:210