Compute public key if absent when reading EC key

parent 4fc090af
......@@ -513,7 +513,7 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
}
/*
* Is 'publickey' present?
* Is 'publickey' present? If not, create it from the private key.
*/
if( ( ret = asn1_get_tag( &p, end, &len,
ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 1 ) ) == 0 )
......@@ -535,6 +535,12 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
ecp_keypair_free( eck );
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret );
}
else if( ( ret = ecp_mul( &eck->grp, &eck->Q, &eck->d, &eck->grp.G,
NULL, NULL ) ) != 0 )
{
ecp_keypair_free( eck );
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret );
}
if( ( ret = ecp_check_privkey( &eck->grp, &eck->d ) ) != 0 )
{
......
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