From e655479528b8dff247d3c67e310c8f9067ad12e4 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 20 Dec 2022 19:24:27 +0100 Subject: [PATCH] Generalize representation handling in mbedtls_mpi_mod_read Call mbedtls_mpi_mod_raw_canonical_to_modulus_rep instead of assuming that anything that isn't MBEDTLS_MPI_MOD_REP_MONTGOMERY is canonical. mbedtls_mpi_mod_write should get the same treatment, but I'm holding off until https://github.com/Mbed-TLS/mbedtls/issues/6679 is done. Signed-off-by: Gilles Peskine --- library/bignum_mod.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/bignum_mod.c b/library/bignum_mod.c index 3eef4e7002..4ac6277b3b 100644 --- a/library/bignum_mod.c +++ b/library/bignum_mod.c @@ -248,8 +248,7 @@ int mbedtls_mpi_mod_read( mbedtls_mpi_mod_residue *r, r->limbs = m->limbs; - if( m->int_rep == MBEDTLS_MPI_MOD_REP_MONTGOMERY ) - ret = mbedtls_mpi_mod_raw_to_mont_rep( r->p, m ); + ret = mbedtls_mpi_mod_raw_canonical_to_modulus_rep( r->p, m ); cleanup: return ( ret );