This function frees the components of an MPI context.
Initialize an MPI context. This makes the MPI ready to be set or freed, but does not define a value for the MPI.
Compare an MPI with an integer.
Perform a multiplication of two MPIs: X = A * B
Perform a signed subtraction of MPIs: X = A - B
Perform a signed addition of MPIs: X = A + B
Enlarge an MPI to the specified number of limbs.
Store integer value in MPI.
Perform an unsigned subtraction of MPIs: X = |A| - |B|
Perform a right-shift on an MPI: X >>= count
Perform a left-shift on an MPI: X <<= count
Perform a modular reduction. R = A mod B
Return the number of bits up to and including the most significant bit of value \c 1. * \note This is same as the one-based index of the most significant bit of value \c 1.
Perform a multiplication of an MPI with an unsigned integer: X = A * b
Import an MPI from unsigned big endian binary data.
Export an MPI into unsigned big endian binary data of fixed size.
Compare the absolute values of two MPIs.
This function performs multiplication of a point by an integer: \p R = \p m * \p P in a restartable way. \see mbedtls_ecp_mul()
Perform a safe conditional copy of MPI which doesn't reveal whether the condition was true or not.
Get a specific bit from an MPI.
Return the number of bits of value \c 0 before the least significant bit of value \c 1.
Return the total size of an MPI value in bytes.
Compute the modular inverse: X = A^-1 mod N
This function generates a private key.
This function performs a scalar multiplication of a point by an integer: \p R = \p m * \p P. It is not thread-safe to use same group in multiple threads.
Retrieve a MPI value from an integer ASN.1 tag. Updates the pointer to immediately behind the full tag.
This function generates an ECDH keypair on an elliptic curve. This function performs the first of two core computations implemented during the ECDH key exchange. The second core computation is performed by mbedtls_ecdh_compute_shared(). \see ecp.h
This function resizes an MPI downwards, keeping at least the specified number of limbs. If \c X is smaller than \c nblimbs, it is resized up instead.
Import an MPI from an ASCII string.
Perform an unsigned addition of MPIs: X = |A| + |B|
Perform a signed subtraction of an MPI and an integer: X = A - b
Perform a division with remainder of two MPIs: A = Q * B + R
Fill an MPI with a number of random bytes.
This function performs multiplication and addition of two points by integers: \p R = \p m * \p P + \p n * \p Q in a restartable way. \see \c mbedtls_ecp_muladd()
This function checks that an \p mbedtls_mpi is a valid private key for this curve.
This function generates an ECP keypair.
Write a arbitrary-precision number (#MBEDTLS_ASN1_INTEGER) in ASN.1 format.
This function computes the shared secret. This function performs the second of two core computations implemented during the ECDH key exchange. The first core computation is performed by mbedtls_ecdh_gen_public(). \see ecp.h
Perform a signed addition of an MPI and an integer: X = A + b
Perform a division with remainder of an MPI by an integer: A = Q * b + R
Perform a modular reduction with respect to an integer. r = A mod b
Compute the greatest common divisor: G = gcd(A, B)
This function generates a keypair with a configurable base point.
This function computes the ECDSA signature of a previously-hashed message. \see ecp.h
This function verifies the ECDSA signature of a previously-hashed message. \see ecp.h
Swap the contents of two MPIs.
Perform a safe conditional swap which doesn't reveal whether the condition was true or not.
Modify a specific bit in an MPI.
Export an MPI to an ASCII string.
Perform a sliding-window exponentiation: X = A^E mod N
This function performs multiplication and addition of two points by integers: \p R = \p m * \p P + \p n * \p Q It is not thread-safe to use same group in multiple threads.
Miller-Rabin primality test. \warning If \p X is potentially generated by an adversary, for example when validating cryptographic parameters that you didn't generate yourself and that are supposed to be prime, then \p rounds should be at least the half of the security strength of the cryptographic algorithm. On the other hand, if \p X is chosen uniformly or non-adversially (as is the case when mbedtls_mpi_gen_prime calls this function), then \p rounds can be much lower.
Print a MPI variable to the debug output. This function is always used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the ssl context, file and line number parameters. \attention This function is intended for INTERNAL usage within the library only.
This function imports a set of core parameters into an RSA context. Any sequence of calls to this function should be followed by a call to mbedtls_rsa_complete(), which checks and completes the provided information to a ready-for-use public or private RSA key.
This function exports the core parameters of an RSA key. If this function runs successfully, the non-NULL buffers pointed to by \p N, \p P, \p Q, \p D, and \p E are fully written, with additional unused space filled leading by zero Bytes. Possible reasons for returning #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED: An alternative RSA implementation is in use, which stores the key externally, and either cannot or should not export it into RAM. A SW or HW implementation might not support a certain deduction. For example, \p P, \p Q from \p N, \p D, and \p E if the former are not part of the implementation. If the function fails due to an unsupported operation, the RSA context stays intact and remains usable.
This function exports CRT parameters of a private RSA key.