Mbed OS Reference
|
Context-independent RSA helper functions. More...
Go to the source code of this file.
Functions | |
int | mbedtls_rsa_deduce_primes (mbedtls_mpi const *N, mbedtls_mpi const *E, mbedtls_mpi const *D, mbedtls_mpi *P, mbedtls_mpi *Q) |
Compute RSA prime moduli P, Q from public modulus N=PQ and a pair of private and public key. More... | |
int | mbedtls_rsa_deduce_private_exponent (mbedtls_mpi const *P, mbedtls_mpi const *Q, mbedtls_mpi const *E, mbedtls_mpi *D) |
Compute RSA private exponent from prime moduli and public key. More... | |
int | mbedtls_rsa_deduce_crt (const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *D, mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP) |
Generate RSA-CRT parameters. More... | |
int | mbedtls_rsa_validate_params (const mbedtls_mpi *N, const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *D, const mbedtls_mpi *E, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng) |
Check validity of core RSA parameters. More... | |
int | mbedtls_rsa_validate_crt (const mbedtls_mpi *P, const mbedtls_mpi *Q, const mbedtls_mpi *D, const mbedtls_mpi *DP, const mbedtls_mpi *DQ, const mbedtls_mpi *QP) |
Check validity of RSA CRT parameters. More... | |
Context-independent RSA helper functions.
This module declares some RSA-related helper functions useful when implementing the RSA interface. These functions are provided in a separate compilation unit in order to make it easy for designers of alternative RSA implementations to use them in their own code, as it is conceived that the functionality they provide will be necessary for most complete implementations.
End-users of Mbed TLS who are not providing their own alternative RSA implementations should not use these functions directly, and should instead use only the functions declared in rsa.h.
The interface provided by this module will be maintained through LTS (Long Term Support) branches of Mbed TLS, but may otherwise be subject to change, and must be considered an internal interface of the library.
There are two classes of helper functions:
(1) Parameter-generating helpers. These are:
(2) Parameter-checking helpers. These are:
Definition in file rsa_internal.h.
int mbedtls_rsa_deduce_primes | ( | mbedtls_mpi const * | N, |
mbedtls_mpi const * | E, | ||
mbedtls_mpi const * | D, | ||
mbedtls_mpi * | P, | ||
mbedtls_mpi * | Q | ||
) |
Compute RSA prime moduli P, Q from public modulus N=PQ and a pair of private and public key.
N | RSA modulus N = PQ, with P, Q to be found |
E | RSA public exponent |
D | RSA private exponent |
P | Pointer to MPI holding first prime factor of N on success |
Q | Pointer to MPI holding second prime factor of N on success |
mbedtls_rsa_validate_params
. int mbedtls_rsa_deduce_private_exponent | ( | mbedtls_mpi const * | P, |
mbedtls_mpi const * | Q, | ||
mbedtls_mpi const * | E, | ||
mbedtls_mpi * | D | ||
) |
Compute RSA private exponent from prime moduli and public key.
P | First prime factor of RSA modulus |
Q | Second prime factor of RSA modulus |
E | RSA public exponent |
D | Pointer to MPI holding the private exponent on success. |
int mbedtls_rsa_deduce_crt | ( | const mbedtls_mpi * | P, |
const mbedtls_mpi * | Q, | ||
const mbedtls_mpi * | D, | ||
mbedtls_mpi * | DP, | ||
mbedtls_mpi * | DQ, | ||
mbedtls_mpi * | QP | ||
) |
Generate RSA-CRT parameters.
P | First prime factor of N |
Q | Second prime factor of N |
D | RSA private exponent |
DP | Output variable for D modulo P-1 |
DQ | Output variable for D modulo Q-1 |
QP | Output variable for the modular inverse of Q modulo P. |
int mbedtls_rsa_validate_params | ( | const mbedtls_mpi * | N, |
const mbedtls_mpi * | P, | ||
const mbedtls_mpi * | Q, | ||
const mbedtls_mpi * | D, | ||
const mbedtls_mpi * | E, | ||
int(*)(void *, unsigned char *, size_t) | f_rng, | ||
void * | p_rng | ||
) |
Check validity of core RSA parameters.
N | RSA modulus N = PQ |
P | First prime factor of N |
Q | Second prime factor of N |
D | RSA private exponent |
E | RSA public exponent |
f_rng | PRNG to be used for primality check, or NULL |
p_rng | PRNG context for f_rng, or NULL |
int mbedtls_rsa_validate_crt | ( | const mbedtls_mpi * | P, |
const mbedtls_mpi * | Q, | ||
const mbedtls_mpi * | D, | ||
const mbedtls_mpi * | DP, | ||
const mbedtls_mpi * | DQ, | ||
const mbedtls_mpi * | QP | ||
) |
Check validity of RSA CRT parameters.
P | First prime factor of RSA modulus |
Q | Second prime factor of RSA modulus |
D | RSA private exponent |
DP | MPI to check for D modulo P-1 |
DQ | MPI to check for D modulo P-1 |
QP | MPI to check for the modular inverse of Q modulo P. |
MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
if check failed, potentially including MBEDTLS_ERR_MPI_XXX
if some MPI calculations failed.MBEDTLS_ERR_RSA_BAD_INPUT_DATA
if insufficient data was provided to check DP, DQ or QP.