Skip to content

Commit 643ec31

Browse files
committed
drivers: pk: add new error code for signature failure
Now that "pk_[sign|verify]_ext()" work the same for all PK context types it doesn't make sense to translate "PSA_ERROR_INVALID_SIGNATURE" to "MBEDTLS_ERR_RSA_VERIFY_FAILED". Besides this translation is only available when RSA key types are defined, which is not always true. For this reason this commit introduces a more generic "MBEDTLS_ERR_PK_INVALID_SIGNATURE" which is valid for any PK context handled by PK module. The translation is trivially to "PSA_ERROR_INVALID_SIGNATURE" of course. Signed-off-by: Valerio Setti <vsetti@baylibre.com>
1 parent 0f314dc commit 643ec31

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/builtin/src/psa_util_internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ int psa_pk_status_to_mbedtls(psa_status_t status)
145145
return MBEDTLS_ERR_PK_ALLOC_FAILED;
146146
case PSA_ERROR_BAD_STATE:
147147
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
148+
case PSA_ERROR_INVALID_SIGNATURE:
149+
return MBEDTLS_ERR_PK_INVALID_SIGNATURE;
148150
case PSA_ERROR_DATA_CORRUPT:
149151
case PSA_ERROR_DATA_INVALID:
150152
case PSA_ERROR_STORAGE_FAILURE:

include/mbedtls/pk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00
4242
/** Unavailable feature, e.g. RSA disabled for RSA key. */
4343
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980
44+
/** Invalid signature */
45+
#define MBEDTLS_ERR_PK_INVALID_SIGNATURE PSA_ERROR_INVALID_SIGNATURE
4446

4547
#ifdef __cplusplus
4648
extern "C" {

0 commit comments

Comments
 (0)