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 
14 /**
15  * @file  mcuxClCss_Common.h
16  * @brief CSSv2 header for common functionality.
17  *
18  * This header exposes functions that support hardware state management for other CSSv2 commands.
19  */
20 
21 /**
22  * @defgroup mcuxClCss_Common mcuxClCss_Common
23  * @brief This part of the @ref mcuxClCss driver supports common functionality
24  * @ingroup mcuxClCss
25  * @{
26  */
27 #ifndef MCUXCLCSS_COMMON_H_
28 #define MCUXCLCSS_COMMON_H_
29 
30 #include <mcuxClCss_Types.h> // Common types
31 #include <mcuxCsslFlowProtection.h>
32 
33 /**
34  * @defgroup mcuxClCss_Common_Macros mcuxClCss_Common_Macros
35  * @brief Defines all macros of @ref mcuxClCss_Common
36  * @ingroup mcuxClCss_Common
37  * @{
38  */
39 
40 #define MCUXCLCSS_API    ///< Marks a function as a public API function of the mcuxClCss component
41 
42 /**********************************************
43  * CONSTANTS
44  **********************************************/
45 
46 /**
47  * @def MCUXCLCSS_HW_VERSION
48  * @brief Compatible CSS hardware IP version for the CLNS release that this header is part of.
49  * <table>
50  *     <caption>Compatible CSS hardware IP version</caption>
51  *     <tr><th>Version component<th>Value
52  *     <tr><td>Level            <td>0
53  *     <tr><td>Major            <td>2
54  *     <tr><td>Minor            <td>19
55  *     <tr><td>Revision         <td>0
56  * </table> */
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 
66 /**
67  * @defgroup mcuxClCss_InterruptOptionEn_t_Macros mcuxClCss_InterruptOptionEn_t
68  * @brief Defines interrupt enable option values
69  * @ingroup mcuxClCss_Common_Macros
70  * @{
71  */
72 #define MCUXCLCSS_CSS_INTERRUPT_ENABLE              ((uint32_t) 1U) ///< Set this option at #mcuxClCss_InterruptOptionEn_t.cssint to allow CSS to trigger an interrupt
73 #define MCUXCLCSS_CSS_INTERRUPT_DISABLE             ((uint32_t) 0U) ///< Set this option at #mcuxClCss_InterruptOptionEn_t.cssint to prevent CSS from triggering an interrupt
74 /**@}*/
75 
76 /**
77  * @defgroup mcuxClCss_InterruptOptionRst_t_Macros mcuxClCss_InterruptOptionRst_t
78  * @brief Defines interrupt reset option values
79  * @ingroup mcuxClCss_Common_Macros
80  * @{
81  */
82 #define MCUXCLCSS_CSS_RESET_CLEAR             ((uint32_t) 1U) ///< Set this option at #mcuxClCss_InterruptOptionRst_t.cssint to reset the CSS interrupt flag
83 #define MCUXCLCSS_CSS_RESET_KEEP              ((uint32_t) 0U) ///< Set this option at #mcuxClCss_InterruptOptionRst_t.cssint to keep the CSS interrupt flag
84 /**@}*/
85 
86 /**
87  * @defgroup mcuxClCss_InterruptOptionSet_t_Macros mcuxClCss_InterruptOptionSet_t
88  * @brief Defines interrupt set option values
89  * @ingroup mcuxClCss_Common_Macros
90  * @{
91  */
92 #define MCUXCLCSS_CSS_INTERRUPT_SET          ((uint32_t) 1U) ///< Set this option at #mcuxClCss_InterruptOptionSet_t.cssint to set the CSS interrupt flag
93 #define MCUXCLCSS_CSS_INTERRUPT_KEEP         ((uint32_t) 0U) ///< Set this option at #mcuxClCss_InterruptOptionSet_t.cssint to leave the CSS interrupt flag unchanged
94 /**@}*/
95 
96 /**
97  * @defgroup MCUXCLCSS_ERROR_FLAGS_ MCUXCLCSS_ERROR_FLAGS_
98  * @brief Options for error flag clearing
99  * @ingroup mcuxClCss_Common_Macros
100  * @{
101  */
102 #define MCUXCLCSS_ERROR_FLAGS_KEEP  ((mcuxClCss_ErrorHandling_t) 0x0u) ///< Set this option at #mcuxClCss_ErrorHandling_t to not clear any error flags
103 #define MCUXCLCSS_ERROR_FLAGS_CLEAR ((mcuxClCss_ErrorHandling_t) 0x1u) ///< Set this option at #mcuxClCss_ErrorHandling_t to clear all CSS error flags
104 /**@}*/
105 
106 /**
107  * @defgroup MCUXCLCSS_RESET_ MCUXCLCSS_RESET_
108  * @brief Options for reset handling
109  * @ingroup mcuxClCss_Common_Macros
110  * @{
111  */
112 #define MCUXCLCSS_RESET_DO_NOT_CANCEL ((mcuxClCss_ResetOption_t) 0x0u) ///< Set this option at #mcuxClCss_ResetOption_t to abort the requested command if another CSS operation is still running
113 #define MCUXCLCSS_RESET_CANCEL        ((mcuxClCss_ResetOption_t) 0x1u) ///< Set this option at #mcuxClCss_ResetOption_t to execute the requested command even if another CSS operation is still running
114 /**@}*/
115 
116 /**
117  * @defgroup MCUXCLCSS_STATUS_PPROT_ MCUXCLCSS_STATUS_PPROT_
118  * @brief Values for the privilege/security level of CSS commands
119  *
120  * Note that some keys and memory areas may only be accessible when CSS is on a certain privilege/security level.
121  *
122  * The default value, before any command has been executed, is #MCUXCLCSS_STATUS_PPROT_UNPRIVILEGED_NONSECURE.
123  *
124  * @ingroup mcuxClCss_Common_Macros
125  * @{
126  */
127 #define MCUXCLCSS_STATUS_PPROT_UNPRIVILEGED_SECURE    ((uint32_t) 0x0u) ///< This value of #mcuxClCss_HwState_t.pprot means that the most recently started CSS operation was or is running in unprivileged secure mode
128 #define MCUXCLCSS_STATUS_PPROT_PRIVILEGED_SECURE      ((uint32_t) 0x1u) ///< This value of #mcuxClCss_HwState_t.pprot means that the most recently started CSS operation was or is running in privileged secure mode
129 #define MCUXCLCSS_STATUS_PPROT_UNPRIVILEGED_NONSECURE ((uint32_t) 0x2u) ///< This value of #mcuxClCss_HwState_t.pprot means that the most recently started CSS operation was or is running in unprivileged non-secure mode
130 #define MCUXCLCSS_STATUS_PPROT_PRIVILEGED_NONSECURE   ((uint32_t) 0x3u) ///< This value of #mcuxClCss_HwState_t.pprot means that the most recently started CSS operation was or is running in privileged non-secure mode
131 /**@}*/
132 
133 /**
134  * @defgroup MCUXCLCSS_STATUS_ECDSAVFY_ MCUXCLCSS_STATUS_ECDSAVFY_
135  * @brief ECDSA verify check values
136  * @ingroup mcuxClCss_Common_Macros
137  * @{
138  */
139 #define MCUXCLCSS_STATUS_ECDSAVFY_NORUN  ((uint32_t) 0x0u) ///< This value of #mcuxClCss_HwState_t.ecdsavfy means that no ECDSA verify operation has been executed
140 #define MCUXCLCSS_STATUS_ECDSAVFY_FAIL   ((uint32_t) 0x1u) ///< This value of #mcuxClCss_HwState_t.ecdsavfy means that the most recently finished ECDSA signature verification failed
141 #define MCUXCLCSS_STATUS_ECDSAVFY_OK     ((uint32_t) 0x2u) ///< This value of #mcuxClCss_HwState_t.ecdsavfy means that the most recently finished ECDSA signature verification passed
142 #define MCUXCLCSS_STATUS_ECDSAVFY_ERROR  ((uint32_t) 0x3u) ///< This value of #mcuxClCss_HwState_t.ecdsavfy means that an error has occurred
143 /**@}*/
144 
145 /**
146  * @defgroup MCUXCLCSS_STATUS_DRBGENTLVL_ MCUXCLCSS_STATUS_DRBGENTLVL_
147  * @brief Constants for Entropy quality of the current DRBG instance
148  * @ingroup mcuxClCss_Common_Macros
149  * @{ */
150 #define MCUXCLCSS_STATUS_DRBGENTLVL_NONE ((uint32_t) 0x0u) ///< This value of #mcuxClCss_HwState_t.drbgentlvl means that the DRBG is not running
151 #define MCUXCLCSS_STATUS_DRBGENTLVL_LOW  ((uint32_t) 0x1u) ///< This value of #mcuxClCss_HwState_t.drbgentlvl means that the DRBG can generate random numbers with a low security strength (sufficient for commands with a low DRBG security strength requirement, see the function description to check which level is required)
152 #define MCUXCLCSS_STATUS_DRBGENTLVL_HIGH ((uint32_t) 0x2u) ///< This value of #mcuxClCss_HwState_t.drbgentlvl means that the DRBG can generate random numbers with 128 bits of security strength (sufficient for commands with a high DRBG security strength requirement, see the function description to check which level is required)
153 /** @} */
154 
155 
156 
157 
158 
159 /**
160  * @}
161  */
162 
163 /**********************************************
164  * TYPEDEFS
165  **********************************************/
166 
167 /**
168  * @defgroup mcuxClCss_Common_Types mcuxClCss_Common_Types
169  * @brief Defines all types of @ref mcuxClCss_Common
170  * @ingroup mcuxClCss_Common
171  * @{
172  */
173 
174 /**
175  * @brief Result type of #mcuxClCss_GetHwVersion
176  *
177  * Contains the CSS version value.
178  */
179 typedef union
180 {
181     struct
182     {
183         uint32_t value; ///< Accesses the bit field as a full word
184     } word;             ///< Access #mcuxClCss_HwVersion_t word-wise
185     struct
186     {
187         uint32_t revision :4; ///< Revision number
188         uint32_t minor :8;    ///< Minor version
189         uint32_t major :4;    ///< Major version
190         uint32_t level :4;    ///< Release level version
191         uint32_t :12;         ///< RFU
192     } bits;                   ///< Access #mcuxClCss_HwVersion_t bit-wise
193 } mcuxClCss_HwVersion_t;
194 
195 /**
196  * @brief Result type of #mcuxClCss_GetHwState
197  *
198  * Contains CSS status information.
199  */
200 typedef union
201 {
202     struct
203     {
204         uint32_t value; ///< Accesses the bit field as a full word
205     } word;             ///< Access #mcuxClCss_HwState_t word-wise
206     struct
207     {
208         uint32_t busy :1;       ///< CSS is busy
209         uint32_t irq :1;        ///< CSS interrupt activated
210         uint32_t err :1;        ///< CSS is in error state
211         uint32_t prngready :1;  ///< CSS PRNG is seeded and ready to use
212         uint32_t ecdsavfy :2;   ///< ECDSA verify operation state (For possible values of this field, see @ref MCUXCLCSS_STATUS_ECDSAVFY_)
213         uint32_t pprot :2;      ///< The privilege/security level of the most recently started CSS command (For possible values of this field, see @ref MCUXCLCSS_STATUS_PPROT_)
214         uint32_t drbgentlvl :2; ///< Entropy quality of the current DRBG instance (For possible values of this field, see @ref MCUXCLCSS_STATUS_DRBGENTLVL_)
215         uint32_t dtrng_busy: 1; ///< Indicates the DTRNG is gathering entropy
216         uint32_t :2;            ///< RFU
217         uint32_t :3;            ///< RFU
218         uint32_t :1;            ///< RFU
219         uint32_t :15;           ///< RFU
220     } bits;                     ///< Access #mcuxClCss_HwState_t bit-wise
221 } mcuxClCss_HwState_t;
222 
223 /**
224  * @brief Type to handle CSS error clearing options
225  *
226  * For possible values, see @ref MCUXCLCSS_ERROR_FLAGS_.
227  */
228 typedef uint32_t mcuxClCss_ErrorHandling_t;
229 
230 /**
231  * @brief Type to handle CSS reset options
232  *
233  * For possible values, see @ref MCUXCLCSS_RESET_.
234  */
235 typedef uint32_t mcuxClCss_ResetOption_t;
236 
237 /**
238  * @brief Command option type for #mcuxClCss_SetIntEnableFlags and #mcuxClCss_GetIntEnableFlags
239  *
240  * Used to get/set CSS interrupt enable options.
241  */
242 typedef union
243 {
244     struct
245     {
246         uint32_t value; ///< Accesses the bit field as a full word
247     } word;             ///< Access #mcuxClCss_InterruptOptionEn_t word-wise
248     struct
249     {
250         uint32_t cssint :1;  ///< Whether CSS interrupt should be used. (For possible values of this field, see @ref mcuxClCss_InterruptOptionEn_t_Macros)
251         uint32_t :1;         ///< RFU
252         uint32_t :30;        ///< RFU
253     } bits;                  ///< Access #mcuxClCss_InterruptOptionEn_t bit-wise
254 } mcuxClCss_InterruptOptionEn_t;
255 
256 /**
257  * @brief Type to control which CSS interrupts should be reset when calling #mcuxClCss_ResetIntFlags
258  */
259 typedef union
260 {
261     struct
262     {
263         uint32_t value; ///< Accesses the bit field as a full word
264     } word;             ///< Access #mcuxClCss_InterruptOptionRst_t word-wise
265     struct
266     {
267         uint32_t cssint :1;  ///< Whether CSS interrupt should be reset. (For possible values of this field, see @ref mcuxClCss_InterruptOptionRst_t_Macros)
268         uint32_t :1;         ///< RFU
269         uint32_t :30;        ///< RFU
270     } bits;                  ///< Access #mcuxClCss_InterruptOptionRst_t bit-wise
271 } mcuxClCss_InterruptOptionRst_t;
272 
273 /**
274  * @brief Type to control which CSS interrupts should be set when calling #mcuxClCss_SetIntFlags
275  */
276 typedef union
277 {
278     struct
279     {
280         uint32_t value; ///< Accesses the bit field as a full word
281     } word;             ///< Access #mcuxClCss_InterruptOptionSet_t word-wise
282     struct
283     {
284         uint32_t cssint :1;     ///< Whether CSS interrupt should be set. (For possible values of this field, see @ref mcuxClCss_InterruptOptionSet_t_Macros)
285         uint32_t :2;            ///< RFU
286         uint32_t :29;           ///< RFU
287     } bits;                     ///< Access #mcuxClCss_InterruptOptionSet_t bit-wise
288 } mcuxClCss_InterruptOptionSet_t;
289 
290 /**
291  * @brief Result type of #mcuxClCss_GetHwConfig
292  *
293  * Contains CSS configuration values.
294  */
295 typedef union
296 {
297     struct
298     {
299         uint32_t value; ///< Accesses the bit field as a full word
300     } word;             ///< Access #mcuxClCss_InterruptOptionSet_t word-wise
301     struct
302     {
303         uint32_t ciphersup :1;       ///< Indicates whether the cipher command is supported
304         uint32_t authciphersup :1;   ///< Indicates whether the auth_cipher command is supported
305         uint32_t ecsignsup :1;       ///< Indicates whether the ecsign command is supported
306         uint32_t ecvfysup :1;        ///< Indicates whether the ecvfy command is supported
307         uint32_t eckxchsup :1;       ///< Indicates whether the dhkey_xch command is supported
308         uint32_t keygensup :1;       ///< Indicates whether the keygen command is supported
309         uint32_t keyinsup :1;        ///< Indicates whether the keyin command is supported
310         uint32_t keyoutsup :1;       ///< Indicates whether the keyout command  is supported
311         uint32_t kdeletesup :1;      ///< Indicates whether the kdelete command is supported
312         uint32_t keyprovsup :1;      ///< Indicates whether the keyprov command is supported
313         uint32_t ckdfsup :1;         ///< Indicates whether the ckdf command is supported
314         uint32_t hkdfsup :1;         ///< Indicates whether the hkdf command is supported
315         uint32_t tlsinitsup :1;      ///< Indicates whether the tls_init command is supported
316         uint32_t hashsup :1;         ///< Indicates whether the hash command is supported
317         uint32_t hmacsup :1;         ///< Indicates whether the hmac command is supported
318         uint32_t cmacsup :1;         ///< Indicates whether the cmac command is supported
319         uint32_t drbgreqsup :1;      ///< Indicates whether the drbg_req command is supported
320         uint32_t drbgtestsup :1;     ///< Indicates whether the drbg_test command is supported
321         uint32_t dtrgncfgloadsup :1; ///< Indicates whether the dtrng_cfg_load command is is supported
322         uint32_t dtrngevalsup :1;    ///< Indicates whether the dtrng_eval command is supported
323         uint32_t gdetcfgloadsup :1;  ///< Indicates whether the gdet_cfg_load command is supported
324         uint32_t gdettrimsup :1;     ///< Indicates whether the gdet_trim command is supported
325         uint32_t :10;                ///< RFU
326     } bits;                          ///< Access #mcuxClCss_InterruptOptionSet_t bit-wise
327 } mcuxClCss_HwConfig_t;
328 
329 #define drbgreqsub drbgreqsup ///< Deprecated name for #mcuxClCss_HwConfig_t.drbgreqsup
330 
331 
332 
333 /**
334  * @}
335  */
336 
337 /**********************************************
338  * FUNCTIONS
339  **********************************************/
340 /**
341  * @defgroup mcuxClCss_Common_Functions mcuxClCss_Common_Functions
342  * @brief Defines all functions of @ref mcuxClCss_Common
343  * @ingroup mcuxClCss_Common
344  * @{
345  */
346 /**
347  * @brief Determines the version of the underlying CSS hardware IP.
348  *
349  * @attention This header was delivered as part of a CLNS release which is compatible with a specific CSS hardware IP version,
350  *            which is defined by the macro #MCUXCLCSS_HW_VERSION.
351  *
352  * @param[out] result Pointer which will be filled with the CSS hardware version
353  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
354  */
355 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetHwVersion)
356 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwVersion(
357     mcuxClCss_HwVersion_t * result
358     );
359 
360 /**
361  * @brief Determines the hardware configuration of the underlying CSS hardware IP.
362  *
363  * @param[out] result Pointer which will be filled with the CSS hardware configuration
364  *
365  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
366  */
367 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetHwConfig)
368 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwConfig(
369     mcuxClCss_HwConfig_t * result
370     );
371 
372 /**
373  * @brief Determines the current state of the CSS.
374  *
375  * @param[out] result Pointer which will be filled with the CSS status information
376  *
377  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
378  */
379 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetHwState)
380 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetHwState(
381     mcuxClCss_HwState_t * result
382     );
383 
384 /**
385  * @brief Enables the CSS.
386  *
387  * Call #mcuxClCss_WaitForOperation to complete the operation.
388  *
389  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK_WAIT
390  */
391 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Enable_Async)
392 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Enable_Async(
393     void
394     );
395 
396 /**
397  * @brief Perform a synchronous reset of the CSS.
398  *
399  * This means that:
400  * - any running CSS command will be stopped,
401  * - all errors will be cleared,
402  * - all keys will be deleted,
403  * - any RNG entropy will be discarded,
404  * - the glitch detector will be reset and
405  * - the run-time fingerprint will be restored to its default value.
406  *
407  * Call #mcuxClCss_WaitForOperation to complete the operation.
408  *
409  * @param[in] options A value indicating whether any running CSS operations shall be canceled
410  *
411  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
412  *
413  * @retval #MCUXCLCSS_STATUS_SW_CANNOT_INTERRUPT if a running operation prevented the reset
414  * @retval #MCUXCLCSS_STATUS_OK_WAIT             on successful request
415  */
416 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Reset_Async)
417 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Reset_Async(
418     mcuxClCss_ResetOption_t options
419     );
420 
421 /**
422  * @brief Disable the CSSv2.
423  *
424  * This is useful as a power saving mechanism.
425  *
426  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
427  */
428 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_Disable)
429 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Disable(
430     void
431 );
432 
433 /**
434  * @brief Set interrupt enable flags.
435  *
436  * @param[in] options The command options, determining which interrupts should be enabled or disabled. For more information, see #mcuxClCss_InterruptOptionEn_t.
437  *
438  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
439  */
440 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_SetIntEnableFlags)
441 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetIntEnableFlags(
442     mcuxClCss_InterruptOptionEn_t options
443     );
444 
445 /**
446  * @brief Get interrupt enable flags.
447  *
448  * @param[out] result Pointer which is filled with the configuration of the interrupts enable register.
449  *
450  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
451  */
452 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetIntEnableFlags)
453 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetIntEnableFlags(
454     mcuxClCss_InterruptOptionEn_t * result
455     );
456 
457 /**
458  * @brief Clear the interrupt status register.
459  *
460  * @param[in] options The command options, determining which interrupt status bits should be cleared. For more information, see #mcuxClCss_InterruptOptionRst_t.
461  *
462  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
463  */
464 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_ResetIntFlags)
465 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ResetIntFlags(
466     mcuxClCss_InterruptOptionRst_t options
467     );
468 
469 /**
470  * @brief Set the interrupt status register, for debug and testing purposes.
471  *
472  * @param[in] options The command options, determining which interrupt status bits should be set. For more information, see #mcuxClCss_InterruptOptionSet_t.
473  *
474  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
475  */
476 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_SetIntFlags)
477 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetIntFlags(
478     mcuxClCss_InterruptOptionSet_t options
479     );
480 
481 /**
482  * @brief Wait for a CSS operation and optionally clear the error status.
483  *
484  * If a CSS operation is active, this function waits for completion of that operation. For this, the
485  * busy flag of CSS is polled. Additionally, this function checks and returns any applicable error indication.
486  * If no operation is active, the function returns immediately.
487  *
488  * @param[in] errorHandling Define if error flags shall be cleared.
489  *
490  * @retval #MCUXCLCSS_STATUS_OK if the last operation was successful, or no operation was active
491  *
492  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
493  */
494 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_WaitForOperation)
495 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_WaitForOperation(
496     mcuxClCss_ErrorHandling_t errorHandling
497     );
498 
499 /**
500  * @brief Await the completion of a CSS operation for a limited amount of time and optionally clear the error status.
501  *
502  * If a CSS operation is active, this function waits for completion of that operation until a counter expires.
503  * For this, the busy flag of CSS is polled. The counting mechanism behaves like a simple for-loop from
504  * @p counterLimit to one. This counter does not have a well-defined relationship to real-world time.
505  * Additionally, this function checks and returns any applicable error indication.
506  * If no operation is active, the function returns immediately.
507  *
508  * @param[in] counterLimit The limit of the wait counter.
509  * @param[in] errorHandling Define if error flags shall be cleared.
510  *
511  * @retval #MCUXCLCSS_STATUS_OK if the last operation was successful, or no operation was active
512  * @retval #MCUXCLCSS_STATUS_SW_COUNTER_EXPIRED if the counter expired while waiting for the operation to complete
513  *
514  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
515  */
516 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_LimitedWaitForOperation)
517 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_LimitedWaitForOperation(
518     uint32_t counterLimit,
519     mcuxClCss_ErrorHandling_t errorHandling
520     );
521 
522 /**
523  * @brief Resets all error flags that have been set by a previous operation.
524  *
525  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code is always #MCUXCLCSS_STATUS_OK
526  */
527 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_ResetErrorFlags)
528 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_ResetErrorFlags(
529     void);
530 
531 /**
532  * @brief Get the last CSS error code and optionally clear the error status.
533  *
534  * @param[in] errorHandling Define if error flags shall be cleared.
535  *
536  * @retval #MCUXCLCSS_STATUS_OK 	if the last operation was successful or no operation was active
537  *
538  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
539  */
540 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetErrorCode)
541 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetErrorCode(
542     mcuxClCss_ErrorHandling_t errorHandling
543     );
544 
545 /**
546  * @brief Get the last CSS error code and level and optionally clear the error status.
547  *
548  * @param[in]  errorHandling    Define if error flags shall be cleared.
549  * @param[out] errorLevel       Pointer to the location that will receive the value of the error level.
550  *
551  * @retval #MCUXCLCSS_STATUS_OK  if the last operation was successful or no operation was active
552  * @retval #MCUXCLCSS_STATUS_    if the last operation resulted in an error
553  *
554  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
555  */
556 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetErrorLevel)
557 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetErrorLevel(
558     mcuxClCss_ErrorHandling_t errorHandling,
559     uint32_t *errorLevel
560     );
561 
562 /**
563  * @brief Set the random start delay for AES based operations. This impacts mcuxClCss_Aead_*, mcuxClCss_Cipher_*, mcuxClCss_Cmac_*, ncpClCss_Ckdf_*, mcuxClCss_KeyImport_Async, mcuxClCss_KeyExport_Async
564  *
565  * @param[in] delay Define the max random start delay. Acceptable values are a power of 2 minus one, starting from 0 to 1023 (0, 1, 3, 7, ..., 1023).
566  *
567  * @retval #MCUXCLCSS_STATUS_OK if the operation was successful
568  *
569  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
570  */
571 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_SetRandomStartDelay)
572 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_SetRandomStartDelay(
573     uint32_t delay
574     );
575 
576 /**
577  * @brief Get the random start delay for AES based operations.
578  *
579  * @param[out] delay Pointer to store random start delay configuration.
580  *
581  * @retval #MCUXCLCSS_STATUS_OK if the operation was successful
582  *
583  *  @return A code-flow protected error code (see @ref mcuxCsslFlowProtection). The error code can be any error code in @ref MCUXCLCSS_STATUS_, see individual documentation for more information
584  */
585 MCUX_CSSL_FP_FUNCTION_DECL(mcuxClCss_GetRandomStartDelay)
586 MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_GetRandomStartDelay(
587     uint32_t * delay
588     );
589 
590 
591 
592 
593 
594 
595 
596 
597 
598 #endif /* MCUXCLCSS_COMMON_H_ */
599 
600 /**
601  * @}
602  *
603  * @}
604  */
605 
606 
607