mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
New function mbedtls_dhm_get_value to copy a field of a DHM context
Reduce the need to break the DHM abstraction by accessing the context directly. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -134,6 +134,37 @@ 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 )
|
||||
{
|
||||
const mbedtls_mpi *src = NULL;
|
||||
switch( param )
|
||||
{
|
||||
case MBEDTLS_DHM_PARAM_P:
|
||||
src = &ctx->P;
|
||||
break;
|
||||
case MBEDTLS_DHM_PARAM_G:
|
||||
src = &ctx->G;
|
||||
break;
|
||||
case MBEDTLS_DHM_PARAM_X:
|
||||
src = &ctx->X;
|
||||
break;
|
||||
case MBEDTLS_DHM_PARAM_GX:
|
||||
src = &ctx->GX;
|
||||
break;
|
||||
case MBEDTLS_DHM_PARAM_GY:
|
||||
src = &ctx->GY;
|
||||
break;
|
||||
case MBEDTLS_DHM_PARAM_K:
|
||||
src = &ctx->K;
|
||||
break;
|
||||
default:
|
||||
return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA );
|
||||
}
|
||||
return( mbedtls_mpi_copy( dest, src ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the ServerKeyExchange parameters
|
||||
*/
|
||||
|
Reference in New Issue
Block a user