MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Rng.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
39
40#ifndef MCUXCLELS_RNG_H_
41#define MCUXCLELS_RNG_H_
42
43#include <mcuxClConfig.h> // Exported features flags header
44#include <mcuxClEls_Common.h> // Common functionality
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
56
57
58/**********************************************
59 * CONSTANTS
60 **********************************************/
67#define MCUXCLELS_RNG_DTRNG_CONFIG_SIZE ((uint8_t) 84)
68#define MCUXCLELS_RNG_DTRNG_EVAL_CONFIG_SIZE ((uint8_t) 52)
69#define MCUXCLELS_RNG_DTRNG_EVAL_RESULT_SIZE ((uint8_t) 188)
70
71#define MCUXCLELS_RNG_DRBG_TEST_EXTRACT_OUTPUT_MIN_SIZE 4U
72#define MCUXCLELS_RNG_DRBG_TEST_EXTRACT_OUTPUT_MAX_SIZE ((uint32_t) 1U << 16U)
73
74#define MCUXCLELS_RNG_DRBG_TEST_MODE_INSTANTIATE ((uint32_t) 0U)
75#define MCUXCLELS_RNG_DRBG_TEST_MODE_EXTRACT ((uint32_t) 1U)
76#define MCUXCLELS_RNG_DRBG_TEST_MODE_AES_ECB ((uint32_t) 3U)
77#define MCUXCLELS_RNG_DRBG_TEST_MODE_AES_CTR ((uint32_t) 2U)
78
79#ifdef MCUXCL_FEATURE_ELS_RND_RAW
80#define MCUXCLELS_RNG_RND_REQ_RND_RAW ((uint32_t) 1U << 1)
81#define MCUXCLELS_RNG_RAW_ENTROPY_SIZE ((uint32_t) 32U)
82#endif /* MCUXCL_FEATURE_ELS_RND_RAW */
83#ifdef MCUXCL_FEATURE_ELS_PRND_INIT
84#define MCUXCLELS_RNG_RND_REQ_PRND_INIT ((uint32_t) 1U << 0)
85#endif /* MCUXCL_FEATURE_ELS_PRND_INIT */
89
90
91/**********************************************
92 * FUNCTIONS
93 **********************************************/
100
140 uint8_t * pOutput,
141 size_t outputLength
142 );
143
144#ifdef MCUXCL_FEATURE_ELS_RND_RAW
162MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_Rng_DrbgRequestRaw_Async)
163MCUXCLELS_API MCUX_CSSL_FP_PROTECTED_TYPE(mcuxClEls_Status_t) mcuxClEls_Rng_DrbgRequestRaw_Async(
164 uint8_t * pOutput
165 );
166#endif /* MCUXCL_FEATURE_ELS_RND_RAW */
167
188 uint8_t const * pEntropy
189 );
190
223 uint8_t * pOutput,
224 size_t outputLength
225 );
226
249 uint8_t const * pDataKey,
250 uint8_t * pOutput
251 );
252
277 uint8_t const * pData,
278 size_t dataLength,
279 uint8_t const * pIvKey,
280 uint8_t * pOutput
281 );
282
314 uint8_t const * pInput
315 );
316
317
349 uint8_t const * pInput,
350 uint8_t * pOutput
351 );
352
353#ifdef MCUXCL_FEATURE_ELS_PRND_INIT
369MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_Prng_Init_Async)
370MCUXCLELS_API MCUX_CSSL_FP_PROTECTED_TYPE(mcuxClEls_Status_t) mcuxClEls_Prng_Init_Async(void);
371#endif /* MCUXCL_FEATURE_ELS_PRND_INIT */
372
392 uint32_t * pWord
393 );
394
415 uint8_t * pOutput,
416 size_t outputLength
417 );
418
419#ifdef MCUXCL_FEATURE_ELS_ITERATIVE_SEEDING
438MCUX_CSSL_FP_FUNCTION_DECL(mcuxClEls_Dtrng_IterativeReseeding_CheckAndReseed)
439MCUXCLELS_API MCUX_CSSL_FP_PROTECTED_TYPE(mcuxClEls_Status_t) mcuxClEls_Dtrng_IterativeReseeding_CheckAndReseed(const uint8_t *pDtrngConfig);
440#endif /* MCUXCL_FEATURE_ELS_ITERATIVE_SEEDING */
441 /* mcuxClEls_Rng_Functions */
445
446 /* mcuxClEls_Rng */
450
451#ifdef __cplusplus
452} /* extern "C" */
453#endif
454
455#endif /* MCUXCLELS_RNG_H_ */
ELS header for common functionality.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:66
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Prng_GetRandomWord(uint32_t *pWord)
Returns one random word from the ELS PRNG.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_DrbgTestInstantiate_Async(uint8_t const *pEntropy)
Instantiates the DRBG in test mode.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Prng_GetRandom(uint8_t *pOutput, size_t outputLength)
Writes random data from the ELS PRNG to the given buffer.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_Dtrng_ConfigLoad_Async(uint8_t const *pInput)
Loads a configuration of the ELS DTRNG.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_DrbgTestExtract_Async(uint8_t *pOutput, size_t outputLength)
Performs a DRBG extraction.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_DrbgTestAesEcb_Async(uint8_t const *pDataKey, uint8_t *pOutput)
Encrypts data using the AES-ECB engine of the DRBG.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_DrbgRequest_Async(uint8_t *pOutput, size_t outputLength)
Writes random data from the ELS DRBG to the given buffer.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_Dtrng_ConfigEvaluate_Async(uint8_t const *pInput, uint8_t *pOutput)
Performs characterization of the ELS DTRNG.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Rng_DrbgTestAesCtr_Async(uint8_t const *pData, size_t dataLength, uint8_t const *pIvKey, uint8_t *pOutput)
Encrypts data using the AES-CTR engine of the DRBG.
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