mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 04:45:49 +01:00
Rename mbedtls_pk_signature_size to mbedtls_pk_get_signature_size
Add more descriptive comments and return value description
This commit is contained in:
parent
60b25f0529
commit
d0d0602ea5
@ -475,7 +475,7 @@ int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
||||
*
|
||||
* \return Maximum size in bytes of a signature made with this key.
|
||||
*/
|
||||
size_t mbedtls_pk_signature_size( const mbedtls_pk_context *ctx );
|
||||
size_t mbedtls_pk_get_signature_size( const mbedtls_pk_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Decrypt message (including padding if relevant).
|
||||
|
@ -120,9 +120,11 @@ struct mbedtls_pk_info_t
|
||||
* usage restrictions into account. */
|
||||
int (*can_do)( const void * ctx, mbedtls_pk_type_t type );
|
||||
|
||||
/** Signature size
|
||||
/** Upper bound of the signature length
|
||||
*
|
||||
* mbedtls_pk_signature_size() returns this value.
|
||||
* mbedtls_pk_get_signature_size() returns this value.
|
||||
*
|
||||
* In case of an error, or an unsupported key type, 0 should be returned.
|
||||
*
|
||||
* Opaque implementations may omit this method if they do not support
|
||||
* signature. */
|
||||
|
@ -357,7 +357,7 @@ size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx )
|
||||
/*
|
||||
* Maximum signature size
|
||||
*/
|
||||
size_t mbedtls_pk_signature_size( const mbedtls_pk_context *ctx )
|
||||
size_t mbedtls_pk_get_signature_size( const mbedtls_pk_context *ctx )
|
||||
{
|
||||
if( ctx == NULL || ctx->pk_info == NULL )
|
||||
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
@ -100,7 +100,7 @@ static void pk_rsa_match( mbedtls_rsa_context *raw,
|
||||
TEST_ASSERT( mbedtls_pk_can_do( tested_ctx, MBEDTLS_PK_RSA ) );
|
||||
TEST_ASSERT( mbedtls_pk_get_bitlen( tested_ctx ) == RSA_KEY_SIZE );
|
||||
TEST_ASSERT( mbedtls_pk_get_len( tested_ctx ) == RSA_KEY_LEN );
|
||||
TEST_ASSERT( mbedtls_pk_signature_size( tested_ctx ) == RSA_KEY_LEN );
|
||||
TEST_ASSERT( mbedtls_pk_get_signature_size( tested_ctx ) == RSA_KEY_LEN );
|
||||
|
||||
/* Test signature */
|
||||
TEST_ASSERT( mbedtls_pk_sign( tested_ctx, MBEDTLS_MD_NONE, hash, sizeof hash,
|
||||
@ -533,7 +533,7 @@ void pk_sign_verify( int type, int sign_ret, int verify_ret )
|
||||
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash,
|
||||
sig, &sig_len, rnd_std_rand, NULL ) == sign_ret );
|
||||
if( sign_ret == 0 )
|
||||
TEST_ASSERT( sig_len <= mbedtls_pk_signature_size( &pk ) );
|
||||
TEST_ASSERT( sig_len <= mbedtls_pk_get_signature_size( &pk ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256,
|
||||
hash, sizeof hash, sig, sig_len ) == verify_ret );
|
||||
@ -774,7 +774,7 @@ void pk_opaque_mock( )
|
||||
TEST_ASSERT( mbedtls_pk_get_bitlen( &ctx ) == OPAQUE_MOCK_BITLEN );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &ctx, OPAQUE_MOCK_CAN_DO ) == 1 );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &ctx, OPAQUE_MOCK_CAN_DO ^ 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pk_signature_size( &ctx ) == OPAQUE_MOCK_SIGNATURE_SIZE );
|
||||
TEST_ASSERT( mbedtls_pk_get_signature_size( &ctx ) == OPAQUE_MOCK_SIGNATURE_SIZE );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_verify( &ctx, OPAQUE_MOCK_MD_ALG,
|
||||
opaque_mock_hash, sizeof( opaque_mock_hash ),
|
||||
@ -881,7 +881,7 @@ void pk_opaque_minimal( )
|
||||
TEST_ASSERT( mbedtls_pk_get_bitlen( &ctx ) == OPAQUE_MOCK_BITLEN );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &ctx, OPAQUE_MOCK_CAN_DO ) == 1 );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &ctx, OPAQUE_MOCK_CAN_DO ^ 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pk_signature_size( &ctx ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pk_get_signature_size( &ctx ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_verify( &ctx, OPAQUE_MOCK_MD_ALG,
|
||||
NULL, 0, NULL, 0 ) ==
|
||||
|
Loading…
Reference in New Issue
Block a user