#include <mcuxClToolchain.h>
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_RNG_Helper.h>
static const ALIGNED uint8_t data1[7] = {
0x65u, 0x78u, 0x61u, 0x6du, 0x70u, 0x6cu, 0x65u
};
static const ALIGNED uint8_t data2[4] = {
0x68u, 0x61u, 0x73u, 0x68u
};
static const ALIGNED uint8_t data3[9] = {
0x73u, 0x74u, 0x72u, 0x65u, 0x61u, 0x6du, 0x69u, 0x6eu, 0x67u
};
static const ALIGNED uint8_t hashExpected[32] = {
0xb3u, 0xdcu, 0xe3u, 0x33u, 0x68u, 0x24u, 0x6du, 0x98u,
0x04u, 0x6bu, 0xd4u, 0x52u, 0x6cu, 0x69u, 0xc1u, 0xd0u,
0x37u, 0x01u, 0x57u, 0x60u, 0x95u, 0xbau, 0x74u, 0x74u,
0xc6u, 0xcbu, 0xf2u, 0x5eu, 0x3fu, 0xffu, 0xe8u, 0xc4u
};
MCUXCLEXAMPLE_FUNCTION(mcuxClHashModes_sha256_streaming_example)
{
mcuxClSession_Descriptor_t sessionDesc;
MCUXCLEXAMPLE_INITIALIZE_PRNG(session);
uint32_t context[MCUXCLHASH_CONTEXT_SIZE_SHA2_256_IN_WORDS];
session,
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by mcuxClHash_init")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
data1Buf,
sizeof(data1)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by mcuxClHash_init")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
data2Buf,
sizeof(data2)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by mcuxClHash_init")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
data3Buf,
sizeof(data3)
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t hashOutputSize = 0u;
session,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by mcuxClHash_init")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
hashBuf,
&hashOutputSize
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(sizeof(hash) != hashOutputSize)
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint8_t hashDifferent = 0u;
for(size_t i = 0u; i < sizeof(hash); i++)
{
if(hashExpected[i] != hash[i])
{
hashDifferent |= 1u;
}
}
if(0u != hashDifferent)
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClExample_Session_Clean(session))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
return MCUXCLEXAMPLE_STATUS_OK;
}
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the mcuxClHash component.
Top-level include file for the mcuxClHashModes component.
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
#define MCUXCLHASH_MAX_CPU_WA_BUFFER_SIZE
Defines the max workarea size required for this component.
Definition mcuxClHash_MemoryConsumption.h:27
#define MCUXCLBUFFER_INIT_RW(name, info, ptr, size)
Initialize an input/output buffer (mcuxCl_Buffer_t) with plain CPU handling.
Definition mcuxClBuffer.h:101
#define MCUXCLBUFFER_INIT_RO(name, info, ptr, size)
Initialize an input buffer (mcuxCl_InputBuffer_t) with plain CPU handling.
Definition mcuxClBuffer.h:84
#define MCUXCLHASH_STATUS_OK
Hash operation successful.
Definition mcuxClHash_Constants.h:35
mcuxClHash_Status_t mcuxClHash_process(mcuxClSession_Handle_t session, mcuxClHash_Context_t pContext, mcuxCl_InputBuffer_t pIn, uint32_t inSize)
Multi-part Hash processing function.
mcuxClHash_Status_t mcuxClHash_init(mcuxClSession_Handle_t session, mcuxClHash_Context_t pContext, mcuxClHash_Algo_t algorithm)
Multi-part Hash initialization function.
mcuxClHash_Status_t mcuxClHash_finish(mcuxClSession_Handle_t session, mcuxClHash_Context_t pContext, mcuxCl_Buffer_t pOut, uint32_t *const pOutSize)
Multi-part Hash computation finalization function.
mcuxClHash_ContextDescriptor_t * mcuxClHash_Context_t
Hash Context type.
Definition mcuxClHash_Types.h:72
static mcuxClHash_Algo_t mcuxClHash_Algorithm_Sha256
Sha-256 algorithm descriptor Sha-256 hash calculation using the Hash functionality SGI.
Definition mcuxClHashModes_Algorithms.h:96
#define MCUXCLHASH_OUTPUT_SIZE_SHA_256
SHA-256 output size: 256 bit (32 bytes).
Definition mcuxClHashModes_Constants.h:38
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:98
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:623
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:777
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:658