2. CMOX_UTILS_COMPARE

2.1. Comparison utilities

group CMOX_UTILS_COMPARE

Public comparison function and related utilities.

Functions

cmox_utils_retval_t cmox_utils_compare ( const uint8_t * P_pBuf1 , uint32_t P_Len1 , const uint8_t * P_pBuf2 , uint32_t P_Len2 , uint32_t * P_pFaultCheck )

Compares two buffers in a fault-secure way.

Note

P_pFaultCheck value, if the parameter is provided, MUST be checked to be equal to the retval, and both MUST be equal to the successful value. P_pFaultCheck MUST be checked only if the main result is successful, and has no relevance if the main result is not successful. Every comparison (both for the return value and for P_pFaultCheck) must be done against the success value, and not comparing the value with the failure value. Indeed, in presence of faults, especially P_pFaultCheck, could be a dirty value.

Warning

If it’s necessary to be protected against fault attacks, it’s very important that P_Len1 and P_Len2 are different memory locations (or registers), otherwise a single fault could be fatal.

Parameters :
  • P_pBuf1[in] First buffer

  • P_Len1[in] Length of the first input buffer

  • P_pBuf2[in] Second buffer

  • P_Len2[in] Length of the second input buffer

  • P_pFaultCheck[out] Optional value to check, together with the retval, to verify if some fault happened

Return values :
  • CMOX_UTILS_AUTH_SUCCESS – The two buffers are equal

  • CMOX_UTILS_AUTH_FAIL – The two buffers are different