mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 15:51:21 +00:00
Rename psa_mac_{finish,verify} -> psa_mac_{sign,verify}_finish
Make function names for multipart operations more consistent (MAC finish edition).
This commit is contained in:
parent
da8191d1cd
commit
acd4be36fa
|
@ -1345,8 +1345,8 @@ typedef struct psa_mac_operation_s psa_mac_operation_t;
|
||||||
* -# Call psa_mac_update() zero, one or more times, passing a fragment
|
* -# Call psa_mac_update() zero, one or more times, passing a fragment
|
||||||
* of the message each time. The MAC that is calculated is the MAC
|
* of the message each time. The MAC that is calculated is the MAC
|
||||||
* of the concatenation of these messages in order.
|
* of the concatenation of these messages in order.
|
||||||
* -# To calculate the MAC, call psa_mac_finish().
|
* -# To calculate the MAC, call psa_mac_sign_finish().
|
||||||
* To compare the MAC with an expected value, call psa_mac_verify().
|
* To compare the MAC with an expected value, call psa_mac_verify_finish().
|
||||||
*
|
*
|
||||||
* The application may call psa_mac_abort() at any time after the operation
|
* The application may call psa_mac_abort() at any time after the operation
|
||||||
* has been initialized with psa_mac_start().
|
* has been initialized with psa_mac_start().
|
||||||
|
@ -1355,7 +1355,8 @@ typedef struct psa_mac_operation_s psa_mac_operation_t;
|
||||||
* eventually terminate the operation. The following events terminate an
|
* eventually terminate the operation. The following events terminate an
|
||||||
* operation:
|
* operation:
|
||||||
* - A failed call to psa_mac_update().
|
* - A failed call to psa_mac_update().
|
||||||
* - A call to psa_mac_finish(), psa_mac_verify() or psa_mac_abort().
|
* - A call to psa_mac_sign_finish(), psa_mac_verify_finish() or
|
||||||
|
* psa_mac_abort().
|
||||||
*
|
*
|
||||||
* \param operation The operation object to use.
|
* \param operation The operation object to use.
|
||||||
* \param key Slot containing the key to use for the operation.
|
* \param key Slot containing the key to use for the operation.
|
||||||
|
@ -1383,12 +1384,12 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation,
|
||||||
const uint8_t *input,
|
const uint8_t *input,
|
||||||
size_t input_length);
|
size_t input_length);
|
||||||
|
|
||||||
psa_status_t psa_mac_finish(psa_mac_operation_t *operation,
|
psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
|
||||||
uint8_t *mac,
|
uint8_t *mac,
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length);
|
size_t *mac_length);
|
||||||
|
|
||||||
psa_status_t psa_mac_verify(psa_mac_operation_t *operation,
|
psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
|
||||||
const uint8_t *mac,
|
const uint8_t *mac,
|
||||||
size_t mac_length);
|
size_t mac_length);
|
||||||
|
|
||||||
|
|
|
@ -142,9 +142,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The size of the output of psa_mac_finish(), in bytes.
|
/** The size of the output of psa_mac_sign_finish(), in bytes.
|
||||||
*
|
*
|
||||||
* This is also the MAC size that psa_mac_verify() expects.
|
* This is also the MAC size that psa_mac_verify_finish() expects.
|
||||||
*
|
*
|
||||||
* \param key_type The type of the MAC key.
|
* \param key_type The type of the MAC key.
|
||||||
* \param key_bits The size of the MAC key in bits.
|
* \param key_bits The size of the MAC key in bits.
|
||||||
|
|
|
@ -1483,8 +1483,8 @@ psa_status_t psa_mac_start( psa_mac_operation_t *operation,
|
||||||
/* Since this function is called identically for a sign or verify
|
/* Since this function is called identically for a sign or verify
|
||||||
* operation, we don't know yet whether the operation is permitted.
|
* operation, we don't know yet whether the operation is permitted.
|
||||||
* Store the part of the key policy that we can't check in the
|
* Store the part of the key policy that we can't check in the
|
||||||
* operation structure. psa_mac_finish() or psa_mac_verify() will
|
* operation structure. psa_mac_sign_finish() or psa_mac_verify_finish()
|
||||||
* check that remaining part. */
|
* will check that remaining part. */
|
||||||
if( ( slot->policy.usage & PSA_KEY_USAGE_SIGN ) != 0 )
|
if( ( slot->policy.usage & PSA_KEY_USAGE_SIGN ) != 0 )
|
||||||
operation->key_usage_sign = 1;
|
operation->key_usage_sign = 1;
|
||||||
if( ( slot->policy.usage & PSA_KEY_USAGE_VERIFY ) != 0 )
|
if( ( slot->policy.usage & PSA_KEY_USAGE_VERIFY ) != 0 )
|
||||||
|
@ -1671,7 +1671,7 @@ cleanup:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_mac_finish( psa_mac_operation_t *operation,
|
psa_status_t psa_mac_sign_finish( psa_mac_operation_t *operation,
|
||||||
uint8_t *mac,
|
uint8_t *mac,
|
||||||
size_t mac_size,
|
size_t mac_size,
|
||||||
size_t *mac_length )
|
size_t *mac_length )
|
||||||
|
@ -1683,7 +1683,7 @@ psa_status_t psa_mac_finish( psa_mac_operation_t *operation,
|
||||||
mac_size, mac_length ) );
|
mac_size, mac_length ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t psa_mac_verify( psa_mac_operation_t *operation,
|
psa_status_t psa_mac_verify_finish( psa_mac_operation_t *operation,
|
||||||
const uint8_t *mac,
|
const uint8_t *mac,
|
||||||
size_t mac_length )
|
size_t mac_length )
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,7 +141,7 @@ static int exercise_mac_key( psa_key_slot_t key,
|
||||||
TEST_ASSERT( psa_mac_start( &operation, key, alg ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_mac_start( &operation, key, alg ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_update( &operation,
|
TEST_ASSERT( psa_mac_update( &operation,
|
||||||
input, sizeof( input ) ) == PSA_SUCCESS );
|
input, sizeof( input ) ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_finish( &operation,
|
TEST_ASSERT( psa_mac_sign_finish( &operation,
|
||||||
mac, sizeof( input ),
|
mac, sizeof( input ),
|
||||||
&mac_length ) == PSA_SUCCESS );
|
&mac_length ) == PSA_SUCCESS );
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,9 @@ static int exercise_mac_key( psa_key_slot_t key,
|
||||||
TEST_ASSERT( psa_mac_start( &operation, key, alg ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_mac_start( &operation, key, alg ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_update( &operation,
|
TEST_ASSERT( psa_mac_update( &operation,
|
||||||
input, sizeof( input ) ) == PSA_SUCCESS );
|
input, sizeof( input ) ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_verify( &operation, mac, mac_length ) == verify_status );
|
TEST_ASSERT( psa_mac_verify_finish( &operation,
|
||||||
|
mac,
|
||||||
|
mac_length ) == verify_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 1 );
|
return( 1 );
|
||||||
|
@ -747,7 +749,7 @@ void mac_key_policy( int policy_usage,
|
||||||
|
|
||||||
status = psa_mac_start( &operation, key_slot, exercise_alg );
|
status = psa_mac_start( &operation, key_slot, exercise_alg );
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
status = psa_mac_finish( &operation,
|
status = psa_mac_sign_finish( &operation,
|
||||||
mac, sizeof( mac ), &output_length );
|
mac, sizeof( mac ), &output_length );
|
||||||
if( policy_alg == exercise_alg &&
|
if( policy_alg == exercise_alg &&
|
||||||
( policy_usage & PSA_KEY_USAGE_SIGN ) != 0 )
|
( policy_usage & PSA_KEY_USAGE_SIGN ) != 0 )
|
||||||
|
@ -759,7 +761,7 @@ void mac_key_policy( int policy_usage,
|
||||||
memset( mac, 0, sizeof( mac ) );
|
memset( mac, 0, sizeof( mac ) );
|
||||||
status = psa_mac_start( &operation, key_slot, exercise_alg );
|
status = psa_mac_start( &operation, key_slot, exercise_alg );
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
status = psa_mac_verify( &operation, mac, sizeof( mac ) );
|
status = psa_mac_verify_finish( &operation, mac, sizeof( mac ) );
|
||||||
if( policy_alg == exercise_alg &&
|
if( policy_alg == exercise_alg &&
|
||||||
( policy_usage & PSA_KEY_USAGE_VERIFY ) != 0 )
|
( policy_usage & PSA_KEY_USAGE_VERIFY ) != 0 )
|
||||||
TEST_ASSERT( status == PSA_ERROR_INVALID_SIGNATURE );
|
TEST_ASSERT( status == PSA_ERROR_INVALID_SIGNATURE );
|
||||||
|
@ -1198,7 +1200,7 @@ void mac_verify( int key_type_arg,
|
||||||
TEST_ASSERT( psa_destroy_key( key_slot ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_destroy_key( key_slot ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_update( &operation,
|
TEST_ASSERT( psa_mac_update( &operation,
|
||||||
input->x, input->len ) == PSA_SUCCESS );
|
input->x, input->len ) == PSA_SUCCESS );
|
||||||
TEST_ASSERT( psa_mac_verify( &operation,
|
TEST_ASSERT( psa_mac_verify_finish( &operation,
|
||||||
expected_mac->x,
|
expected_mac->x,
|
||||||
expected_mac->len ) == PSA_SUCCESS );
|
expected_mac->len ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue