mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-06 14:38:57 +01:00
Add ecp_curve_info_from_name()
This commit is contained in:
parent
49d738b50d
commit
0267e3dc9b
4 changed files with 83 additions and 3 deletions
|
|
@ -58,6 +58,11 @@
|
|||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(inline)
|
||||
#define inline _inline
|
||||
#else
|
||||
|
|
@ -84,13 +89,13 @@ unsigned long add_count, dbl_count, mul_count;
|
|||
const ecp_curve_info ecp_supported_curves[] =
|
||||
{
|
||||
#if defined(POLARSSL_ECP_DP_BP512R1_ENABLED)
|
||||
{ POLARSSL_ECP_DP_BP512R1, 28, 512, "brainpool512r1" },
|
||||
{ POLARSSL_ECP_DP_BP512R1, 28, 512, "brainpoolP512r1" },
|
||||
#endif
|
||||
#if defined(POLARSSL_ECP_DP_BP384R1_ENABLED)
|
||||
{ POLARSSL_ECP_DP_BP384R1, 27, 384, "brainpool384r1" },
|
||||
{ POLARSSL_ECP_DP_BP384R1, 27, 384, "brainpoolP384r1" },
|
||||
#endif
|
||||
#if defined(POLARSSL_ECP_DP_BP256R1_ENABLED)
|
||||
{ POLARSSL_ECP_DP_BP256R1, 26, 256, "brainpool256r1" },
|
||||
{ POLARSSL_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1" },
|
||||
#endif
|
||||
#if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED)
|
||||
{ POLARSSL_ECP_DP_SECP521R1, 25, 521, "secp521r1" },
|
||||
|
|
@ -154,6 +159,24 @@ const ecp_curve_info *ecp_curve_info_from_tls_id( uint16_t tls_id )
|
|||
return( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the curve info from the name
|
||||
*/
|
||||
const ecp_curve_info *ecp_curve_info_from_name( const char *name )
|
||||
{
|
||||
const ecp_curve_info *curve_info;
|
||||
|
||||
for( curve_info = ecp_curve_list();
|
||||
curve_info->grp_id != POLARSSL_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
if( strcasecmp( curve_info->name, name ) == 0 )
|
||||
return( curve_info );
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize (the components of) a point
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue