MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxCsslMemory_Compare Function Definitions

mcuxCsslMemory_Compare Function Definitions More...

Functions

mcuxCsslMemory_CompareResult_t mcuxCsslMemory_Compare (mcuxCsslParamIntegrity_Checksum_t chk, void const *lhs, void const *rhs, size_t cnt)
 Compares the two memory regions lhs and rhs. More...
 

Detailed Description

mcuxCsslMemory_Compare Function Definitions

Function Documentation

◆ mcuxCsslMemory_Compare()

mcuxCsslMemory_CompareResult_t mcuxCsslMemory_Compare ( mcuxCsslParamIntegrity_Checksum_t  chk,
void const *  lhs,
void const *  rhs,
size_t  cnt 
)

Compares the two memory regions lhs and rhs.

The implementation is secure in the following aspects:

  • Constant execution time: The execution sequence of the code is always identical for equal cnt parameters, i.e. no branches are performed based on the data in lhs or rhs.
  • Parameter integrity protection: An incorrect parameter checksum makes the function return immediately.
  • Code flow protection: The function call is protected. Additionally, the result depends on all steps of the calculation.
Parameters
chkThe parameter checksum, generated with mcuxCsslParamIntegrity_Protect.
lhsThe left-hand side data to compare. Must not be NULL.
rhsThe right-hand side data to compare. Must not be NULL.
cntThe number of bytes to compare. Must be different from zero.
Returns
A status code encapsulated in a flow-protection type.
Return values
MCUXCSSLMEMORY_COMPARE_EQUALIf the contents of lhs and rhs are equal.
MCUXCSSLMEMORY_COMPARE_NOT_EQUALIf the contents of lhs and rhs are not equal.
MCUXCSSLMEMORY_COMPARE_INVALID_PARAMETERIf one of the parameters was invalid (i.e. lhs or rhs was NULL or cnt was zero).
MCUXCSSLMEMORY_COMPARE_FAULTIf a fault was detected.