commit | 86258f51b5bcbe4e2f8cbad6ef3c2e162f0d619b | [log] [tgz] |
---|---|---|
author | Janos Follath <janos.follath@arm.com> | Wed Feb 21 11:25:41 2024 +0000 |
committer | Janos Follath <janos.follath@arm.com> | Wed Feb 21 11:25:41 2024 +0000 |
tree | c98b095454500b5e5f323709cd4ed03f53e96963 | |
parent | aec1a868fe783a85cd057b78163bd0b1e143f0c6 [diff] |
Exp mod: handle negative zero Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum.c b/library/bignum.c index 7681982..08b8b34 100644 --- a/library/bignum.c +++ b/library/bignum.c
@@ -1689,7 +1689,9 @@ * Correct for negative A. */ if (A->s == -1 && (E->p[0] & 1) != 0) { - X->s = -1; + mbedtls_ct_condition_t is_x_non_zero = mbedtls_mpi_core_check_zero_ct(X->p, X->n); + X->s = mbedtls_ct_uint_if(is_x_non_zero, -1, 1); + MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(X, N, X)); }