mbedtls_ct_memcpy_if() function
Conditional memcpy. Functionally equivalent to: if (condition) { memcpy(dest, src1, len); } else { if (src2 != NULL) memcpy(dest, src2, len); } It will always read len bytes from src1. If src2 != NULL, it will always read len bytes from src2. If src2 == NULL, it will instead read len bytes from dest (as if src2 == dest).
Arguments
dest
Secret. Destination pointer.
src1
Secret. Pointer to copy from (if \p condition == MBEDTLS_CT_TRUE). This may be equal to \p dest, but may not overlap in other ways.
src2
Secret (contents only - may branch to determine if this parameter is NULL). Pointer to copy from (if \p condition == MBEDTLS_CT_FALSE and \p src2 is not NULL). May be NULL. This may be equal to \p dest, but may not overlap it in other ways. It may overlap with \p src1.
len
Number of bytes to copy.
mbedtls_ct_memcpy_if() is called by 4 functions and calls 1 function:
![]()
mbedtls_ct_memcpy_if()
mbedtls_ct_memcpy_if():
![]()
mbedtls_ct_memcpy_if()