Example for the mcuxClRandom component.
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_ELS_Helper.h>
static uint32_t indexRandomData = 0u;
static const ALIGNED uint8_t randomData[] = {0x8au,0x76u,0x90u,0xd2u,0xd9u,0x55u,0x3cu,0x93u,
0x03u,0x52u,0x3au,0x3cu,0xbeu,0xe1u,0x39u,0xa4u,
0xefu,0xf1u,0xc4u,0xbbu,0xa3u,0xc7u,0x09u,0xf3u,
0xb7u,0x14u,0x07u,0xb2u,0xd8u,0x98u,0xa0u,0xaeu};
void *pCustomState,
uint32_t outLength
)
{
uint32_t *pIndexRandomData = (uint32_t *)pCustomState;
for (uint32_t i = 0u; i < outLength; i++)
{
{
}
*pIndexRandomData = (*pIndexRandomData + 1u) % sizeof(randomData);
}
}
MCUXCLEXAMPLE_FUNCTION(mcuxClRandom_PRNG_Patch_example)
{
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(session, 0u, 0u);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint8_t pPrngData[16u];
session,
pPrngBuffer,
sizeof(pPrngData)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
bool outputAsExpected = mcuxClCore_assertEqual((const uint8_t *) pPrngData, (const uint8_t*) randomData, sizeof(pPrngData));
if(outputAsExpected)
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
&indexRandomData
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
pPrngBuffer,
sizeof(pPrngData)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
outputAsExpected = mcuxClCore_assertEqual((const uint8_t *) pPrngData, (const uint8_t*) randomData, sizeof(pPrngData));
if(!outputAsExpected)
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
pPrngBuffer,
sizeof(pPrngData)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
outputAsExpected = mcuxClCore_assertEqual((const uint8_t *) pPrngData, (const uint8_t*) randomData, sizeof(pPrngData));
if(outputAsExpected)
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClExample_Session_Clean(session))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
return MCUXCLEXAMPLE_STATUS_OK;
}
static mcuxClEls_EccByte_t ecc_public_key_client[MCUXCLELS_ECC_PUBLICKEY_SIZE] ALIGNED
Destination buffer to receive the public key of the mcuxClEls_EccKeyGen_Async operation.
Definition mcuxClEls_Tls_Master_Key_Session_Keys_example.c:33
Provides the API for the CL buffer types.
mcuxClBuffer_Status_t mcuxClBuffer_export(mcuxCl_Buffer_t bufDst, uint32_t offset, const uint8_t *pSrc, uint32_t byteLength)
Perform a write to the buffer.
Definition of function identifiers for the flow protection mechanism.
Top level header of mcuxClRandom component.
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
#define MCUXCLBUFFER_INIT(name, info, ptr, size)
Initialize an input/output buffer (mcuxCl_Buffer_t).
Definition mcuxClBuffer.h:71
uint8_t * mcuxCl_Buffer_t
Input/output buffer type.
Definition mcuxClBuffer_Pointer.h:55
#define MCUXCLELS_RESET_DO_NOT_CANCEL
Set this option at mcuxClEls_ResetOption_t to abort the requested command if another ELS operation is...
Definition mcuxClEls_Common.h:119
mcuxClRandom_Status_t mcuxClRandom_ncInit(mcuxClSession_Handle_t pSession)
Non-cryptographic PRNG initialization function.
mcuxClRandom_Status_t mcuxClRandom_ncGenerate(mcuxClSession_Handle_t pSession, mcuxCl_Buffer_t pOut, uint32_t outLength)
Non-cryptographic PRNG data generation function.
mcuxClRandom_Status_t mcuxClRandom_ncPatch(mcuxClSession_Handle_t pSession, mcuxClRandom_CustomNcGenerateAlgorithm_t prngPatchFunction, void *pCustomPrngState)
Function to enable the PRNG patch mode.
mcuxClRandom_Status_t(* mcuxClRandom_CustomNcGenerateAlgorithm_t)(void *pCustomPrngState, mcuxCl_Buffer_t pOut, uint32_t outLength)
Interface definition for custom PRNG functions to be used by PRNG patch mode.
Definition mcuxClRandom_Types.h:99
uint32_t mcuxClRandom_Status_t
Type for status codes of mcuxClRandom component functions.
Definition mcuxClRandom_Types.h:48
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:113
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:581
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:735
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:616
#define MCUXCLRANDOM_STATUS_FAULT_ATTACK
Random function returned fault attack.
Definition mcuxClRandom_Constants.h:47
#define MCUXCLRANDOM_STATUS_OK
Random function returned successfully.
Definition mcuxClRandom_Constants.h:46
Structure for mcuxClSession Descriptor.
Definition mcuxClSession_Types.h:121