Move RSA_ALT pk_info type check to the respective check_pair function

This commit is contained in:
Unknown 2018-02-06 03:28:23 -05:00
parent 3b450a1798
commit 7f4b10b5bd
2 changed files with 8 additions and 6 deletions

View File

@ -329,12 +329,7 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_conte
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
}
if( prv->pk_info->type == MBEDTLS_PK_RSA_ALT )
{
if( pub->pk_info->type != MBEDTLS_PK_RSA )
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
}
else if( prv->pk_info->type != MBEDTLS_PK_OPAQUE )
if( prv->pk_info->type != MBEDTLS_PK_OPAQUE )
{
if( pub->pk_info != prv->pk_info )
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );

View File

@ -486,6 +486,13 @@ static int rsa_alt_check_pair( const mbedtls_pk_context *pub, const void *prv )
unsigned char hash[32];
size_t sig_len = 0;
int ret;
const mbedtls_pk_context* prv_context = prv;
if( prv_context->pk_info->type == MBEDTLS_PK_RSA_ALT )
{
if( pub->pk_info->type != MBEDTLS_PK_RSA )
return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
}
if( rsa_alt_get_bitlen( prv ) != rsa_get_bitlen( pub->pk_ctx ) )
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );