Add verify for pk_sign_ext test
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
406cf27cb5
commit
b3bfe9f5d2
@ -341,7 +341,7 @@ PSA wrapped sign: BP512R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP512R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP512R1:PSA_ECC_FAMILY_BRAINPOOL_P_R1:512
|
||||
|
||||
PK test valid mebdtls_pk_sign_ext
|
||||
PK Sign ext:PK_RSASSA_PSS,MD_SHA512
|
||||
depends_on:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA512_C
|
||||
pk_psa_sign_ext:MBEDTLS_PK_RSA:2048:MBEDTLS_PK_RSASSA_PSS:MBEDTLS_MD_SHA512
|
||||
|
||||
|
@ -1096,21 +1096,36 @@ void pk_psa_sign_ext( int pk_type, int parameter, int key_pk_type, int md_alg )
|
||||
unsigned char sig[MBEDTLS_PK_SIGNATURE_MAX_SIZE];
|
||||
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
|
||||
size_t hash_len = sizeof( hash );
|
||||
|
||||
memset( hash, 0x2a, sizeof hash );
|
||||
memset( sig, 0, sizeof sig );
|
||||
void const *options = NULL;
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
mbedtls_pk_rsassa_pss_options rsassa_pss_options;
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
memset( hash, 0x2a, sizeof( hash ) );
|
||||
memset( sig, 0, sizeof( sig ) );
|
||||
|
||||
mbedtls_pk_init( &pk );
|
||||
PSA_INIT();
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( pk_type ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pk_setup( &pk,
|
||||
mbedtls_pk_info_from_type( pk_type ) ) == 0 );
|
||||
|
||||
TEST_ASSERT( pk_genkey( &pk, parameter ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_sign_ext( key_pk_type, &pk, md_alg, hash, hash_len,
|
||||
sig, sizeof sig , &sig_len,
|
||||
sig, sizeof( sig ), &sig_len,
|
||||
mbedtls_test_rnd_std_rand, NULL ) == 0 );
|
||||
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
if( key_pk_type == MBEDTLS_PK_RSASSA_PSS )
|
||||
{
|
||||
const mbedtls_md_info_t* md_info = mbedtls_md_info_from_type( md_alg );
|
||||
rsassa_pss_options.mgf1_hash_id = md_alg;
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
rsassa_pss_options.expected_salt_len = mbedtls_md_get_size( md_info );
|
||||
options = (const void*) &rsassa_pss_options;
|
||||
}
|
||||
#endif
|
||||
TEST_ASSERT( mbedtls_pk_verify_ext( key_pk_type, options, &pk, md_alg,
|
||||
hash, sizeof( hash ), sig, sig_len ) == 0 );
|
||||
exit:
|
||||
PSA_DONE( );
|
||||
mbedtls_pk_free( &pk );
|
||||
|
Loading…
Reference in New Issue
Block a user