mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 06:33:06 +00:00
Improve return code
CORRUPTION_DETECTED should be reserved for cases that are impossible, short of physical corruption during execution or a major bug in the code. We shouldn't use this for the kind of mistakes that can happen during configuration or integration, such as calling a driver on a key type that it doesn't support. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
4f119b8f21
commit
fbea9d2e7d
6
3rdparty/p256-m/p256-m_driver_entrypoints.c
vendored
6
3rdparty/p256-m/p256-m_driver_entrypoints.c
vendored
@ -130,7 +130,7 @@ psa_status_t p256_transparent_export_public_key(const psa_key_attributes_t *attr
|
||||
|
||||
/* Validate sizes, as p256-m expects fixed-size buffers */
|
||||
if (key_buffer_size != PRIVKEY_SIZE) {
|
||||
return PSA_ERROR_CORRUPTION_DETECTED;
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (data_size < PSA_PUBKEY_SIZE) {
|
||||
return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
@ -231,7 +231,7 @@ psa_status_t p256_transparent_sign_hash(
|
||||
|
||||
/* Validate sizes, as p256-m expects fixed-size buffers */
|
||||
if (key_buffer_size != PRIVKEY_SIZE) {
|
||||
return PSA_ERROR_CORRUPTION_DETECTED;
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (signature_size < SIGNATURE_SIZE) {
|
||||
return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
@ -257,7 +257,7 @@ static psa_status_t p256_verify_hash_with_public_key(
|
||||
{
|
||||
/* Validate sizes, as p256-m expects fixed-size buffers */
|
||||
if (key_buffer_size != PSA_PUBKEY_SIZE || *key_buffer != PSA_PUBKEY_HEADER_BYTE) {
|
||||
return PSA_ERROR_CORRUPTION_DETECTED;
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (signature_length != SIGNATURE_SIZE) {
|
||||
return PSA_ERROR_INVALID_SIGNATURE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user