mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-07 06:45:34 +00:00
pk_internal: pass context to can_do
In the mbedtls_pk_info_t method can_do, pass the context data. This will be needed for opaque keys, where the info structure depends on the method to access the opaque key and not on the key type.
This commit is contained in:
parent
858880686e
commit
373deea06d
|
@ -41,10 +41,10 @@ struct mbedtls_pk_info_t
|
|||
const char *name;
|
||||
|
||||
/** Get key size in bits */
|
||||
size_t (*get_bitlen)( const void * );
|
||||
size_t (*get_bitlen)( const void *ctx );
|
||||
|
||||
/** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */
|
||||
int (*can_do)( mbedtls_pk_type_t type );
|
||||
int (*can_do)( const void * ctx, mbedtls_pk_type_t type );
|
||||
|
||||
/** Verify signature */
|
||||
int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg,
|
||||
|
|
|
@ -154,7 +154,7 @@ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type )
|
|||
if( ctx == NULL || ctx->pk_info == NULL )
|
||||
return( 0 );
|
||||
|
||||
return( ctx->pk_info->can_do( type ) );
|
||||
return( ctx->pk_info->can_do( ctx->pk_ctx, type ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -60,8 +60,9 @@ static void mbedtls_zeroize( void *v, size_t n ) {
|
|||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
static int rsa_can_do( mbedtls_pk_type_t type )
|
||||
static int rsa_can_do( const void *ctx, mbedtls_pk_type_t type )
|
||||
{
|
||||
(void) ctx;
|
||||
return( type == MBEDTLS_PK_RSA ||
|
||||
type == MBEDTLS_PK_RSASSA_PSS );
|
||||
}
|
||||
|
@ -201,8 +202,9 @@ const mbedtls_pk_info_t mbedtls_rsa_info = {
|
|||
/*
|
||||
* Generic EC key
|
||||
*/
|
||||
static int eckey_can_do( mbedtls_pk_type_t type )
|
||||
static int eckey_can_do( const void *ctx, mbedtls_pk_type_t type )
|
||||
{
|
||||
(void) ctx;
|
||||
return( type == MBEDTLS_PK_ECKEY ||
|
||||
type == MBEDTLS_PK_ECKEY_DH ||
|
||||
type == MBEDTLS_PK_ECDSA );
|
||||
|
@ -314,8 +316,9 @@ const mbedtls_pk_info_t mbedtls_eckey_info = {
|
|||
/*
|
||||
* EC key restricted to ECDH
|
||||
*/
|
||||
static int eckeydh_can_do( mbedtls_pk_type_t type )
|
||||
static int eckeydh_can_do( const void *ctx, mbedtls_pk_type_t type )
|
||||
{
|
||||
(void) ctx;
|
||||
return( type == MBEDTLS_PK_ECKEY ||
|
||||
type == MBEDTLS_PK_ECKEY_DH );
|
||||
}
|
||||
|
@ -337,8 +340,9 @@ const mbedtls_pk_info_t mbedtls_eckeydh_info = {
|
|||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_C)
|
||||
static int ecdsa_can_do( mbedtls_pk_type_t type )
|
||||
static int ecdsa_can_do( const void *ctx, mbedtls_pk_type_t type )
|
||||
{
|
||||
(void) ctx;
|
||||
return( type == MBEDTLS_PK_ECDSA );
|
||||
}
|
||||
|
||||
|
@ -404,8 +408,9 @@ const mbedtls_pk_info_t mbedtls_ecdsa_info = {
|
|||
* Support for alternative RSA-private implementations
|
||||
*/
|
||||
|
||||
static int rsa_alt_can_do( mbedtls_pk_type_t type )
|
||||
static int rsa_alt_can_do( const void *ctx, mbedtls_pk_type_t type )
|
||||
{
|
||||
(void) ctx;
|
||||
return( type == MBEDTLS_PK_RSA );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue