MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Common.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2023 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
40
47#ifndef MCUXCLELS_COMMON_H_
48#define MCUXCLELS_COMMON_H_
49
50#include <mcuxClConfig.h> // Exported features flags header
51#include <mcuxClEls_Types.h> // Common types
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
65
66#define MCUXCLELS_API
67
68/**********************************************
69 * CONSTANTS
70 **********************************************/
71
72#ifdef MCUXCL_FEATURE_ELS_DMA_FINAL_ADDRESS_READBACK
73 #define MCUXCLELS_DMA_READBACK_PROTECTION_TOKEN MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_CompareDmaFinalOutputAddress)
74#else
75 #define MCUXCLELS_DMA_READBACK_PROTECTION_TOKEN (0u)
76#endif
77
78
85#define MCUXCLELS_ELS_INTERRUPT_ENABLE (0x01U)
86#define MCUXCLELS_ELS_INTERRUPT_DISABLE (0x00U)
87#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
88#define MCUXCLELS_GLITCH_DETECTOR_INTERRUPT_ENABLE ((uint32_t) 1U)
89#define MCUXCLELS_GLITCH_DETECTOR_INTERRUPT_DISABLE ((uint32_t) 0U)
90#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
92
99#define MCUXCLELS_ELS_RESET_CLEAR (0x01U)
100#define MCUXCLELS_ELS_RESET_KEEP (0x00U)
101#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
102#define MCUXCLELS_GLITCH_DETECTOR_RESET_CLEAR ((uint32_t) 1U)
103#define MCUXCLELS_GLITCH_DETECTOR_RESET_KEEP ((uint32_t) 0U)
104#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
106
113#define MCUXCLELS_ELS_INTERRUPT_SET (0x01U)
114#define MCUXCLELS_ELS_INTERRUPT_KEEP (0x00U)
115#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
116#define MCUXCLELS_GLITCH_DETECTOR_NEG_SET (0x01U)
117#define MCUXCLELS_GLITCH_DETECTOR_NEG_KEEP (0x00U)
118#define MCUXCLELS_GLITCH_DETECTOR_POS_SET (0x01U)
119#define MCUXCLELS_GLITCH_DETECTOR_POS_KEEP (0x00U)
120#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
122
129#define MCUXCLELS_ERROR_FLAGS_KEEP ((mcuxClEls_ErrorHandling_t) 0x0u)
130#define MCUXCLELS_ERROR_FLAGS_CLEAR ((mcuxClEls_ErrorHandling_t) 0x1u)
132
139#define MCUXCLELS_RESET_DO_NOT_CANCEL ((mcuxClEls_ResetOption_t) 0x0u)
140#define MCUXCLELS_RESET_CANCEL ((mcuxClEls_ResetOption_t) 0x1u)
142
154#define MCUXCLELS_STATUS_PPROT_UNPRIVILEGED_SECURE ((uint32_t) 0x0u)
155#define MCUXCLELS_STATUS_PPROT_PRIVILEGED_SECURE ((uint32_t) 0x1u)
156#define MCUXCLELS_STATUS_PPROT_UNPRIVILEGED_NONSECURE ((uint32_t) 0x2u)
157#define MCUXCLELS_STATUS_PPROT_PRIVILEGED_NONSECURE ((uint32_t) 0x3u)
159
166#define MCUXCLELS_STATUS_ECDSAVFY_NORUN ((uint32_t) 0x0u)
167#define MCUXCLELS_STATUS_ECDSAVFY_FAIL ((uint32_t) 0x1u)
168#define MCUXCLELS_STATUS_ECDSAVFY_OK ((uint32_t) 0x2u)
169#define MCUXCLELS_STATUS_ECDSAVFY_ERROR ((uint32_t) 0x3u)
171
177#define MCUXCLELS_STATUS_DRBGENTLVL_NONE ((uint32_t) 0x0u)
178#define MCUXCLELS_STATUS_DRBGENTLVL_LOW ((uint32_t) 0x1u)
179#define MCUXCLELS_STATUS_DRBGENTLVL_HIGH ((uint32_t) 0x2u)
181
182#ifdef MCUXCL_FEATURE_ELS_LOCKING
188#define MCUXCLELS_MASTER_UNLOCK_ANY ((uint32_t) 0x1Fu)
190#endif /* MCUXCL_FEATURE_ELS_LOCKING */
191
192
193
197
198/**********************************************
199 * TYPEDEFS
200 **********************************************/
201
208
214typedef union
215{
216 struct
217 {
218 uint32_t value;
219 } word;
220 struct
221 {
222 uint32_t revision :4;
223 uint32_t minor :8;
224 uint32_t major :4;
225#ifndef MCUXCL_FEATURE_ELS_GET_FW_VERSION
226 uint32_t level :4;
227 uint32_t :12;
228#else /* MCUXCL_FEATURE_ELS_GET_FW_VERSION */
229 uint32_t fw_revision :4;
230 uint32_t fw_minor :8;
231 uint32_t fw_major :4;
232#endif /* MCUXCL_FEATURE_ELS_GET_FW_VERSION */
233 } bits;
235
241typedef union
242{
243 struct
244 {
245 uint32_t value;
246 } word;
247 struct
248 {
249 uint32_t busy :1;
250 uint32_t irq :1;
251 uint32_t err :1;
252 uint32_t prngready :1;
253 uint32_t ecdsavfy :2;
254 uint32_t pprot :2;
255 uint32_t drbgentlvl :2;
256 uint32_t dtrng_busy: 1;
257#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
258 uint32_t gdet_pos :1;
259 uint32_t gdet_neg :1;
260#else
261 uint32_t :2;
262#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
263 uint32_t :3;
264#ifdef MCUXCL_FEATURE_ELS_LOCKING
265 uint32_t els_locked :1;
266#else
267 uint32_t :1;
268#endif /* MCUXCL_FEATURE_ELS_LOCKING */
269 uint32_t :15;
270 } bits;
272
279
285typedef uint32_t mcuxClEls_ResetOption_t;
286
292typedef union
293{
294 struct
295 {
296 uint32_t value;
297 } word;
298 struct
299 {
300 uint32_t elsint :1;
301#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
302 uint32_t gdetint :1;
303#else
304 uint32_t :1;
305#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
306 uint32_t :30;
307 } bits;
309
313typedef union
314{
315 struct
316 {
317 uint32_t value;
318 } word;
319 struct
320 {
321 uint32_t elsint :1;
322#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
323 uint32_t gdetint :1;
324#else
325 uint32_t :1;
326#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
327 uint32_t :30;
328 } bits;
330
334typedef union
335{
336 struct
337 {
338 uint32_t value;
339 } word;
340 struct
341 {
342 uint32_t elsint :1;
343#ifdef MCUXCL_FEATURE_ELS_GLITCHDETECTOR
344 uint32_t gdetint_neg :1;
345 uint32_t gdetint_pos :1;
346#else
347 uint32_t :2;
348#endif /* MCUXCL_FEATURE_ELS_GLITCHDETECTOR */
349 uint32_t :29;
350 } bits;
352
358typedef union
359{
360 struct
361 {
362 uint32_t value;
363 } word;
364 struct
365 {
366 uint32_t ciphersup :1;
367 uint32_t authciphersup :1;
368 uint32_t ecsignsup :1;
369 uint32_t ecvfysup :1;
370 uint32_t eckxchsup :1;
371 uint32_t keygensup :1;
372 uint32_t keyinsup :1;
373 uint32_t keyoutsup :1;
374 uint32_t kdeletesup :1;
375 uint32_t keyprovsup :1;
376 uint32_t ckdfsup :1;
377 uint32_t hkdfsup :1;
378 uint32_t tlsinitsup :1;
379 uint32_t hashsup :1;
380 uint32_t hmacsup :1;
381 uint32_t cmacsup :1;
382 uint32_t drbgreqsup :1;
383 uint32_t drbgtestsup :1;
384 uint32_t dtrgncfgloadsup :1;
385 uint32_t dtrngevalsup :1;
386 uint32_t gdetcfgloadsup :1;
387 uint32_t gdettrimsup :1;
388 uint32_t :10;
389 } bits;
391
392#define drbgreqsub drbgreqsup
393
394
398
399/**********************************************
400 * FUNCTIONS
401 **********************************************/
422 mcuxClEls_HwVersion_t * result
423 );
424
425#ifdef MCUXCL_FEATURE_ELS_HWCONFIG
437MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_GetHwConfig)
439 mcuxClEls_HwConfig_t * result
440 );
441#endif /* MCUXCL_FEATURE_ELS_HWCONFIG */
442
456 mcuxClEls_HwState_t * result
457 );
458
472 void
473 );
474
502 );
503
517 void
518);
519
534 );
535
550 );
551
566 );
567
582 );
583
603 mcuxClEls_ErrorHandling_t errorHandling
604 );
605
629 uint32_t counterLimit,
630 mcuxClEls_ErrorHandling_t errorHandling
631 );
632
644 void);
645
661 mcuxClEls_ErrorHandling_t errorHandling
662 );
663
681 mcuxClEls_ErrorHandling_t errorHandling,
682 uint32_t *errorLevel
683 );
684
700 uint32_t startDelay
701 );
702
718 uint32_t * startDelay
719 );
720
721#ifdef MCUXCL_FEATURE_ELS_LOCKING
745MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_GetLock)
747 uint32_t * pSessionId
748 );
749
769MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_ReleaseLock)
771 uint32_t sessionId
772 );
773
788MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_IsLocked)
790
807MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_SetMasterUnlock)
809 uint32_t masterId
810 );
811
812#endif /* MCUXCL_FEATURE_ELS_LOCKING */
813
814
815#ifdef MCUXCL_FEATURE_ELS_DMA_ADDRESS_READBACK
827MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_GetLastDmaAddress)
829 uint32_t* pLastAddress
830 );
831#endif /* MCUXCL_FEATURE_ELS_DMA_ADDRESS_READBACK */
832
833#ifdef MCUXCL_FEATURE_ELS_DMA_FINAL_ADDRESS_READBACK
851MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_CompareDmaFinalOutputAddress)
852MCUXCLELS_API MCUX_CSSL_FP_PROTECTED_TYPE(mcuxClEls_Status_t) mcuxClEls_CompareDmaFinalOutputAddress(
853 uint8_t *outputStartAddress,
854 size_t expectedLength
855 );
856#endif /* MCUXCL_FEATURE_ELS_DMA_FINAL_ADDRESS_READBACK */
857
858#ifdef __cplusplus
859} /* extern "C" */
860#endif
861
862#endif /* MCUXCLELS_COMMON_H_ */
863
Definition of function identifiers for the flow protection mechanism.
ELS type header.
Provides the API for the CSSL flow protection mechanism.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:66
uint32_t mcuxClEls_ErrorHandling_t
Type to handle ELS error clearing options.
Definition mcuxClEls_Common.h:278
uint32_t mcuxClEls_ResetOption_t
Type to handle ELS reset options.
Definition mcuxClEls_Common.h:285
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_ResetIntFlags(mcuxClEls_InterruptOptionRst_t options)
Clear the interrupt status register.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_SetRandomStartDelay(uint32_t startDelay)
Set the random start delay for AES based operations.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_SetIntEnableFlags(mcuxClEls_InterruptOptionEn_t options)
Set interrupt enable flags.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_LimitedWaitForOperation(uint32_t counterLimit, mcuxClEls_ErrorHandling_t errorHandling)
Await the completion of an ELS operation for a limited amount of time and optionally clear the error ...
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetIntEnableFlags(mcuxClEls_InterruptOptionEn_t *result)
Get interrupt enable flags.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Enable_Async(void)
Enables the ELS.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetErrorLevel(mcuxClEls_ErrorHandling_t errorHandling, uint32_t *errorLevel)
Get the last ELS error code and level and optionally clear the error status.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_SetIntFlags(mcuxClEls_InterruptOptionSet_t options)
Set the interrupt status register, for debug and testing purposes.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Reset_Async(mcuxClEls_ResetOption_t options)
Perform a synchronous reset of the ELS.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetHwVersion(mcuxClEls_HwVersion_t *result)
Determines the version of the underlying ELS hardware IP.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Disable(void)
Disable the ELS.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetHwState(mcuxClEls_HwState_t *result)
Determines the current state of the ELS.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetErrorCode(mcuxClEls_ErrorHandling_t errorHandling)
Get the last ELS error code and optionally clear the error status.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_WaitForOperation(mcuxClEls_ErrorHandling_t errorHandling)
Wait for an ELS operation and optionally clear the error status.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_ResetErrorFlags(void)
Resets all error flags that have been set by a previous operation.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetRandomStartDelay(uint32_t *startDelay)
Get the random start delay for AES based operations.
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition mcuxClEls_Types.h:232
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:145
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:101
Result type of mcuxClEls_GetHwVersion.
Definition mcuxClEls_Common.h:215
uint32_t major
Major version.
Definition mcuxClEls_Common.h:224
uint32_t revision
Revision number.
Definition mcuxClEls_Common.h:222
uint32_t level
Release level version.
Definition mcuxClEls_Common.h:226
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:218
uint32_t minor
Minor version.
Definition mcuxClEls_Common.h:223
Result type of mcuxClEls_GetHwState.
Definition mcuxClEls_Common.h:242
uint32_t dtrng_busy
Indicates the DTRNG is gathering entropy.
Definition mcuxClEls_Common.h:256
uint32_t ecdsavfy
ECDSA verify operation state (For possible values of this field, see MCUXCLELS_STATUS_ECDSAVFY_).
Definition mcuxClEls_Common.h:253
uint32_t busy
ELS is busy.
Definition mcuxClEls_Common.h:249
uint32_t err
ELS is in error state.
Definition mcuxClEls_Common.h:251
uint32_t drbgentlvl
Entropy quality of the current DRBG instance (For possible values of this field, see MCUXCLELS_STATUS...
Definition mcuxClEls_Common.h:255
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:245
uint32_t pprot
The privilege/security level of the most recently started ELS command (For possible values of this fi...
Definition mcuxClEls_Common.h:254
uint32_t irq
ELS interrupt activated.
Definition mcuxClEls_Common.h:250
uint32_t prngready
ELS PRNG is seeded and ready to use.
Definition mcuxClEls_Common.h:252
Command option type for mcuxClEls_SetIntEnableFlags and mcuxClEls_GetIntEnableFlags.
Definition mcuxClEls_Common.h:293
uint32_t elsint
Whether ELS interrupt should be used. (For possible values of this field, see mcuxClEls_InterruptOpti...
Definition mcuxClEls_Common.h:300
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:296
Type to control which ELS interrupts should be reset when calling mcuxClEls_ResetIntFlags.
Definition mcuxClEls_Common.h:314
uint32_t elsint
Whether ELS interrupt should be reset. (For possible values of this field, see mcuxClEls_InterruptOpt...
Definition mcuxClEls_Common.h:321
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:317
Type to control which ELS interrupts should be set when calling mcuxClEls_SetIntFlags.
Definition mcuxClEls_Common.h:335
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:338
uint32_t elsint
Whether ELS interrupt should be set. (For possible values of this field, see mcuxClEls_InterruptOptio...
Definition mcuxClEls_Common.h:342
Result type of mcuxClEls_GetHwConfig.
Definition mcuxClEls_Common.h:359
uint32_t ckdfsup
Indicates whether the ckdf command is supported.
Definition mcuxClEls_Common.h:376
uint32_t ecvfysup
Indicates whether the ecvfy command is supported.
Definition mcuxClEls_Common.h:369
uint32_t keyinsup
Indicates whether the keyin command is supported.
Definition mcuxClEls_Common.h:372
uint32_t drbgreqsup
Indicates whether the drbg_req command is supported.
Definition mcuxClEls_Common.h:382
uint32_t dtrgncfgloadsup
Indicates whether the dtrng_cfg_load command is is supported.
Definition mcuxClEls_Common.h:384
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Common.h:362
uint32_t hmacsup
Indicates whether the hmac command is supported.
Definition mcuxClEls_Common.h:380
uint32_t gdettrimsup
Indicates whether the gdet_trim command is supported.
Definition mcuxClEls_Common.h:387
uint32_t keyprovsup
Indicates whether the keyprov command is supported.
Definition mcuxClEls_Common.h:375
uint32_t keyoutsup
Indicates whether the keyout command is supported.
Definition mcuxClEls_Common.h:373
uint32_t dtrngevalsup
Indicates whether the dtrng_eval command is supported.
Definition mcuxClEls_Common.h:385
uint32_t gdetcfgloadsup
Indicates whether the gdet_cfg_load command is supported.
Definition mcuxClEls_Common.h:386
uint32_t tlsinitsup
Indicates whether the tls_init command is supported.
Definition mcuxClEls_Common.h:378
uint32_t ecsignsup
Indicates whether the ecsign command is supported.
Definition mcuxClEls_Common.h:368
uint32_t ciphersup
Indicates whether the cipher command is supported.
Definition mcuxClEls_Common.h:366
uint32_t hashsup
Indicates whether the hash command is supported.
Definition mcuxClEls_Common.h:379
uint32_t eckxchsup
Indicates whether the dhkey_xch command is supported.
Definition mcuxClEls_Common.h:370
uint32_t authciphersup
Indicates whether the auth_cipher command is supported.
Definition mcuxClEls_Common.h:367
uint32_t cmacsup
Indicates whether the cmac command is supported.
Definition mcuxClEls_Common.h:381
uint32_t keygensup
Indicates whether the keygen command is supported.
Definition mcuxClEls_Common.h:371
uint32_t drbgtestsup
Indicates whether the drbg_test command is supported.
Definition mcuxClEls_Common.h:383
uint32_t hkdfsup
Indicates whether the hkdf command is supported.
Definition mcuxClEls_Common.h:377
uint32_t kdeletesup
Indicates whether the kdelete command is supported.
Definition mcuxClEls_Common.h:374