1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Add mod_mul function

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei
2022-12-13 10:51:37 +01:00
parent 3e0418fe50
commit 9db81e9cca
2 changed files with 56 additions and 0 deletions

View File

@ -176,6 +176,28 @@ exit:
/* BEGIN MERGE SLOT 2 */
int mbedtls_mpi_mod_mul( mbedtls_mpi_mod_residue *X,
const mbedtls_mpi_mod_residue *A,
const mbedtls_mpi_mod_residue *B,
const mbedtls_mpi_mod_modulus *N )
{
if( N->limbs == 0 )
return MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
if( X->limbs != N->limbs || A->limbs != N->limbs || B->limbs != N->limbs )
return MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
mbedtls_mpi_uint *T = mbedtls_calloc( N->limbs * 2 + 1, ciL );
if( !T )
return MBEDTLS_ERR_MPI_ALLOC_FAILED;
mbedtls_mpi_mod_raw_mul( X->p, A->p, B->p, N, T );
mbedtls_free( T );
return( 0 );
}
/* END MERGE SLOT 2 */
/* BEGIN MERGE SLOT 3 */