From 928a07ba4935e7f3086e75a9eeef187fd0bbeef5 Mon Sep 17 00:00:00 2001 From: Mihir Raj Singh Date: Wed, 11 Jan 2023 20:08:34 +0530 Subject: [PATCH] bignum_mod: Renamed `m` -> N in mbedtls_mpi_mod_modulus_free Signed-off-by: Mihir Raj Singh --- library/bignum_mod.c | 30 ++++++++++++++++-------------- library/bignum_mod.h | 4 ++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/library/bignum_mod.c b/library/bignum_mod.c index c826ce7f1..1e9303df7 100644 --- a/library/bignum_mod.c +++ b/library/bignum_mod.c @@ -71,33 +71,35 @@ void mbedtls_mpi_mod_modulus_init( mbedtls_mpi_mod_modulus *N ) N->int_rep = MBEDTLS_MPI_MOD_REP_INVALID; } -void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *m) +void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *N ) { - if (m == NULL) { + if (N == NULL) { return; } - switch (m->int_rep) { + switch( N->int_rep ) + { case MBEDTLS_MPI_MOD_REP_MONTGOMERY: - if (m->rep.mont.rr != NULL) { - mbedtls_platform_zeroize((mbedtls_mpi_uint *) m->rep.mont.rr, - m->limbs * sizeof(mbedtls_mpi_uint)); - mbedtls_free((mbedtls_mpi_uint *) m->rep.mont.rr); - m->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 ); + N->rep.mont.rr = NULL; } - m->rep.mont.mm = 0; + N->rep.mont.mm = 0; break; case MBEDTLS_MPI_MOD_REP_OPT_RED: - mbedtls_free(m->rep.ored); + mbedtls_free( N->rep.ored ); break; case MBEDTLS_MPI_MOD_REP_INVALID: break; } - m->p = NULL; - m->limbs = 0; - m->bits = 0; - m->int_rep = MBEDTLS_MPI_MOD_REP_INVALID; + N->p = NULL; + N->limbs = 0; + N->bits = 0; + N->int_rep = MBEDTLS_MPI_MOD_REP_INVALID; } static int set_mont_const_square(const mbedtls_mpi_uint **X, diff --git a/library/bignum_mod.h b/library/bignum_mod.h index d29552270..ad8a1dd37 100644 --- a/library/bignum_mod.h +++ b/library/bignum_mod.h @@ -216,9 +216,9 @@ int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *N, * mbedtls_mpi_mod_modulus_setup() only removes the reference to it, * making it safe to free or to use it again. * - * \param[in,out] m The address of the modulus structure to free. + * \param[in,out] N The address of the modulus structure to free. */ -void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *m); +void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *N ); /* BEGIN MERGE SLOT 1 */