PK: add nice interface functions

Also fix a const-corectness issue.
This commit is contained in:
Manuel Pégourié-Gonnard 2013-08-14 15:56:19 +02:00
parent 765db07dfb
commit b3d9187cea
9 changed files with 111 additions and 28 deletions

View file

@ -53,9 +53,9 @@ static int rsa_can_do( pk_type_t type )
return( type == POLARSSL_PK_RSA );
}
static size_t rsa_get_size( void * ctx )
static size_t rsa_get_size( const void * ctx )
{
return( mpi_size( &((rsa_context *) ctx)->N ) * 8 );
return( 8 * ((rsa_context *) ctx)->len );
}
static int rsa_verify_wrap( void *ctx,
@ -101,7 +101,7 @@ int ecdsa_can_do( pk_type_t type )
return( type == POLARSSL_PK_ECDSA );
}
static size_t ecdsa_get_size( void *ctx )
static size_t ecdsa_get_size( const void *ctx )
{
return( ((ecdsa_context *) ctx)->grp.pbits );
}
@ -152,7 +152,7 @@ static int eckey_can_do( pk_type_t type )
type == POLARSSL_PK_ECDSA );
}
static size_t eckey_get_size( void *ctx )
static size_t eckey_get_size( const void *ctx )
{
return( ((ecp_keypair *) ctx)->grp.pbits );
}