PK: fix support for ECKEY_DH

This commit is contained in:
Manuel Pégourié-Gonnard 2013-08-12 18:51:26 +02:00
parent f18c3e0378
commit 835eb59c6a
3 changed files with 38 additions and 1 deletions

View file

@ -38,6 +38,7 @@ extern const pk_info_t rsa_info;
#if defined(POLARSSL_ECP_C)
extern const pk_info_t eckey_info;
extern const pk_info_t eckeydh_info;
#endif
#if defined(POLARSSL_ECDSA_C)

View file

@ -119,11 +119,16 @@ int pk_set_type( pk_context *ctx, pk_type_t type )
else
#endif
#if defined(POLARSSL_ECP_C)
if( type == POLARSSL_PK_ECKEY || type == POLARSSL_PK_ECKEY_DH )
if( type == POLARSSL_PK_ECKEY )
{
size = sizeof( ecp_keypair );
info = &eckey_info;
}
else if( type == POLARSSL_PK_ECKEY_DH )
{
size = sizeof( ecp_keypair );
info = &eckeydh_info;
}
else
#endif
#if defined(POLARSSL_ECDSA_C)

View file

@ -84,6 +84,9 @@ const pk_info_t ecdsa_info = {
#endif /* POLARSSL_ECDSA_C */
#if defined(POLARSSL_ECP_C)
/*
* Generic EC key
*/
static int eckey_can_do( pk_type_t type )
{
return( type == POLARSSL_PK_ECKEY ||
@ -123,4 +126,32 @@ const pk_info_t eckey_info = {
eckey_can_do,
eckey_verify_wrap,
};
/*
* EC key resticted to ECDH
*/
static int eckeydh_can_do( pk_type_t type )
{
return( type == POLARSSL_PK_ECKEY ||
type == POLARSSL_PK_ECKEY_DH );
}
static int eckeydh_verify_wrap( void *ctx,
const unsigned char *hash, const md_info_t *md_info,
const unsigned char *sig, size_t sig_len )
{
((void) ctx);
((void) hash);
((void) md_info);
((void) sig);
((void) sig_len);
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
}
const pk_info_t eckeydh_info = {
POLARSSL_PK_ECKEY_DH,
eckeydh_can_do,
eckeydh_verify_wrap,
};
#endif /* POLARSSL_ECP_C */