mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Add pk_check_pair()
This commit is contained in:
parent
30668d688d
commit
70bdadf54b
5 changed files with 88 additions and 0 deletions
20
library/pk.c
20
library/pk.c
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue