Tidy up, removing MPI_CORE(), and using the new mbedtls_mpi_core_mla()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
diff --git a/library/bignum_core.h b/library/bignum_core.h
index 62d0151..7736467 100644
--- a/library/bignum_core.h
+++ b/library/bignum_core.h
@@ -155,9 +155,35 @@
#define GET_BYTE( X, i ) \
( ( (X)[(i) / ciL] >> ( ( (i) % ciL ) * 8 ) ) & 0xff )
-/** Perform a known-size multiply accumulate operation
+/**
+ * \brief Montgomery multiplication: X = A * B * R^-1 mod N (HAC 14.36)
*
- * Add \p b * \p s to \p d.
+ * \param[out] X The destination MPI, as a little-endian array of
+ * length \p n.
+ * On successful completion, X contains the result of
+ * the multiplication A * B * R^-1 mod N where
+ * R = (2^ciL)^n.
+ * \param[in] A Little-endian presentation of first operand.
+ * Must have exactly \p n limbs.
+ * \param[in] B Little-endian presentation of second operand.
+ * \param[in] B_len The number of limbs in \p B.
+ * \param[in] N Little-endian presentation of the modulus.
+ * 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()`.
+ * \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.
+ */
+void mbedtls_mpi_core_montmul( mbedtls_mpi_uint *X,
+ const mbedtls_mpi_uint *A,
+ const mbedtls_mpi_uint *B, size_t B_len,
+ const mbedtls_mpi_uint *N, size_t n,
+ mbedtls_mpi_uint mm, mbedtls_mpi_uint *T );
+
+/**
+ * \brief Perform a known-size multiply accumulate operation: d += b * s
*
* \param[in,out] d The pointer to the (little-endian) array
* representing the bignum to accumulate onto.
@@ -176,55 +202,6 @@
const mbedtls_mpi_uint *s, size_t s_len,
mbedtls_mpi_uint b );
-#define MPI_CORE(func) mbedtls_mpi_core_ ## func ## _minimal
-
-/** Montgomery multiplication: X = A * B * R^-1 mod N (HAC 14.36)
- *
- * \param[out] X The destination MPI, as a big endian array of length \p n.
- * On successful completion, X contains the result of
- * the multiplication A * B * R^-1 mod N where
- * R = (2^ciL)^n.
- * \param[in] A Big endian presentation of first operand.
- * Must have exactly \p n limbs.
- * \param[in] B Big endian presentation of second operand.
- * \param[in] B_len The number of limbs in \p B.
- * \param[in] N Big endian presentation of the modulus.
- * 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()`.
- * \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.
- */
-void MPI_CORE(montmul)( mbedtls_mpi_uint *X,
- const mbedtls_mpi_uint *A,
- const mbedtls_mpi_uint *B, size_t B_len,
- const mbedtls_mpi_uint *N, size_t n,
- mbedtls_mpi_uint mm, mbedtls_mpi_uint *T );
-
-/**
- * \brief Perform a known-size multiply accumulate operation
- *
- * Add \p b * \p s to \p d.
- *
- * \param[in,out] d The pointer to the (little-endian) array
- * representing the bignum to accumulate onto.
- * \param d_len The number of limbs of \p d. This must be
- * at least \p s_len.
- * \param[in] s The pointer to the (little-endian) array
- * representing the bignum to multiply with.
- * This may be the same as \p d. Otherwise,
- * it must be disjoint from \p d.
- * \param s_len The number of limbs of \p s.
- * \param b A scalar to multiply with.
- *
- * \return c The carry at the end of the operation.
- */
-mbedtls_mpi_uint MPI_CORE(mla)( mbedtls_mpi_uint *d, size_t d_len ,
- const mbedtls_mpi_uint *s, size_t s_len,
- mbedtls_mpi_uint b );
-
/**
* \brief Subtract two known-size large unsigned integers, returning the borrow.
*
@@ -235,17 +212,17 @@
* d may be aliased to l or r.
*
* \param[out] d The result of the subtraction.
- * \param[in] l The left operand.
- * \param[in] r The right operand.
+ * \param[in] l Little-endian presentation of left operand.
+ * \param[in] r Little-endian presentation of right operand.
* \param n Number of limbs of \p d, \p l and \p r.
*
* \return 1 if `l < r`.
* 0 if `l >= r`.
*/
-mbedtls_mpi_uint MPI_CORE(sub)( mbedtls_mpi_uint *d,
- const mbedtls_mpi_uint *l,
- const mbedtls_mpi_uint *r,
- size_t n );
+mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *d,
+ const mbedtls_mpi_uint *l,
+ const mbedtls_mpi_uint *r,
+ size_t n );
/**
* \brief Constant-time conditional addition of two known-size large unsigned
@@ -270,9 +247,9 @@
*
* \return 1 if `d + cond*r >= (2^{ciL})^n`, 0 otherwise.
*/
-mbedtls_mpi_uint MPI_CORE(add_if)( mbedtls_mpi_uint *d,
- const mbedtls_mpi_uint *r,
- size_t n,
- unsigned cond );
+mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *d,
+ const mbedtls_mpi_uint *r,
+ size_t n,
+ unsigned cond );
#endif /* MBEDTLS_BIGNUM_CORE_H */