mbedtls_mpi_mod_inv() function
Perform modular inversion of an MPI with respect to a modulus \p N. \p A and \p X must be associated with the modulus \p N and will therefore have the same number of limbs as \p N. \p X may be aliased to \p A. \warning Currently only supports prime moduli, but does not check for them.
Arguments
X
The modular inverse of \p A with respect to \p N.
A
The number to calculate the modular inverse of. Must not be 0.
Return value
\c 0 if successful. #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p A and \p N do not have the same number of limbs. #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p A is zero. #MBEDTLS_ERR_MPI_ALLOC_FAILED if couldn't allocate enough memory (needed for conversion to and from Mongtomery form when not in Montgomery form already, and for temporary use by the inversion calculation itself).