Commit 835eb59c authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

PK: fix support for ECKEY_DH

parent f18c3e03
......@@ -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)
......
......@@ -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)
......
......@@ -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 */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment