Align Montgomery init with development
The signature and naming of the Montgomrey initialisation function in
development and in the LTS was different. Align them for easier
readability and maintenance.
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum.c b/library/bignum.c
index 50da6b3..74f10af 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1907,19 +1907,17 @@
/*
* Fast Montgomery initialization (thanks to Tom St Denis)
*/
-void mbedtls_mpi_montg_init(mbedtls_mpi_uint *mm, const mbedtls_mpi *N)
+mbedtls_mpi_uint mbedtls_mpi_montmul_init(const mbedtls_mpi_uint *N)
{
- mbedtls_mpi_uint x, m0 = N->p[0];
- unsigned int i;
+ mbedtls_mpi_uint x = N[0];
- x = m0;
- x += ((m0 + 2) & 4) << 1;
+ x += ((N[0] + 2) & 4) << 1;
- for (i = biL; i >= 8; i /= 2) {
- x *= (2 - (m0 * x));
+ for (unsigned int i = biL; i >= 8; i /= 2) {
+ x *= (2 - (N[0] * x));
}
- *mm = ~x + 1;
+ return ~x + 1;
}
void mbedtls_mpi_montmul(mbedtls_mpi *A,
@@ -2069,7 +2067,7 @@
/*
* Init temps and window size
*/
- mbedtls_mpi_montg_init(&mm, N);
+ mm = mbedtls_mpi_montmul_init(N->p);
mbedtls_mpi_init(&RR); mbedtls_mpi_init(&T);
mbedtls_mpi_init(&Apos);
mbedtls_mpi_init(&WW);