mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
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>
This commit is contained in:
@ -207,7 +207,7 @@ int mbedtls_mpi_mod_read( mbedtls_mpi_mod_residue *r,
|
||||
/* 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 @@ int mbedtls_mpi_mod_write( const mbedtls_mpi_mod_residue *r,
|
||||
/* 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)
|
||||
|
Reference in New Issue
Block a user