Example for the mcuxClMath component.
#include <mcuxClToolchain.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClExample_RNG_Helper.h>
#include <mcuxClExample_ELS_Helper.h>
#define LEN_X 16u
#define LEN_Y 8u
#define LEN_N 16u
#define LEN_R LEN_N
static const ALIGNED uint8_t operandX[LEN_X] =
{
0x01u, 0x23u, 0x45u, 0x67u, 0x89u, 0xabu, 0xcdu, 0xefu,
0x01u, 0x23u, 0x45u, 0x67u, 0x89u, 0xabu, 0xcdu, 0xefu
};
static const ALIGNED uint8_t operandY[LEN_Y] =
{
0x23u, 0x45u, 0x67u, 0x89u, 0xabu, 0xcdu, 0xefu, 0x10u
};
static const ALIGNED uint8_t operandN[LEN_N] =
{
0x23u, 0x45u, 0x67u, 0x89u, 0xabu, 0xcdu, 0xefu, 0x01u,
0x23u, 0x45u, 0x67u, 0x89u, 0xabu, 0xcdu, 0xefu, 0x01u
};
static const ALIGNED uint8_t refR[LEN_R] =
{
0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x01u,
0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x11u, 0x01u
};
#define MAX_CPUWA_SIZE (MCUXCLRANDOMMODES_NCINIT_WACPU_SIZE + \
MCUXCLRANDOMMODES_NCGENERATE_WACPU_SIZE + \
MCUXCLMATH_MODMULT_CPU_WA_BUFFER_SIZE)
#define MAX_PKCWA_SIZE MCUXCLMATH_MODMULT_PKC_WA_BUFFER_SIZE(LEN_X, LEN_N)
MCUXCLEXAMPLE_FUNCTION(mcuxClMath_SecModMultOdd_example)
{
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
mcuxClSession_Descriptor_t sessionDesc;
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(pSession, MAX_CPUWA_SIZE, MAX_PKCWA_SIZE);
MCUXCLEXAMPLE_INITIALIZE_PRNG(pSession);
uint8_t resultData[LEN_R];
buffX,
LEN_X,
buffY,
LEN_Y,
buffN,
LEN_N,
buffR)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if (!mcuxClCore_assertEqual(resultData, refR, sizeof(refR)))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if (!mcuxClExample_Session_Clean(pSession))
{
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:53
Top-level include file for the mcuxClBuffer component.
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the ELS driver.
Top-level include file for the mcuxClMath component.
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:88
#define MCUXCLBUFFER_INIT_RO(name, info, ptr, size)
Initialize an input buffer (mcuxCl_InputBuffer_t) with plain CPU handling.
Definition mcuxClBuffer.h:105
#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:139
mcuxClMath_Status_t mcuxClMath_SecModMultOdd(mcuxClSession_Handle_t pSession, mcuxCl_InputBuffer_t pX, uint32_t lenX, mcuxCl_InputBuffer_t pY, uint32_t lenY, mcuxCl_InputBuffer_t pN, uint32_t lenN, mcuxCl_Buffer_t pR)
Calculates secure modular multiplication in normal representation: R = X * Y mod N.
#define MCUXCLMATH_STATUS_OK
Math operation successful.
Definition mcuxClMath_Types.h:73
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:133
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:601
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:755
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:636