Clean up mpi_mod_init/free
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum_mod.h b/library/bignum_mod.h
index 7eac1df..432cd00 100644
--- a/library/bignum_mod.h
+++ b/library/bignum_mod.h
@@ -56,8 +56,12 @@
MBEDTLS_MPI_MOD_REP_OPT_RED
} mbedtls_mpi_mod_rep_selector;
-#define MBEDTLS_MPI_MOD_EXT_REP_LE 0x1
-#define MBEDTLS_MPI_MOD_EXT_REP_BE 0x2
+typedef enum
+{
+ MBEDTLS_MPI_MOD_EXT_REP_INVALID = 0,
+ MBEDTLS_MPI_MOD_EXT_REP_LE,
+ MBEDTLS_MPI_MOD_EXT_REP_BE
+} mbedtls_mpi_mod_ext_rep;
void mbedtls_mpi_mod_residue_release( mbedtls_mpi_mod_residue *r );
diff --git a/library/bignum_new.c b/library/bignum_new.c
index b6a806e..5f10ead 100644
--- a/library/bignum_new.c
+++ b/library/bignum_new.c
@@ -114,7 +114,11 @@
if ( m == NULL )
return;
- m->rep.mont = 0;
+ m->p = NULL;
+ m->n = 0;
+ m->plen = 0;
+ m->ext_rep = MBEDTLS_MPI_MOD_EXT_REP_INVALID;
+ m->int_rep = MBEDTLS_MPI_MOD_REP_INVALID;
}
void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *m )
@@ -125,10 +129,8 @@
m->p = NULL;
m->n = 0;
m->plen = 0;
- m->ext_rep = 0;
- m->int_rep = 0;
- m->rep.mont = NULL;
- m->rep.ored = NULL;
+ m->ext_rep = MBEDTLS_MPI_MOD_EXT_REP_INVALID;
+ m->int_rep = MBEDTLS_MPI_MOD_REP_INVALID;
}
int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *m,