1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

pk_set_type() cannot be used to reset key type

This commit is contained in:
Manuel Pégourié-Gonnard
2013-07-09 10:21:34 +02:00
committed by Paul Bakker
parent 0a64e8f1fd
commit 374e4b87d4
4 changed files with 24 additions and 2 deletions

View File

@@ -3120,6 +3120,8 @@ int x509parse_key( pk_context *ctx,
return( 0 );
}
pk_free( ctx );
if ( ( ret = pk_set_type( ctx, POLARSSL_PK_ECKEY ) ) != 0 )
return( ret );
@@ -3128,6 +3130,8 @@ int x509parse_key( pk_context *ctx,
return( 0 );
}
pk_free( ctx );
return( POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT );
}
@@ -3145,12 +3149,16 @@ int x509parse_public_key( pk_context *ctx,
if( ( ret = x509parse_public_key_rsa( ctx->data, key, keylen ) ) == 0 )
return( 0 );
pk_free( ctx );
if ( ( ret = pk_set_type( ctx, POLARSSL_PK_ECKEY ) ) != 0 )
return( ret );
if( ( ret = x509parse_public_key_ec( ctx->data, key, keylen ) ) == 0 )
return( 0 );
pk_free( ctx );
return( POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT );
}