Don't return internal error codes #331

Open
opened 2025-06-24 06:45:09 -05:00 by gilles-peskine-arm · 0 comments
gilles-peskine-arm commented 2025-06-24 06:45:09 -05:00 (Migrated from github.com)

Some functions return error codes that are defined in a private header.

git grep '#define MBEDTLS_ERR_' drivers

These error codes aren't public, so users can't catch these errors specifically, they can only use the negative-return-code catch-all.

We should never return such errors from library functions.

What to do will depend on the error code. Some of them should be unified with the PSA error code for the same condition (e.g. #define MBEDTLS_ERR_GCM_AUTH_FAILED PSA_ERROR_INVALID_SIGNATURE). Others may be made public, if they're truly a different error conditions. Others may just disappear when the legacy module that raises them is refactored or removed.

Some functions return error codes that are defined in a private header. ``` git grep '#define MBEDTLS_ERR_' drivers ``` These error codes aren't public, so users can't catch these errors specifically, they can only use the negative-return-code catch-all. We should never return such errors from library functions. What to do will depend on the error code. Some of them should be unified with the PSA error code for the same condition (e.g. `#define MBEDTLS_ERR_GCM_AUTH_FAILED PSA_ERROR_INVALID_SIGNATURE`). Others may be made public, if they're truly a different error conditions. Others may just disappear when the legacy module that raises them is refactored or removed.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto#331
No description provided.