From fbea9d2e7d004dfdd5f457d9a3f0d8d6581f4405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 20 Sep 2023 09:22:29 +0200 Subject: [PATCH] Improve return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 3rdparty/p256-m/p256-m_driver_entrypoints.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3rdparty/p256-m/p256-m_driver_entrypoints.c b/3rdparty/p256-m/p256-m_driver_entrypoints.c index 0ca5583c9a..b75c06c669 100644 --- a/3rdparty/p256-m/p256-m_driver_entrypoints.c +++ b/3rdparty/p256-m/p256-m_driver_entrypoints.c @@ -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;