mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #6743 from minosgalanakis/bignum/implement_modular_negation
Bignum: Implement fixed width modular negation
This commit is contained in:
@ -213,6 +213,18 @@ int mbedtls_mpi_mod_raw_from_mont_rep( mbedtls_mpi_uint *X,
|
||||
mbedtls_free( T );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void mbedtls_mpi_mod_raw_neg( mbedtls_mpi_uint *X,
|
||||
const mbedtls_mpi_uint *A,
|
||||
const mbedtls_mpi_mod_modulus *m )
|
||||
{
|
||||
mbedtls_mpi_core_sub( X, m->p, A, m->limbs );
|
||||
|
||||
/* If A=0 initially, then X=N now. Detect this by
|
||||
* subtracting N and catching the carry. */
|
||||
mbedtls_mpi_uint borrow = mbedtls_mpi_core_sub( X, X, m->p, m->limbs );
|
||||
(void) mbedtls_mpi_core_add_if( X, m->p, m->limbs, (unsigned) borrow );
|
||||
}
|
||||
/* END MERGE SLOT 7 */
|
||||
|
||||
/* BEGIN MERGE SLOT 8 */
|
||||
|
Reference in New Issue
Block a user