mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-06-19 11:27:56 +00:00
use mbedtls_cipher_info_from_psa to get cipher ID
This commit is contained in:
parent
f58aa6ade6
commit
0f21465175
|
@ -1491,6 +1491,8 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key,
|
||||||
size_t key_bits;
|
size_t key_bits;
|
||||||
unsigned char tag[16];
|
unsigned char tag[16];
|
||||||
mbedtls_cipher_id_t cipher_id;
|
mbedtls_cipher_id_t cipher_id;
|
||||||
|
const mbedtls_cipher_info_t *cipher_info = NULL;
|
||||||
|
|
||||||
*ciphertext_length = 0;
|
*ciphertext_length = 0;
|
||||||
|
|
||||||
if( ciphertext_size < ( plaintext_length + sizeof( tag ) ) )
|
if( ciphertext_size < ( plaintext_length + sizeof( tag ) ) )
|
||||||
|
@ -1501,14 +1503,9 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key,
|
||||||
return( status );
|
return( status );
|
||||||
slot = &global_data.key_slots[key];
|
slot = &global_data.key_slots[key];
|
||||||
|
|
||||||
if ( key_type == PSA_KEY_TYPE_AES )
|
cipher_info = mbedtls_cipher_info_from_psa( alg, key_type, key_bits, &cipher_id );
|
||||||
{
|
if( cipher_info == NULL )
|
||||||
cipher_id = MBEDTLS_CIPHER_ID_AES;
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: check key policy
|
//TODO: check key policy
|
||||||
|
|
||||||
|
@ -1622,7 +1619,8 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key,
|
||||||
const uint8_t *tag;
|
const uint8_t *tag;
|
||||||
size_t tag_length;
|
size_t tag_length;
|
||||||
mbedtls_cipher_id_t cipher_id;
|
mbedtls_cipher_id_t cipher_id;
|
||||||
|
const mbedtls_cipher_info_t *cipher_info = NULL;
|
||||||
|
|
||||||
*plaintext_length = 0;
|
*plaintext_length = 0;
|
||||||
|
|
||||||
status = psa_get_key_information( key, &key_type, &key_bits );
|
status = psa_get_key_information( key, &key_type, &key_bits );
|
||||||
|
@ -1630,15 +1628,9 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key,
|
||||||
return( status );
|
return( status );
|
||||||
slot = &global_data.key_slots[key];
|
slot = &global_data.key_slots[key];
|
||||||
|
|
||||||
if ( key_type == PSA_KEY_TYPE_AES )
|
cipher_info = mbedtls_cipher_info_from_psa( alg, key_type, key_bits, &cipher_id );
|
||||||
{
|
if( cipher_info == NULL )
|
||||||
cipher_id = MBEDTLS_CIPHER_ID_AES;
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: check key policy
|
//TODO: check key policy
|
||||||
|
|
||||||
if ( !( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) == PSA_KEY_TYPE_CATEGORY_CIPHER
|
if ( !( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) == PSA_KEY_TYPE_CATEGORY_CIPHER
|
||||||
|
|
Loading…
Reference in a new issue