mbedtls_mpi_mod_read/write: restrict pre-conditions
Require equality for the number of limbs in the modulus and the residue.
This makes these functions consistent with residue_setup().
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum_mod.c b/library/bignum_mod.c
index f07307c..7f7c715 100644
--- a/library/bignum_mod.c
+++ b/library/bignum_mod.c
@@ -207,7 +207,7 @@
/* Do our best to check if r and m have been set up */
if ( r->limbs == 0 || m->limbs == 0 )
goto cleanup;
- if ( r->limbs > m->limbs )
+ if ( r->limbs != m->limbs )
goto cleanup;
ret = mbedtls_mpi_mod_raw_read( r->p, m, buf, buflen, ext_rep );
@@ -235,7 +235,7 @@
/* Do our best to check if r and m have been set up */
if ( r->limbs == 0 || m->limbs == 0 )
goto cleanup;
- if ( r->limbs > m->limbs )
+ if ( r->limbs != m->limbs )
goto cleanup;
if ( m->int_rep == MBEDTLS_MPI_MOD_REP_MONTGOMERY)