From 07f853713d60aa448a66fe8963c5ce0c1494e7c9 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Mon, 31 Jul 2023 12:27:49 +0100 Subject: [PATCH] Clarify comments in mbedtls_ct_memcpy_if Signed-off-by: Dave Rodgman --- library/constant_time.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/constant_time.c b/library/constant_time.c index 8cdb53a1c..c60ec8455 100644 --- a/library/constant_time.c +++ b/library/constant_time.c @@ -185,8 +185,11 @@ void mbedtls_ct_memcpy_if(mbedtls_ct_condition_t condition, const uint32_t mask = (uint32_t) condition; const uint32_t not_mask = (uint32_t) ~mbedtls_ct_compiler_opaque(condition); - /* If src2 is NULL and condition == 0, then this function has no effect. - * In this case, copy from dest back into dest. */ + /* If src2 is NULL, setup src2 so that we read from the destination address. + * + * This means that if src2 == NULL && condition is false, the result will be a + * no-op because we read from dest and write the same data back into dest. + */ if (src2 == NULL) { src2 = dest; }