1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Add pk_check_pair()

This commit is contained in:
Manuel Pégourié-Gonnard
2014-11-06 16:51:20 +01:00
parent 30668d688d
commit 70bdadf54b
5 changed files with 88 additions and 0 deletions

View File

@ -300,6 +300,26 @@ int pk_encrypt( pk_context *ctx,
output, olen, osize, f_rng, p_rng ) );
}
/*
* Check public-private key pair
*/
int pk_check_pair( const pk_context *pub, const pk_context *prv )
{
if( pub == NULL || pub->pk_info == NULL ||
prv == NULL || prv->pk_info == NULL )
{
return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
}
if( pub->pk_info != prv->pk_info ||
pub->pk_info->check_pair_func == NULL )
{
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
}
return( pub->pk_info->check_pair_func( pub->pk_ctx, prv->pk_ctx ) );
}
/*
* Get key size in bits
*/