mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
Add name and get_size() members in PK
This commit is contained in:
parent
835eb59c6a
commit
f8c948a674
3 changed files with 58 additions and 14 deletions
|
|
@ -45,6 +45,11 @@ static int rsa_can_do( pk_type_t type )
|
|||
return( type == POLARSSL_PK_RSA );
|
||||
}
|
||||
|
||||
static size_t rsa_get_size( void * ctx )
|
||||
{
|
||||
return( mpi_size( &((rsa_context *) ctx)->N ) * 8 );
|
||||
}
|
||||
|
||||
static int rsa_verify_wrap( void *ctx,
|
||||
const unsigned char *hash, const md_info_t *md_info,
|
||||
const unsigned char *sig, size_t sig_len )
|
||||
|
|
@ -57,6 +62,8 @@ static int rsa_verify_wrap( void *ctx,
|
|||
|
||||
const pk_info_t rsa_info = {
|
||||
POLARSSL_PK_RSA,
|
||||
"RSA",
|
||||
rsa_get_size,
|
||||
rsa_can_do,
|
||||
rsa_verify_wrap,
|
||||
};
|
||||
|
|
@ -68,6 +75,11 @@ int ecdsa_can_do( pk_type_t type )
|
|||
return( type == POLARSSL_PK_ECDSA );
|
||||
}
|
||||
|
||||
static size_t ecdsa_get_size( void *ctx )
|
||||
{
|
||||
return( ((ecdsa_context *) ctx)->grp.pbits );
|
||||
}
|
||||
|
||||
int ecdsa_verify_wrap( void *ctx,
|
||||
const unsigned char *hash, const md_info_t *md_info,
|
||||
const unsigned char *sig, size_t sig_len )
|
||||
|
|
@ -78,6 +90,8 @@ int ecdsa_verify_wrap( void *ctx,
|
|||
|
||||
const pk_info_t ecdsa_info = {
|
||||
POLARSSL_PK_ECDSA,
|
||||
"ECDSA",
|
||||
ecdsa_get_size,
|
||||
ecdsa_can_do,
|
||||
ecdsa_verify_wrap,
|
||||
};
|
||||
|
|
@ -94,6 +108,11 @@ static int eckey_can_do( pk_type_t type )
|
|||
type == POLARSSL_PK_ECDSA );
|
||||
}
|
||||
|
||||
static size_t eckey_get_size( void *ctx )
|
||||
{
|
||||
return( ((ecp_keypair *) ctx)->grp.pbits );
|
||||
}
|
||||
|
||||
static int eckey_verify_wrap( void *ctx,
|
||||
const unsigned char *hash, const md_info_t *md_info,
|
||||
const unsigned char *sig, size_t sig_len )
|
||||
|
|
@ -123,6 +142,8 @@ static int eckey_verify_wrap( void *ctx,
|
|||
|
||||
const pk_info_t eckey_info = {
|
||||
POLARSSL_PK_ECKEY,
|
||||
"EC",
|
||||
eckey_get_size,
|
||||
eckey_can_do,
|
||||
eckey_verify_wrap,
|
||||
};
|
||||
|
|
@ -151,6 +172,8 @@ static int eckeydh_verify_wrap( void *ctx,
|
|||
|
||||
const pk_info_t eckeydh_info = {
|
||||
POLARSSL_PK_ECKEY_DH,
|
||||
"EC_DH",
|
||||
eckey_get_size, /* Same underlying key structure */
|
||||
eckeydh_can_do,
|
||||
eckeydh_verify_wrap,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue