mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-02 18:56:21 +00:00
Merge branch 'mbedtls-1.3' into development
* mbedtls-1.3: Fix bug in pk_parse_key() Update generated file Conflicts: library/pkparse.c library/version_features.c
This commit is contained in:
commit
e1e5871a55
|
@ -91,6 +91,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
|
||||||
|
|
|
@ -761,58 +761,62 @@ static int pk_parse_key_sec1_der( mbedtls_ecp_keypair *eck,
|
||||||
|
|
||||||
p += len;
|
p += len;
|
||||||
|
|
||||||
/*
|
pubkey_done = 0;
|
||||||
* Is 'parameters' present?
|
if( p != end )
|
||||||
*/
|
|
||||||
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
|
|
||||||
MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ) == 0 )
|
|
||||||
{
|
{
|
||||||
if( ( ret = pk_get_ecparams( &p, p + len, ¶ms) ) != 0 ||
|
/*
|
||||||
( ret = pk_use_ecparams( ¶ms, &eck->grp ) ) != 0 )
|
* Is 'parameters' present?
|
||||||
|
*/
|
||||||
|
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
|
||||||
|
MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 0 ) ) == 0 )
|
||||||
|
{
|
||||||
|
if( ( ret = pk_get_ecparams( &p, p + len, ¶ms) ) != 0 ||
|
||||||
|
( ret = pk_use_ecparams( ¶ms, &eck->grp ) ) != 0 )
|
||||||
|
{
|
||||||
|
mbedtls_ecp_keypair_free( eck );
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG )
|
||||||
|
{
|
||||||
|
mbedtls_ecp_keypair_free( eck );
|
||||||
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Is 'publickey' present? If not, or if we can't read it (eg because it
|
||||||
|
* is compressed), create it from the private key.
|
||||||
|
*/
|
||||||
|
pubkey_done = 0;
|
||||||
|
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
|
||||||
|
MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 1 ) ) == 0 )
|
||||||
|
{
|
||||||
|
end2 = p + len;
|
||||||
|
|
||||||
|
if( ( ret = mbedtls_asn1_get_bitstring_null( &p, end2, &len ) ) != 0 )
|
||||||
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
||||||
|
|
||||||
|
if( p + len != end2 )
|
||||||
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
|
||||||
|
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
|
||||||
|
|
||||||
|
if( ( ret = pk_get_ecpubkey( &p, end2, eck ) ) == 0 )
|
||||||
|
pubkey_done = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* The only acceptable failure mode of pk_get_ecpubkey() above
|
||||||
|
* is if the point format is not recognized.
|
||||||
|
*/
|
||||||
|
if( ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE )
|
||||||
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG )
|
||||||
{
|
{
|
||||||
mbedtls_ecp_keypair_free( eck );
|
mbedtls_ecp_keypair_free( eck );
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG )
|
|
||||||
{
|
|
||||||
mbedtls_ecp_keypair_free( eck );
|
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Is 'publickey' present? If not, or if we can't read it (eg because it
|
|
||||||
* is compressed), create it from the private key.
|
|
||||||
*/
|
|
||||||
pubkey_done = 0;
|
|
||||||
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
|
|
||||||
MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | 1 ) ) == 0 )
|
|
||||||
{
|
|
||||||
end2 = p + len;
|
|
||||||
|
|
||||||
if( ( ret = mbedtls_asn1_get_bitstring_null( &p, end2, &len ) ) != 0 )
|
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
||||||
|
|
||||||
if( p + len != end2 )
|
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
|
|
||||||
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
|
|
||||||
|
|
||||||
if( ( ret = pk_get_ecpubkey( &p, end2, eck ) ) == 0 )
|
|
||||||
pubkey_done = 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* The only acceptable failure mode of pk_get_ecpubkey() above
|
|
||||||
* is if the point format is not recognized.
|
|
||||||
*/
|
|
||||||
if( ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE )
|
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG )
|
|
||||||
{
|
|
||||||
mbedtls_ecp_keypair_free( eck );
|
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! pubkey_done &&
|
if( ! pubkey_done &&
|
||||||
|
|
BIN
tests/data_files/ec_prv.noopt.der
Normal file
BIN
tests/data_files/ec_prv.noopt.der
Normal file
Binary file not shown.
|
@ -146,6 +146,10 @@ Parse EC Key #1 (SEC1 DER)
|
||||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_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:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_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
|
||||||
|
|
Loading…
Reference in a new issue