1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

bignum_mod_raw: Renamed m -> N in mbedtls_mpi_mod_raw_neg()

Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
This commit is contained in:
Mihir Raj Singh
2023-01-11 21:12:46 +05:30
parent b0354c5b71
commit 432cacf5c2
4 changed files with 105 additions and 110 deletions

View File

@ -77,11 +77,9 @@ void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *N )
return;
}
switch( N->int_rep )
{
switch (N->int_rep) {
case MBEDTLS_MPI_MOD_REP_MONTGOMERY:
if (N->rep.mont.rr != NULL)
{
if (N->rep.mont.rr != NULL) {
mbedtls_platform_zeroize((mbedtls_mpi_uint *) N->rep.mont.rr,
N->limbs * sizeof(mbedtls_mpi_uint));
mbedtls_free((mbedtls_mpi_uint *) N->rep.mont.rr);
@ -166,8 +164,7 @@ int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *N,
exit:
if( ret != 0 )
{
if (ret != 0) {
mbedtls_mpi_mod_modulus_free(N);
}
@ -405,8 +402,7 @@ int mbedtls_mpi_mod_write( const mbedtls_mpi_mod_residue *r,
ret = mbedtls_mpi_mod_raw_write(r->p, N, buf, buflen, ext_rep);
if( N->int_rep == MBEDTLS_MPI_MOD_REP_MONTGOMERY )
{
if (N->int_rep == MBEDTLS_MPI_MOD_REP_MONTGOMERY) {
/* If this fails, the value of r is corrupted and we want to return
* this error (as opposed to the error code from the write above) to
* let the caller know. If it succeeds, we want to return the error

View File

@ -74,8 +74,7 @@ int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
goto cleanup;
}
if( !mbedtls_mpi_core_lt_ct( X, N->p, N->limbs ) )
{
if (!mbedtls_mpi_core_lt_ct(X, N->p, N->limbs)) {
ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
goto cleanup;
}
@ -93,11 +92,11 @@ int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
{
switch (ext_rep) {
case MBEDTLS_MPI_MOD_EXT_REP_LE:
return( mbedtls_mpi_core_write_le( A, N->limbs,
output, output_length ) );
return mbedtls_mpi_core_write_le(A, N->limbs,
output, output_length);
case MBEDTLS_MPI_MOD_EXT_REP_BE:
return( mbedtls_mpi_core_write_be( A, N->limbs,
output, output_length ) );
return mbedtls_mpi_core_write_be(A, N->limbs,
output, output_length);
default:
return MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
}
@ -266,14 +265,14 @@ int mbedtls_mpi_mod_raw_from_mont_rep( mbedtls_mpi_uint *X,
void mbedtls_mpi_mod_raw_neg(mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_mod_modulus *m)
const mbedtls_mpi_mod_modulus *N)
{
mbedtls_mpi_core_sub(X, m->p, A, m->limbs);
mbedtls_mpi_core_sub(X, N->p, A, N->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);
mbedtls_mpi_uint borrow = mbedtls_mpi_core_sub(X, X, N->p, N->limbs);
(void) mbedtls_mpi_core_add_if(X, N->p, N->limbs, (unsigned) borrow);
}
/* END MERGE SLOT 7 */

View File

@ -433,20 +433,20 @@ int mbedtls_mpi_mod_raw_from_mont_rep( mbedtls_mpi_uint *X,
/** \brief Perform fixed width modular negation.
*
* The size of the operation is determined by \p m. \p A must have
* the same number of limbs as \p m.
* The size of the operation is determined by \p N. \p A must have
* the same number of limbs as \p N.
*
* \p X may be aliased to \p A.
*
* \param[out] X The result of the modular negation.
* This must be initialized.
* \param[in] A Little-endian presentation of the input operand. This
* must be less than or equal to \p m.
* \param[in] m The modulus to use.
* must be less than or equal to \p N.
* \param[in] N The modulus to use.
*/
void mbedtls_mpi_mod_raw_neg(mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_mod_modulus *m);
const mbedtls_mpi_mod_modulus *N);
/* END MERGE SLOT 7 */
/* BEGIN MERGE SLOT 8 */