mirror of
https://github.com/espressif/mbedtls.git
synced 2025-05-09 19:31:18 +08:00
Add low level subtraction with modulus
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
531a871b88
commit
4c7cf7d742
@ -108,6 +108,16 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
|
|||||||
|
|
||||||
/* BEGIN MERGE SLOT 2 */
|
/* BEGIN MERGE SLOT 2 */
|
||||||
|
|
||||||
|
void mbedtls_mpi_mod_raw_sub( mbedtls_mpi_uint *X,
|
||||||
|
const mbedtls_mpi_uint *A,
|
||||||
|
const mbedtls_mpi_uint *B,
|
||||||
|
const mbedtls_mpi_mod_modulus *N )
|
||||||
|
{
|
||||||
|
mbedtls_mpi_uint c = mbedtls_mpi_core_sub( X, A, B, N->limbs );
|
||||||
|
|
||||||
|
(void) mbedtls_mpi_core_add_if( X, N->p, N->limbs, c );
|
||||||
|
}
|
||||||
|
|
||||||
/* END MERGE SLOT 2 */
|
/* END MERGE SLOT 2 */
|
||||||
|
|
||||||
/* BEGIN MERGE SLOT 3 */
|
/* BEGIN MERGE SLOT 3 */
|
||||||
|
@ -144,6 +144,26 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
|
|||||||
|
|
||||||
/* BEGIN MERGE SLOT 2 */
|
/* BEGIN MERGE SLOT 2 */
|
||||||
|
|
||||||
|
/** \brief Perform a subtraction of two MPIs and return the modulus
|
||||||
|
* of the result.
|
||||||
|
*
|
||||||
|
* The size of the operation is determined by \p N.
|
||||||
|
*
|
||||||
|
* \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. Use to perform a modulu
|
||||||
|
* operation on the result of the subtraction.
|
||||||
|
*
|
||||||
|
* \note Both \p A and \p B must be smaller than the modulus \p N.
|
||||||
|
*/
|
||||||
|
void mbedtls_mpi_mod_raw_sub( mbedtls_mpi_uint *X,
|
||||||
|
const mbedtls_mpi_uint *A,
|
||||||
|
const mbedtls_mpi_uint *B,
|
||||||
|
const mbedtls_mpi_mod_modulus *N );
|
||||||
|
|
||||||
/* END MERGE SLOT 2 */
|
/* END MERGE SLOT 2 */
|
||||||
|
|
||||||
/* BEGIN MERGE SLOT 3 */
|
/* BEGIN MERGE SLOT 3 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user