Add mod_raw_mul function

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2022-12-07 16:02:33 +01:00
parent 9fa4897839
commit 979d34ca7d
No known key found for this signature in database
GPG Key ID: F072ACA227ACD71D
2 changed files with 35 additions and 0 deletions

View File

@ -120,6 +120,16 @@ void mbedtls_mpi_mod_raw_sub( mbedtls_mpi_uint *X,
(void) mbedtls_mpi_core_add_if( X, N->p, N->limbs, (unsigned) c );
}
void mbedtls_mpi_mod_raw_mul( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_uint *B,
const mbedtls_mpi_mod_modulus *N,
mbedtls_mpi_uint *T )
{
mbedtls_mpi_core_montmul( X, A, B, N->limbs, N->p, N->limbs,
N->rep.mont.mm, T );
}
/* END MERGE SLOT 2 */
/* BEGIN MERGE SLOT 3 */

View File

@ -170,6 +170,31 @@ void mbedtls_mpi_mod_raw_sub( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *B,
const mbedtls_mpi_mod_modulus *N );
/** \brief Multiply two MPIs, returning the residue modulo the specified
* modulus.
*
* The size of the operation is determined by \p N. \p A and \p B must have
* the same number of limbs as \p N.
*
* \p X may be aliased to \p A or \p B, or even both, but may not overlap
* either otherwise.
*
* \param[out] X The address of the result MPI.
* This must be initialized. Must have enough limbs to
* store the full value of the result.
* \param[in] A The address of the first MPI. This must be initialized.
* \param[in] B The address of the second MPI. This must be initialized.
* \param[in] N The address of the modulus. Used to perform a modulo
* operation on the result of the subtraction.
* \param[in] T The address of an MPI used by the multiplication
* as a temp variable.
*/
void mbedtls_mpi_mod_raw_mul( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_uint *B,
const mbedtls_mpi_mod_modulus *N,
mbedtls_mpi_uint *T );
/* END MERGE SLOT 2 */
/* BEGIN MERGE SLOT 3 */