mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-15 23:42:41 +00:00
Implement buffer copy code in psa_hash_compare
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
31d8c0bdb4
commit
51ffac9f40
@ -2493,17 +2493,23 @@ exit:
|
||||
}
|
||||
|
||||
psa_status_t psa_hash_compare(psa_algorithm_t alg,
|
||||
const uint8_t *input, size_t input_length,
|
||||
const uint8_t *hash, size_t hash_length)
|
||||
const uint8_t *input_external, size_t input_length,
|
||||
const uint8_t *hash_external, size_t hash_length)
|
||||
{
|
||||
uint8_t actual_hash[PSA_HASH_MAX_SIZE];
|
||||
size_t actual_hash_length;
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
LOCAL_INPUT_DECLARE(input_external, input);
|
||||
LOCAL_INPUT_DECLARE(hash_external, hash);
|
||||
|
||||
if (!PSA_ALG_IS_HASH(alg)) {
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
return status;
|
||||
}
|
||||
|
||||
psa_status_t status = psa_driver_wrapper_hash_compute(
|
||||
LOCAL_INPUT_ALLOC(input_external, input_length, input);
|
||||
status = psa_driver_wrapper_hash_compute(
|
||||
alg, input, input_length,
|
||||
actual_hash, sizeof(actual_hash),
|
||||
&actual_hash_length);
|
||||
@ -2514,12 +2520,18 @@ psa_status_t psa_hash_compare(psa_algorithm_t alg,
|
||||
status = PSA_ERROR_INVALID_SIGNATURE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
LOCAL_INPUT_ALLOC(hash_external, hash_length, hash);
|
||||
if (mbedtls_ct_memcmp(hash, actual_hash, actual_hash_length) != 0) {
|
||||
status = PSA_ERROR_INVALID_SIGNATURE;
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_platform_zeroize(actual_hash, sizeof(actual_hash));
|
||||
|
||||
LOCAL_INPUT_FREE(input_external, input);
|
||||
LOCAL_INPUT_FREE(hash_external, hash);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user