Minor comments improvement
This commit is contained in:
parent
d363799a9d
commit
d9431a7817
1 changed files with 20 additions and 9 deletions
|
@ -74,16 +74,24 @@ static void mbedtls_zeroize( void *v, size_t n ) {
|
||||||
/*
|
/*
|
||||||
* Context-independent RSA helper functions.
|
* Context-independent RSA helper functions.
|
||||||
*
|
*
|
||||||
* The following three functions
|
* There are two classes of helper functions:
|
||||||
* - mbedtls_rsa_deduce_moduli
|
* (1) Parameter-generating helpers. These are:
|
||||||
* - mbedtls_rsa_deduce_private
|
* - mbedtls_rsa_deduce_moduli
|
||||||
* - mbedtls_rsa_check_params
|
* - mbedtls_rsa_deduce_private
|
||||||
* are helper functions operating on the core RSA parameters
|
* - mbedtls_rsa_deduce_crt
|
||||||
* (represented as MPI's). They do not use the RSA context structure
|
* Each of these functions takes a set of core RSA parameters
|
||||||
* and therefore need not be replaced when providing an alternative
|
* and generates some other, or CRT related parameters.
|
||||||
* RSA implementation.
|
* (2) Parameter-checking helpers. These are:
|
||||||
|
* - mbedtls_rsa_validate_params
|
||||||
|
* - mbedtls_rsa_validate_crt
|
||||||
|
* They take a set of core or CRT related RSA parameters
|
||||||
|
* and check their validity.
|
||||||
*
|
*
|
||||||
* Their purpose is to provide common MPI operations in the context
|
* The helper functions do not use the RSA context structure
|
||||||
|
* and therefore do not need to be replaced when providing
|
||||||
|
* an alternative RSA implementation.
|
||||||
|
*
|
||||||
|
* Their main purpose is to provide common MPI operations in the context
|
||||||
* of RSA that can be easily shared across multiple implementations.
|
* of RSA that can be easily shared across multiple implementations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -504,18 +512,21 @@ int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
|
||||||
mbedtls_mpi K;
|
mbedtls_mpi K;
|
||||||
mbedtls_mpi_init( &K );
|
mbedtls_mpi_init( &K );
|
||||||
|
|
||||||
|
/* DP = D mod P-1 */
|
||||||
if( DP != NULL )
|
if( DP != NULL )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DP, D, &K ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DP, D, &K ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DQ = D mod Q-1 */
|
||||||
if( DQ != NULL )
|
if( DQ != NULL )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DQ, D, &K ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DQ, D, &K ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* QP = Q^{-1} mod P */
|
||||||
if( QP != NULL )
|
if( QP != NULL )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( QP, Q, P ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( QP, Q, P ) );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue