Fix bug in pk_parse_key()

This commit is contained in:
Manuel Pégourié-Gonnard 2015-04-14 11:18:04 +02:00
parent dbd60f72b1
commit 924cd100a6
4 changed files with 56 additions and 47 deletions

View File

@ -25,6 +25,8 @@ Features
errors on use of deprecated functions. errors on use of deprecated functions.
Bugfix Bugfix
* Fix bug in pk_parse_key() that caused some valid private EC keys to be
rejected.
* Fix bug in Via Padlock support (found by Nikos Mavrogiannopoulos). * Fix bug in Via Padlock support (found by Nikos Mavrogiannopoulos).
* Fix thread safety bug in RSA operations (found by Fredrik Axelsson). * Fix thread safety bug in RSA operations (found by Fredrik Axelsson).
* Fix hardclock() (only used in the benchmarking program) with some * Fix hardclock() (only used in the benchmarking program) with some

View File

@ -761,6 +761,9 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
p += len; p += len;
pubkey_done = 0;
if( p != end )
{
/* /*
* Is 'parameters' present? * Is 'parameters' present?
*/ */
@ -784,7 +787,6 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
* Is 'publickey' present? If not, or if we can't read it (eg because it * Is 'publickey' present? If not, or if we can't read it (eg because it
* is compressed), create it from the private key. * is compressed), create it from the private key.
*/ */
pubkey_done = 0;
if( ( ret = asn1_get_tag( &p, end, &len, if( ( ret = asn1_get_tag( &p, end, &len,
ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 1 ) ) == 0 ) ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 1 ) ) == 0 )
{ {
@ -814,6 +816,7 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
ecp_keypair_free( eck ); ecp_keypair_free( eck );
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret ); return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret );
} }
}
if( ! pubkey_done && if( ! pubkey_done &&
( ret = ecp_mul( &eck->grp, &eck->Q, &eck->d, &eck->grp.G, ( ret = ecp_mul( &eck->grp, &eck->Q, &eck->d, &eck->grp.G,

Binary file not shown.

View File

@ -146,6 +146,10 @@ Parse EC Key #1 (SEC1 DER)
depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED
pk_parse_keyfile_ec:"data_files/ec_prv.sec1.der":"NULL":0 pk_parse_keyfile_ec:"data_files/ec_prv.sec1.der":"NULL":0
Parse EC Key #1a (SEC1 DER, no optional part)
depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP256R1_ENABLED
pk_parse_keyfile_ec:"data_files/ec_prv.noopt.der":"NULL":0
Parse EC Key #2 (SEC1 PEM) Parse EC Key #2 (SEC1 PEM)
depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED
pk_parse_keyfile_ec:"data_files/ec_prv.sec1.pem":"NULL":0 pk_parse_keyfile_ec:"data_files/ec_prv.sec1.pem":"NULL":0