mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-06-25 22:56:35 +08:00
Update mbedtls_mpi_core_uint_le_mpi to new CT interface
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
ee54faf1cd
commit
fd7fab4073
@ -148,24 +148,22 @@ void mbedtls_mpi_core_bigendian_to_host(mbedtls_mpi_uint *A,
|
||||
|
||||
/* Whether min <= A, in constant time.
|
||||
* A_limbs must be at least 1. */
|
||||
unsigned mbedtls_mpi_core_uint_le_mpi(mbedtls_mpi_uint min,
|
||||
mbedtls_ct_condition_t mbedtls_mpi_core_uint_le_mpi(mbedtls_mpi_uint min,
|
||||
const mbedtls_mpi_uint *A,
|
||||
size_t A_limbs)
|
||||
{
|
||||
/* min <= least significant limb? */
|
||||
unsigned min_le_lsl = 1 ^ mbedtls_ct_mpi_uint_lt(A[0], min);
|
||||
mbedtls_ct_condition_t min_le_lsl = mbedtls_ct_bool_ge(A[0], min);
|
||||
|
||||
/* limbs other than the least significant one are all zero? */
|
||||
mbedtls_mpi_uint msll_mask = 0;
|
||||
mbedtls_ct_condition_t msll_mask = MBEDTLS_CT_FALSE;
|
||||
for (size_t i = 1; i < A_limbs; i++) {
|
||||
msll_mask |= A[i];
|
||||
msll_mask = mbedtls_ct_bool_or(msll_mask, mbedtls_ct_bool(A[i]));
|
||||
}
|
||||
/* The most significant limbs of A are not all zero iff msll_mask != 0. */
|
||||
unsigned msll_nonzero = mbedtls_ct_mpi_uint_mask(msll_mask) & 1;
|
||||
|
||||
/* min <= A iff the lowest limb of A is >= min or the other limbs
|
||||
* are not all zero. */
|
||||
return min_le_lsl | msll_nonzero;
|
||||
return mbedtls_ct_bool_or(msll_mask, min_le_lsl);
|
||||
}
|
||||
|
||||
unsigned mbedtls_mpi_core_lt_ct(const mbedtls_mpi_uint *A,
|
||||
|
@ -144,9 +144,9 @@ void mbedtls_mpi_core_bigendian_to_host(mbedtls_mpi_uint *A,
|
||||
* \param A_limbs The number of limbs of \p A.
|
||||
* This must be at least 1.
|
||||
*
|
||||
* \return 1 if \p min is less than or equal to \p A, otherwise 0.
|
||||
* \return MBEDTLS_CT_TRUE if \p min is less than or equal to \p A, otherwise MBEDTLS_CT_FALSE.
|
||||
*/
|
||||
unsigned mbedtls_mpi_core_uint_le_mpi(mbedtls_mpi_uint min,
|
||||
mbedtls_ct_condition_t mbedtls_mpi_core_uint_le_mpi(mbedtls_mpi_uint min,
|
||||
const mbedtls_mpi_uint *A,
|
||||
size_t A_limbs);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user