Change mpi_core_check_sub to be constant time
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
diff --git a/library/bignum_core.c b/library/bignum_core.c
index 1a3e0b9..ee3d704 100644
--- a/library/bignum_core.c
+++ b/library/bignum_core.c
@@ -449,9 +449,10 @@
mbedtls_mpi_uint c = 0;
for (size_t i = 0; i < limbs; i++) {
- mbedtls_mpi_uint z = (A[i] < c);
+ mbedtls_mpi_uint z = mbedtls_ct_mpi_uint_if(mbedtls_ct_uint_lt(A[i], c),
+ 1, 0);
mbedtls_mpi_uint t = A[i] - c;
- c = (t < B[i]) + z;
+ c = mbedtls_ct_mpi_uint_if(mbedtls_ct_uint_lt(t, B[i]), 1, 0) + z;
X[i] = t - B[i];
}