Example constant-time memory compare (CSSL component mcuxCsslMemory).
#include <mcuxClToolchain.h>
#include <stdbool.h>
#include <stdint.h>
#include <mcuxCsslMemory_Examples.h>
#define EXIT_CODE_ERROR false
#define EXIT_CODE_OK true
MCUXCSSL_MEMORY_EX_FUNCTION(mcuxCsslMemory_Compare_example)
{
ALIGNED uint8_t arr1[] = {0xe4u, 0xf9u, 0x26u, 0x4cu, 0x65u, 0xe2u, 0x13u, 0xa3u,
0x9au, 0x40u, 0xd7u, 0x87u, 0xccu, 0x0bu, 0x31u, 0x18u,
0xacu, 0x55u, 0xb5u, 0x7du, 0x06u, 0x7fu, 0xceu, 0xe4u,
0xb2u, 0x7eu, 0xd5u, 0xaau, 0x90u, 0x9au, 0x42u, 0x56u,
0x76u};
ALIGNED uint8_t arr2[sizeof(arr1)] = {0xe4u, 0xf9u, 0x26u, 0x4cu, 0x65u, 0xe2u, 0x13u, 0xa3u,
0x9au, 0x40u, 0xd7u, 0x87u, 0xccu, 0x0bu, 0x31u, 0x18u,
0xacu, 0x55u, 0xb5u, 0x7du, 0x06u, 0x7fu, 0xceu, 0xe4u,
0xb2u, 0x7eu, 0xd5u, 0xaau, 0x90u, 0x9au, 0x42u, 0x56u,
0x71u};
ALIGNED uint8_t arr3[sizeof(arr1)] = {0xe4u, 0xf9u, 0x26u, 0x4cu, 0x65u, 0xe2u, 0x13u, 0xa3u,
0x9au, 0x40u, 0xd7u, 0x87u, 0xccu, 0x0bu, 0x31u, 0x18u,
0xacu, 0x55u, 0xb5u, 0x7du, 0x06u, 0x7fu, 0xceu, 0xe4u,
0xb2u, 0x7eu, 0xd5u, 0xaau, 0x90u, 0x9au, 0x42u, 0x56u,
0x76u};
MCUX_CSSL_PI_PROTECT(arr1, arr1, 0U),
arr1,
arr1,
0U));
{
return EXIT_CODE_ERROR;
}
MCUX_CSSL_PI_PROTECT(arr1, arr1, sizeof(arr1)),
arr1,
arr1,
sizeof(arr1)));
{
return EXIT_CODE_ERROR;
}
MCUX_CSSL_PI_PROTECT(arr1, arr2, sizeof(arr1)),
arr1,
arr2,
sizeof(arr1)));
{
return EXIT_CODE_ERROR;
}
MCUX_CSSL_PI_PROTECT(arr1, arr3, sizeof(arr1)),
arr1,
arr3,
sizeof(arr1)));
{
return EXIT_CODE_ERROR;
}
return EXIT_CODE_OK;
}
Provides the API for the CSSL flow protection mechanism.
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the CSSL memory functions.
Top-level include file for the parameter integrity protection mechanism.
#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
mcuxCsslMemory_Status_t mcuxCsslMemory_Compare(mcuxCsslParamIntegrity_Checksum_t chk, void const *pLhs, void const *pRhs, uint32_t length)
Compares the two memory regions lhs and rhs.
#define MCUXCSSLMEMORY_STATUS_NOT_EQUAL
The two contents of the Memory Compare are not equal.
Definition mcuxCsslMemory_Constants.h:51
#define MCUXCSSLMEMORY_STATUS_ZERO_LENGTH
The length passed to Memory Compare is zero.
Definition mcuxCsslMemory_Constants.h:50
#define MCUXCSSLMEMORY_STATUS_EQUAL
The two contents of the Memory Compare are equal.
Definition mcuxCsslMemory_Constants.h:49