mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 22:05:42 +01:00
Renamings and other fixes
This commit is contained in:
parent
e40c469ad3
commit
ac7194133e
@ -222,12 +222,22 @@ ecp_keypair;
|
|||||||
#define POLARSSL_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */
|
#define POLARSSL_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return the list of supported curves with associated info
|
* \brief Get the list of supported curves in order of preferrence
|
||||||
|
* (full information)
|
||||||
*
|
*
|
||||||
* \return A statically allocated array, the last entry is 0.
|
* \return A statically allocated array, the last entry is 0.
|
||||||
*/
|
*/
|
||||||
const ecp_curve_info *ecp_curve_list( void );
|
const ecp_curve_info *ecp_curve_list( void );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the list of supported curves in order of preferrence
|
||||||
|
* (grp_id only)
|
||||||
|
*
|
||||||
|
* \return A statically allocated array,
|
||||||
|
* terminated with POLARSSL_ECP_DP_NONE.
|
||||||
|
*/
|
||||||
|
const ecp_group_id *ecp_grp_id_list( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get curve information from an internal group identifier
|
* \brief Get curve information from an internal group identifier
|
||||||
*
|
*
|
||||||
@ -255,13 +265,6 @@ const ecp_curve_info *ecp_curve_info_from_tls_id( uint16_t tls_id );
|
|||||||
*/
|
*/
|
||||||
const ecp_curve_info *ecp_curve_info_from_name( const char *name );
|
const ecp_curve_info *ecp_curve_info_from_name( const char *name );
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the default ECDH curve list
|
|
||||||
*
|
|
||||||
* \return The default ECDH curve list
|
|
||||||
*/
|
|
||||||
ecp_group_id *ecp_get_default_echd_curve_list( void );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialize a point (as zero)
|
* \brief Initialize a point (as zero)
|
||||||
*/
|
*/
|
||||||
|
@ -115,13 +115,10 @@ typedef enum
|
|||||||
* - size in bits
|
* - size in bits
|
||||||
* - readable name
|
* - readable name
|
||||||
*
|
*
|
||||||
* The sequence of elements in this list also determines the default preference
|
* Curves are listed in order: largest curves first, and for a given size,
|
||||||
* of the curves used by an ECHDE handshake.
|
* fastest curves first. This provides the default order for the SSL module.
|
||||||
* We start with the most secure curves. From the same sized curves, we prefer
|
|
||||||
* the SECP ones because they are much faster.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static const ecp_curve_info ecp_supported_curves[] =
|
static const ecp_curve_info ecp_supported_curves[POLARSSL_ECP_DP_MAX] =
|
||||||
{
|
{
|
||||||
#if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_SECP521R1, 25, 521, "secp521r1" },
|
{ POLARSSL_ECP_DP_SECP521R1, 25, 521, "secp521r1" },
|
||||||
@ -138,28 +135,28 @@ static const ecp_curve_info ecp_supported_curves[] =
|
|||||||
#if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_SECP256R1, 23, 256, "secp256r1" },
|
{ POLARSSL_ECP_DP_SECP256R1, 23, 256, "secp256r1" },
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(POLARSSL_ECP_DP_SECP256K1_ENABLED)
|
||||||
|
{ POLARSSL_ECP_DP_SECP256K1, 22, 256, "secp256k1" },
|
||||||
|
#endif
|
||||||
#if defined(POLARSSL_ECP_DP_BP256R1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_BP256R1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1" },
|
{ POLARSSL_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1" },
|
||||||
#endif
|
#endif
|
||||||
#if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_SECP224R1, 21, 224, "secp224r1" },
|
{ POLARSSL_ECP_DP_SECP224R1, 21, 224, "secp224r1" },
|
||||||
#endif
|
#endif
|
||||||
#if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED)
|
|
||||||
{ POLARSSL_ECP_DP_SECP192R1, 19, 192, "secp192r1" },
|
|
||||||
#endif
|
|
||||||
#if defined(POLARSSL_ECP_DP_SECP256K1_ENABLED)
|
|
||||||
{ POLARSSL_ECP_DP_SECP256K1, 22, 256, "secp256k1" },
|
|
||||||
#endif
|
|
||||||
#if defined(POLARSSL_ECP_DP_SECP224K1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_SECP224K1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_SECP224K1, 20, 224, "secp224k1" },
|
{ POLARSSL_ECP_DP_SECP224K1, 20, 224, "secp224k1" },
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED)
|
||||||
|
{ POLARSSL_ECP_DP_SECP192R1, 19, 192, "secp192r1" },
|
||||||
|
#endif
|
||||||
#if defined(POLARSSL_ECP_DP_SECP192K1_ENABLED)
|
#if defined(POLARSSL_ECP_DP_SECP192K1_ENABLED)
|
||||||
{ POLARSSL_ECP_DP_SECP192K1, 18, 192, "secp192k1" },
|
{ POLARSSL_ECP_DP_SECP192K1, 18, 192, "secp192k1" },
|
||||||
#endif
|
#endif
|
||||||
{ POLARSSL_ECP_DP_NONE, 0, 0, NULL },
|
{ POLARSSL_ECP_DP_NONE, 0, 0, NULL },
|
||||||
};
|
};
|
||||||
#define ECP_NUM_SUPPORTED_CURVES ( sizeof( ecp_supported_curves ) / \
|
|
||||||
sizeof( ecp_curve_info ) )
|
static ecp_group_id ecp_supported_grp_id[POLARSSL_ECP_DP_MAX];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of supported curves and associated info
|
* List of supported curves and associated info
|
||||||
@ -170,7 +167,33 @@ const ecp_curve_info *ecp_curve_list( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the curve info for the internal identifer
|
* List of supported curves, group ID only
|
||||||
|
*/
|
||||||
|
const ecp_group_id *ecp_grp_id_list( void )
|
||||||
|
{
|
||||||
|
static int init_done = 0;
|
||||||
|
|
||||||
|
if( ! init_done )
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
const ecp_curve_info *curve_info;
|
||||||
|
|
||||||
|
for( curve_info = ecp_curve_list();
|
||||||
|
curve_info->grp_id != POLARSSL_ECP_DP_NONE;
|
||||||
|
curve_info++ )
|
||||||
|
{
|
||||||
|
ecp_supported_grp_id[i++] = curve_info->grp_id;
|
||||||
|
}
|
||||||
|
ecp_supported_grp_id[i] = POLARSSL_ECP_DP_NONE;
|
||||||
|
|
||||||
|
init_done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ecp_supported_grp_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the curve info for the internal identifier
|
||||||
*/
|
*/
|
||||||
const ecp_curve_info *ecp_curve_info_from_grp_id( ecp_group_id grp_id )
|
const ecp_curve_info *ecp_curve_info_from_grp_id( ecp_group_id grp_id )
|
||||||
{
|
{
|
||||||
@ -223,23 +246,6 @@ const ecp_curve_info *ecp_curve_info_from_name( const char *name )
|
|||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the default ECDH curve list
|
|
||||||
*/
|
|
||||||
ecp_group_id *ecp_get_default_echd_curve_list( void )
|
|
||||||
{
|
|
||||||
static ecp_group_id ecdh_default_curve_list[ECP_NUM_SUPPORTED_CURVES];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Build the list of default curves based on ecp_supported_curves[] */
|
|
||||||
for( i = 0; i < ECP_NUM_SUPPORTED_CURVES; i++)
|
|
||||||
{
|
|
||||||
ecdh_default_curve_list[i] = ecp_supported_curves[i].grp_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ecdh_default_curve_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the type of a curve
|
* Get the type of a curve
|
||||||
*/
|
*/
|
||||||
|
@ -3386,7 +3386,7 @@ int ssl_init( ssl_context *ssl )
|
|||||||
|
|
||||||
#if defined(POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED) && \
|
#if defined(POLARSSL_KEY_EXCHANGE__SOME__ECDHE_ENABLED) && \
|
||||||
defined(POLARSSL_SSL_SET_CURVES)
|
defined(POLARSSL_SSL_SET_CURVES)
|
||||||
ssl->curve_list = ecp_get_default_echd_curve_list( );
|
ssl->curve_list = ecp_grp_id_list( );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
|
if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
|
||||||
|
Loading…
Reference in New Issue
Block a user