Extract MPI_CORE(mul) from the prototype

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Hanno Becker 2022-08-24 16:17:52 +01:00 committed by Gabor Mezei
parent 05c5a91514
commit 4ae890bbd0
No known key found for this signature in database
GPG key ID: F072ACA227ACD71D
2 changed files with 28 additions and 0 deletions

View file

@ -448,6 +448,15 @@ mbedtls_mpi_uint mbedtls_mpi_core_mla(mbedtls_mpi_uint *d, size_t d_len,
return c;
}
void MPI_CORE(mul)( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A, size_t a,
const mbedtls_mpi_uint *B, size_t b )
{
memset( X, 0, ( a + b ) * ciL );
for( size_t i=0; i < b; i++ )
(void) mbedtls_mpi_core_mla( X + i, a + 1, A, a, B[i] );
}
/*
* Fast Montgomery initialization (thanks to Tom St Denis).
*/

View file

@ -398,6 +398,25 @@ mbedtls_mpi_uint mbedtls_mpi_core_mla(mbedtls_mpi_uint *X, size_t X_limbs,
const mbedtls_mpi_uint *A, size_t A_limbs,
mbedtls_mpi_uint b);
#define MPI_CORE(func) mbedtls_mpi_core_ ## func ## _minimal
/**
* \brief Perform a known-size multiplication
*
* \param[out] X The pointer to the (little-endian) array
* representing the product of \p a and \p b.
* This must be of length \p a + \p b.
* \param[in] A The pointer to the (little-endian) array
* representing the first factor.
* \param a The number of limbs in \p A.
* \param[in] B The pointer to the (little-endian) array
* representing the second factor.
* \param b The number of limbs in \p B.
*/
void MPI_CORE(mul)( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A, size_t a,
const mbedtls_mpi_uint *B, size_t b );
/**
* \brief Calculate initialisation value for fast Montgomery modular
* multiplication