mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-27 02:55:30 +00:00
psa: mac: Add MAC compute builtin implementation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
def68e722a
commit
bfdfaa676c
|
@ -359,30 +359,6 @@ static psa_status_t mac_setup( mbedtls_psa_mac_operation_t *operation,
|
||||||
return( status );
|
return( status );
|
||||||
}
|
}
|
||||||
|
|
||||||
static psa_status_t mac_compute(
|
|
||||||
const psa_key_attributes_t *attributes,
|
|
||||||
const uint8_t *key_buffer,
|
|
||||||
size_t key_buffer_size,
|
|
||||||
psa_algorithm_t alg,
|
|
||||||
const uint8_t *input,
|
|
||||||
size_t input_length,
|
|
||||||
uint8_t *mac,
|
|
||||||
size_t mac_size,
|
|
||||||
size_t *mac_length )
|
|
||||||
{
|
|
||||||
/* One-shot MAC has not been implemented in this PSA implementation yet. */
|
|
||||||
(void) attributes;
|
|
||||||
(void) key_buffer;
|
|
||||||
(void) key_buffer_size;
|
|
||||||
(void) alg;
|
|
||||||
(void) input;
|
|
||||||
(void) input_length;
|
|
||||||
(void) mac;
|
|
||||||
(void) mac_size;
|
|
||||||
(void) mac_length;
|
|
||||||
return( PSA_ERROR_NOT_SUPPORTED );
|
|
||||||
}
|
|
||||||
|
|
||||||
static psa_status_t mac_update(
|
static psa_status_t mac_update(
|
||||||
mbedtls_psa_mac_operation_t *operation,
|
mbedtls_psa_mac_operation_t *operation,
|
||||||
const uint8_t *input,
|
const uint8_t *input,
|
||||||
|
@ -497,6 +473,44 @@ cleanup:
|
||||||
|
|
||||||
return( status );
|
return( status );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static psa_status_t mac_compute(
|
||||||
|
const psa_key_attributes_t *attributes,
|
||||||
|
const uint8_t *key_buffer,
|
||||||
|
size_t key_buffer_size,
|
||||||
|
psa_algorithm_t alg,
|
||||||
|
const uint8_t *input,
|
||||||
|
size_t input_length,
|
||||||
|
uint8_t *mac,
|
||||||
|
size_t mac_size,
|
||||||
|
size_t *mac_length )
|
||||||
|
{
|
||||||
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
|
mbedtls_psa_mac_operation_t operation = MBEDTLS_PSA_MAC_OPERATION_INIT;
|
||||||
|
|
||||||
|
status = mac_setup( &operation,
|
||||||
|
attributes, key_buffer, key_buffer_size,
|
||||||
|
alg );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
if( input_length > 0 )
|
||||||
|
{
|
||||||
|
status = mac_update( &operation, input, input_length );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = mac_finish_internal( &operation, mac, mac_size );
|
||||||
|
if( status == PSA_SUCCESS )
|
||||||
|
*mac_length = mac_size;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mac_abort( &operation );
|
||||||
|
|
||||||
|
return( status );
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BUILTIN_ALG_HMAC || BUILTIN_ALG_CMAC */
|
#endif /* BUILTIN_ALG_HMAC || BUILTIN_ALG_CMAC */
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_BUILTIN_MAC)
|
#if defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||||
|
|
Loading…
Reference in a new issue