Define handles as key identifiers

Define psa_key_handle_t to be equal to
mbedtls_svc_key_id_t. Make the handle of a persistent
key be equal to its key identifier. For volatile keys,
make the key handle equal to the volatile key
identifier of the created volatile key.

The unit tests are modified just to make them compile
not to make them run successfully. They are fixed in
the subsequent commits.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto_slot_management.h b/library/psa_crypto_slot_management.h
index d649f53..98a1ce7 100644
--- a/library/psa_crypto_slot_management.h
+++ b/library/psa_crypto_slot_management.h
@@ -22,6 +22,7 @@
 #define PSA_CRYPTO_SLOT_MANAGEMENT_H
 
 #include "psa/crypto.h"
+#include "psa_crypto_core.h"
 #include "psa_crypto_se.h"
 
 /* Number of key slots (plus one because 0 is not used).
@@ -45,21 +46,38 @@
  */
 #define PSA_KEY_ID_VOLATILE_MAX  PSA_KEY_ID_VENDOR_MAX
 
-/** Access a key slot at the given handle.
+/** Retrieve the description of a key given its identifier.
  *
- * \param handle        Key handle to query.
+ *  The descriptions of volatile keys and loaded persistent keys are
+ *  stored in key slots. This function returns a pointer to the key slot
+ *  containing the description of a key given its identifier.
+ *
+ *  In case of a persistent key, the function loads the description of the key
+ *  into a key slot if not already done.
+ *
+ * \param key           Key identifier to query.
  * \param[out] p_slot   On success, `*p_slot` contains a pointer to the
- *                      key slot in memory designated by \p handle.
+ *                      key slot containing the description of the key
+ *                      identified by \p key.
  *
- * \retval PSA_SUCCESS
- *         Success: \p handle is a handle to `*p_slot`. Note that `*p_slot`
- *         may be empty or occupied.
- * \retval PSA_ERROR_INVALID_HANDLE
- *         \p handle is out of range or is not in use.
- * \retval PSA_ERROR_BAD_STATE
+ * \retval #PSA_SUCCESS
+ *         The pointer to the key slot containing the description of the key
+ *         identified by \p key was returned.
+ * \retval #PSA_ERROR_BAD_STATE
  *         The library has not been initialized.
+ * \retval #PSA_ERROR_INVALID_HANDLE
+ *         \p key is not a valid key identifier.
+ * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
+ *         \p key is a persistent key identifier. The implementation does not
+ *         have sufficient resources to load the persistent key. This can be
+ *         due to a lack of empty key slot, or available memory.
+ * \retval #PSA_ERROR_DOES_NOT_EXIST
+ *         There is no key with key identifier \p key.
+ * \retval #PSA_ERROR_CORRUPTION_DETECTED
+ * \retval #PSA_ERROR_STORAGE_FAILURE
+ * \retval #PSA_ERROR_DATA_CORRUPT
  */
-psa_status_t psa_get_key_slot( psa_key_handle_t handle,
+psa_status_t psa_get_key_slot( mbedtls_svc_key_id_t key,
                                psa_key_slot_t **p_slot );
 
 /** Initialize the key slot structures.
@@ -79,8 +97,6 @@
  * This function returns a key slot that is available for use and is in its
  * ground state (all-bits-zero).
  *
- * \param[out] handle            On success, a slot number that can be used
- *                               as a handle to the slot.
  * \param[out] volatile_key_id   On success, volatile key identifier
  *                               associated to the returned slot.
  * \param[out] p_slot            On success, a pointer to the slot.
@@ -89,8 +105,7 @@
  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
  * \retval #PSA_ERROR_BAD_STATE
  */
-psa_status_t psa_get_empty_key_slot( psa_key_handle_t *handle,
-                                     psa_key_id_t *volatile_key_id,
+psa_status_t psa_get_empty_key_slot( psa_key_id_t *volatile_key_id,
                                      psa_key_slot_t **p_slot );
 
 /** Test whether a lifetime designates a key in an external cryptoprocessor.