mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Implement can_do for opaque ECC keypairs
Unfortunately the can_do wrapper does not receive the key context as an argument, so it cannot check psa_get_key_information(). Later we might want to change our internal structures to fix this, but for now we'll just restrict opaque PSA keys to be ECDSA keypairs, as this is the only thing we need for now. It also simplifies testing a bit (no need to test each key type).
This commit is contained in:
committed by
Hanno Becker
parent
683632b78e
commit
07b103fe07
@ -108,6 +108,12 @@ void pk_psa_utils( )
|
||||
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup_psa( &pk, 0 ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
mbedtls_pk_free( &pk );
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
key = pk_psa_genkey();
|
||||
TEST_ASSERT( key != 0 );
|
||||
|
||||
@ -119,6 +125,10 @@ void pk_psa_utils( )
|
||||
TEST_ASSERT( mbedtls_pk_get_bitlen( &pk ) == bitlen );
|
||||
TEST_ASSERT( mbedtls_pk_get_len( &pk ) == bitlen / 8 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &pk, MBEDTLS_PK_ECKEY ) == 1 );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &pk, MBEDTLS_PK_ECDSA ) == 1 );
|
||||
TEST_ASSERT( mbedtls_pk_can_do( &pk, MBEDTLS_PK_RSA ) == 0 );
|
||||
|
||||
/* test that freeing the context does not destroy the key */
|
||||
mbedtls_pk_free( &pk );
|
||||
TEST_ASSERT( PSA_SUCCESS == psa_destroy_key( key ) );
|
||||
|
Reference in New Issue
Block a user