Make a public version of mpi_montg_init() in bignum_new.c and add unit tests
The unit tests were created by capturing runs of the existing function during
execution of existing unit tests.
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
diff --git a/library/bignum_core.h b/library/bignum_core.h
index 7736467..02ac55d 100644
--- a/library/bignum_core.h
+++ b/library/bignum_core.h
@@ -171,7 +171,7 @@
* This must be odd and have exactly \p n limbs.
* \param[in] n The number of limbs in \p X, \p A, \p N.
* \param mm The Montgomery constant for \p N: -N^-1 mod 2^ciL.
- * This can be calculated by `mpi_montg_init()`.
+ * This can be calculated by `mbedtls_mpi_montg_init()`.
* \param[in,out] T Temporary storage of size at least 2*n+1 limbs.
* Its initial content is unused and
* its final content is indeterminate.
@@ -183,6 +183,17 @@
mbedtls_mpi_uint mm, mbedtls_mpi_uint *T );
/**
+ * \brief Calculate initialisation value for fast Montgomery modular
+ * multiplication
+ *
+ * \param m0 The least-significant mbedtls_mpi_uint from the modulus, which
+ * must be odd
+ *
+ * \return The initialisation value for fast Montgomery modular multiplication
+ */
+mbedtls_mpi_uint mbedtls_mpi_montg_init( mbedtls_mpi_uint m0 );
+
+/**
* \brief Perform a known-size multiply accumulate operation: d += b * s
*
* \param[in,out] d The pointer to the (little-endian) array