Function esp_idf_svc::hal::sys::psa_destroy_key
source ยท pub unsafe extern "C" fn psa_destroy_key(key: u32) -> i32
Expand description
\brief Destroy a key.
This function destroys a key from both volatile memory and, if applicable, non-volatile storage. Implementations shall make a best effort to ensure that the key material cannot be recovered.
This function also erases any metadata such as policies and frees resources associated with the key.
If a key is currently in use in a multipart operation, then destroying the key will cause the multipart operation to fail.
\warning We can only guarantee that the the key material will eventually be wiped from memory. With threading enabled and during concurrent execution, copies of the key material may still exist until all threads have finished using the key.
\param key Identifier of the key to erase. If this is \c 0, do nothing and return #PSA_SUCCESS.
\retval #PSA_SUCCESS \p key was a valid identifier and the key material that it referred to has been erased. Alternatively, \p key is \c 0. \retval #PSA_ERROR_NOT_PERMITTED The key cannot be erased because it is read-only, either due to a policy or due to physical restrictions. \retval #PSA_ERROR_INVALID_HANDLE \p key is not a valid identifier nor \c 0. \retval #PSA_ERROR_COMMUNICATION_FAILURE There was a failure in communication with the cryptoprocessor. The key material may still be present in the cryptoprocessor. \retval #PSA_ERROR_DATA_INVALID This error is typically a result of either storage corruption on a cleartext storage backend, or an attempt to read data that was written by an incompatible version of the library. \retval #PSA_ERROR_STORAGE_FAILURE The storage is corrupted. Implementations shall make a best effort to erase key material even in this stage, however applications should be aware that it may be impossible to guarantee that the key material is not recoverable in such cases. \retval #PSA_ERROR_CORRUPTION_DETECTED An unexpected condition which is not a storage corruption or a communication failure occurred. The cryptoprocessor may have been compromised. \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.