mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-01 17:40:53 -04:00
Exp mod: handle negative zero
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
aec1a868fe
commit
86258f51b5
@ -1689,7 +1689,9 @@ int mbedtls_mpi_exp_mod(mbedtls_mpi *X, const mbedtls_mpi *A,
|
||||
* 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));
|
||||
}
|
||||
|
||||
|
@ -1362,6 +1362,9 @@ mpi_exp_mod:"04":"00":"09":"1":0
|
||||
Test mbedtls_mpi_exp_mod: 10 ^ 0 (1 limb) mod 9
|
||||
mpi_exp_mod:"0a":"00":"09":"1":0
|
||||
|
||||
Test mbedtls_mpi_exp_mod: -3 ^ 3 mod 27
|
||||
mpi_exp_mod:"-3":"3":"1b":"1b":0
|
||||
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE exponent
|
||||
mpi_exp_mod_size:2:MBEDTLS_MPI_MAX_SIZE:10:"":0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user