mbedtls_mpi_core_montmul() function
Montgomery multiplication: X = A * B * R^-1 mod N (HAC 14.36) \p A and \p B must be in canonical form. That is, < \p N. \p X may be aliased to \p A or \p N, or even \p B (if \p AN_limbs == \p B_limbs) but may not overlap any parameters otherwise. \p A and \p B may alias each other, if \p AN_limbs == \p B_limbs. They may not alias \p N (since they must be in canonical form, they cannot == \p N).
Arguments
X
The destination MPI, as a little-endian array of length \p AN_limbs. On successful completion, X contains the result of the multiplication `A * B * R^-1` mod N where `R = 2^(biL*AN_limbs)`.
A
Little-endian presentation of first operand. Must have the same number of limbs as \p N.
B
Little-endian presentation of second operand.
B_limbs
The number of limbs in \p B. Must be <= \p AN_limbs.
N
Little-endian presentation of the modulus. This must be odd, and have exactly the same number of limbs as \p A. It may alias \p X, but must not alias or otherwise overlap any of the other parameters.
AN_limbs
The number of limbs in \p X, \p A and \p N.
mm
The Montgomery constant for \p N: -N^-1 mod 2^biL. This can be calculated by `mbedtls_mpi_core_montmul_init()`.
T
Temporary storage of size at least 2*AN_limbs+1 limbs. Its initial content is unused and its final content is indeterminate. It must not alias or otherwise overlap any of the other parameters.
![]()
mbedtls_mpi_core_montmul(T->p, T->p, Vf->p, nlimbs, N->p, nlimbs, mm, M_T.p);
mbedtls_mpi_core_montmul() is called by 5 functions and calls 4 functions:
![]()
mbedtls_mpi_core_montmul()
mbedtls_mpi_core_montmul():
![]()
mbedtls_mpi_core_montmul()