mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-29 16:32:32 -04:00
mbedtls_mpi_core_exp_mod() ouuput may alias input A
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
parent
90af1a10ab
commit
a7f0d7b029
@ -517,6 +517,9 @@ size_t mbedtls_mpi_core_exp_mod_working_limbs( size_t AN_limbs, size_t E_limbs )
|
||||
* \brief Perform a modular exponentiation with secret exponent:
|
||||
* X = A^E mod N, where \p A is already in Montgomery form.
|
||||
*
|
||||
* \p X may be aliased to \p A, but not to \p RR or \p E, even if \p E_limbs ==
|
||||
* \p AN_limbs.
|
||||
*
|
||||
* \param[out] X The destination MPI, as a little endian array of length
|
||||
* \p AN_limbs.
|
||||
* \param[in] A The base MPI, as a little endian array of length \p AN_limbs.
|
||||
|
@ -1097,6 +1097,12 @@ void mpi_core_exp_mod( char * input_N, char * input_A,
|
||||
|
||||
TEST_EQUAL( 0, memcmp( X, Y, N_limbs * sizeof( mbedtls_mpi_uint ) ) );
|
||||
|
||||
/* Check when output aliased to input */
|
||||
|
||||
mbedtls_mpi_core_exp_mod( A, A, N, N_limbs, E, E_limbs, R2, T );
|
||||
|
||||
TEST_EQUAL( 0, memcmp( X, A, N_limbs * sizeof( mbedtls_mpi_uint ) ) );
|
||||
|
||||
exit:
|
||||
mbedtls_free( T );
|
||||
mbedtls_free( A );
|
||||
|
Loading…
x
Reference in New Issue
Block a user