mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 22:20:30 +00:00
mbedtls_dhm_get_value parameter order: context first, output last
mbedtls_dhm_get_value can be seen as either a copy function or a getter function. Given the name and the semantics, it's more of a getter, even if it "gets" by doing a copy. Therefore, put the context first, and the selector next, leaving the output for last. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
cadd3d860e
commit
e5702489f5
@ -315,18 +315,18 @@ size_t mbedtls_dhm_get_len( const mbedtls_dhm_context *ctx );
|
||||
/**
|
||||
* \brief This function copies a parameter of a DHM key.
|
||||
*
|
||||
* \param dest The MPI object to copy the value into. It must be
|
||||
* initialized.
|
||||
* \param ctx The DHM context to query.
|
||||
* \param param The parameter to copy.
|
||||
* \param dest The MPI object to copy the value into. It must be
|
||||
* initialized.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_DHM_BAD_INPUT_DATA if \p field is invalid.
|
||||
* \return An \c MBEDTLS_ERR_MPI_XXX error code if the copy fails.
|
||||
*/
|
||||
int mbedtls_dhm_get_value( mbedtls_mpi *dest,
|
||||
const mbedtls_dhm_context *ctx,
|
||||
mbedtls_dhm_parameter param );
|
||||
int mbedtls_dhm_get_value( const mbedtls_dhm_context *ctx,
|
||||
mbedtls_dhm_parameter param,
|
||||
mbedtls_mpi *dest );
|
||||
|
||||
/**
|
||||
* \brief This function frees and clears the components
|
||||
|
@ -134,9 +134,9 @@ size_t mbedtls_dhm_get_len( const mbedtls_dhm_context *ctx )
|
||||
return( mbedtls_mpi_size( &ctx->P ) );
|
||||
}
|
||||
|
||||
int mbedtls_dhm_get_value( mbedtls_mpi *dest,
|
||||
const mbedtls_dhm_context *ctx,
|
||||
mbedtls_dhm_parameter param )
|
||||
int mbedtls_dhm_get_value( const mbedtls_dhm_context *ctx,
|
||||
mbedtls_dhm_parameter param,
|
||||
mbedtls_mpi *dest )
|
||||
{
|
||||
const mbedtls_mpi *src = NULL;
|
||||
switch( param )
|
||||
|
@ -3871,10 +3871,10 @@ int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
if( ( ret = mbedtls_dhm_get_value( &conf->dhm_P, dhm_ctx,
|
||||
MBEDTLS_DHM_PARAM_P ) ) != 0 ||
|
||||
( ret = mbedtls_dhm_get_value( &conf->dhm_G, dhm_ctx,
|
||||
MBEDTLS_DHM_PARAM_G ) ) != 0 )
|
||||
if( ( ret = mbedtls_dhm_get_value( dhm_ctx, MBEDTLS_DHM_PARAM_P,
|
||||
&conf->dhm_P ) ) != 0 ||
|
||||
( ret = mbedtls_dhm_get_value( dhm_ctx, MBEDTLS_DHM_PARAM_G,
|
||||
&conf->dhm_G ) ) != 0 )
|
||||
{
|
||||
mbedtls_mpi_free( &conf->dhm_P );
|
||||
mbedtls_mpi_free( &conf->dhm_G );
|
||||
|
@ -9,7 +9,7 @@ int check_get_value( const mbedtls_dhm_context *ctx,
|
||||
int ok = 0;
|
||||
mbedtls_mpi_init( &actual );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_get_value( &actual, ctx, param ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_get_value( ctx, param, &actual ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &actual, expected ) == 0 );
|
||||
ok = 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user