diff --git a/library/bignum_core.c b/library/bignum_core.c index e50f043c5..1ec5340b7 100644 --- a/library/bignum_core.c +++ b/library/bignum_core.c @@ -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). */ diff --git a/library/bignum_core.h b/library/bignum_core.h index 05bc923d2..f66db8fd4 100644 --- a/library/bignum_core.h +++ b/library/bignum_core.h @@ -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