Return CORRUPTION_DETECTED instead of BAD_SLOT when the slot's state is wrong

These error codes are only returned if the program has been tampered with,
so they should be CORRUPTION_DETECTED.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
Ryan Everett 2024-01-12 17:45:05 +00:00
parent 4755e6bda4
commit dfe8bf86a8
6 changed files with 17 additions and 29 deletions

View file

@ -415,9 +415,7 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes);
* \retval #PSA_ERROR_BAD_STATE
* The library has not been previously initialized by psa_crypto_init().
* It is implementation-dependent whether a failure to initialize
* results in this error code. Or,
* this call was operating on a key slot and found the slot in
* an invalid state for the operation.
* results in this error code.
*/
psa_status_t psa_purge_key(mbedtls_svc_key_id_t key);
@ -557,9 +555,7 @@ psa_status_t psa_copy_key(mbedtls_svc_key_id_t source_key,
* \retval #PSA_ERROR_BAD_STATE
* The library has not been previously initialized by psa_crypto_init().
* It is implementation-dependent whether a failure to initialize
* results in this error code. Or,
* this call was operating on a key slot and found the slot in
* an invalid state for the operation.
* results in this error code.
*/
psa_status_t psa_destroy_key(mbedtls_svc_key_id_t key);

View file

@ -142,9 +142,7 @@ psa_status_t psa_open_key(mbedtls_svc_key_id_t key,
* \retval #PSA_ERROR_BAD_STATE
* The library has not been previously initialized by psa_crypto_init().
* It is implementation-dependent whether a failure to initialize
* results in this error code. Or,
* this call was operating on a key slot and found the slot in
* an invalid state for the operation.
* results in this error code.
*/
psa_status_t psa_close_key(psa_key_handle_t handle);