Remove mbedtls_ct_int_if
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/constant_time_impl.h b/library/constant_time_impl.h
index afec894..513f146 100644
--- a/library/constant_time_impl.h
+++ b/library/constant_time_impl.h
@@ -331,42 +331,6 @@
return (unsigned char) (~(low_mask | high_mask)) & to;
}
-static inline int mbedtls_ct_int_if(mbedtls_ct_condition_t condition, int if1, int if0)
-{
- /*
- * Use memcpy to avoid unsigned-to-signed conversion UB.
- *
- * Although this looks inefficient, in practice (for gcc and clang),
- * the sizeof test is eliminated at compile-time, and identical code is generated
- * as for mbedtls_ct_uint_if (for -Os and -O1 or higher).
- */
- int result;
- if (sizeof(int) <= sizeof(unsigned int)) {
- unsigned int uif1 = 0, uif0 = 0;
- memcpy(&uif1, &if1, sizeof(if1));
- memcpy(&uif0, &if0, sizeof(if0));
- unsigned int uresult = mbedtls_ct_uint_if(condition, uif1, uif0);
- memcpy(&result, &uresult, sizeof(result));
- } else {
- mbedtls_ct_memcpy_if(condition, (unsigned char *) &result, (const unsigned char *) &if1,
- (const unsigned char *) &if0, sizeof(result));
- }
- return result;
-}
-
-static inline int mbedtls_ct_int_if_else_0(mbedtls_ct_condition_t condition, int if1)
-{
- if (sizeof(int) <= sizeof(unsigned int)) {
- unsigned int uif1 = 0;
- memcpy(&uif1, &if1, sizeof(if1));
- unsigned int uresult = mbedtls_ct_uint_if_else_0(condition, uif1);
- int result;
- memcpy(&result, &uresult, sizeof(result));
- return result;
- } else {
- return mbedtls_ct_int_if(condition, if1, 0);
- }
-}
/* ============================================================================
* Everything below here is trivial wrapper functions
diff --git a/library/constant_time_internal.h b/library/constant_time_internal.h
index 604268e..d3d8945 100644
--- a/library/constant_time_internal.h
+++ b/library/constant_time_internal.h
@@ -411,34 +411,6 @@
unsigned char c,
unsigned char t);
-/** Choose between two int values.
- *
- * Functionally equivalent to:
- *
- * condition ? if1 : if0.
- *
- * \param condition Condition to test.
- * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
- * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
- *
- * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
- */
-static inline int mbedtls_ct_int_if(mbedtls_ct_condition_t condition, int if1, int if0);
-
-/** Choose between an int value and 0.
- *
- * Functionally equivalent to:
- *
- * condition ? if1 : 0.
- *
- * Functionally equivalent to mbedtls_ct_int_if(condition, if1, 0).
- *
- * \param condition Condition to test.
- * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
- *
- * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
- */
-static inline int mbedtls_ct_int_if_else_0(mbedtls_ct_condition_t condition, int if1);
/* ============================================================================
* Block memory operations