Attest: Introduce PSA error codes
This change addresses the compliance with PSA initial attestation
API 1.0.0 version. It replaces the existing psa_attest_err_t enum
values with the error codes that are detailed in the
interface/include/psa/error.h file.
Change-Id: I1795331e7081589371c82f0e56655db6a543edd3
Signed-off-by: Sverteczky, Marcell <marcell.sverteczky@arm.com>
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/interface/include/psa/initial_attestation.h b/interface/include/psa/initial_attestation.h
index 4dd247b..aa4a414 100644
--- a/interface/include/psa/initial_attestation.h
+++ b/interface/include/psa/initial_attestation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -33,35 +33,6 @@
#define PSA_INITIAL_ATTEST_API_VERSION_MINOR (0)
/**
- * \enum psa_attest_err_t
- *
- * \brief Initial attestation service error types
- *
- */
-enum psa_attest_err_t {
- /** Action was performed successfully */
- PSA_ATTEST_ERR_SUCCESS = 0,
- /** Boot status data is unavailable or malformed */
- PSA_ATTEST_ERR_INIT_FAILED,
- /** Token buffer is too small to store the created token there */
- PSA_ATTEST_ERR_TOKEN_BUFFER_OVERFLOW,
- /** Attestation key buffer is too small to store the obtained key there */
- PSA_ATTEST_ERR_KEY_BUFFER_OVERFLOW,
- /** Some of the mandatory claims are unavailable */
- PSA_ATTEST_ERR_CLAIM_UNAVAILABLE,
- /** Some parameter or combination of parameters are recognised as invalid:
- * - challenge size is not allowed
- * - challenge object is unavailable
- * - token buffer is unavailable
- */
- PSA_ATTEST_ERR_INVALID_INPUT,
- /** Unexpected error happened during operation */
- PSA_ATTEST_ERR_GENERAL,
- /** Following entry is only to ensure the error code of integer size */
- PSA_ATTEST_ERR_FORCE_INT_SIZE = INT_MAX
-};
-
-/**
* The allowed size of input challenge in bytes: 32, 48, 64
* Challenge can be a nonce from server
* or the hash of some combined data : nonce + attested data by caller.
@@ -197,9 +168,9 @@
* updated by initial attestation service with
* final token size.
*
- * \return Returns error code as specified in \ref psa_attest_err_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token(const uint8_t *challenge_obj,
uint32_t challenge_size,
uint8_t *token,
@@ -215,9 +186,9 @@
* \param[out] token_size Size of the token in bytes, which is created by
* initial attestation service.
*
- * \return Returns error code as specified in \ref psa_attest_err_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token_size(uint32_t challenge_size,
uint32_t *token_size);
@@ -233,9 +204,9 @@
*
* \note Currently only the ECDSA P-256 over SHA-256 algorithm is supported.
*
- * \return Returns error code as specified in \ref psa_attest_err_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-enum psa_attest_err_t
+psa_status_t
tfm_initial_attest_get_public_key(uint8_t *public_key,
size_t public_key_buf_size,
size_t *public_key_len,
diff --git a/interface/src/tfm_initial_attestation_func_api.c b/interface/src/tfm_initial_attestation_func_api.c
index 7292df5..cf82498 100644
--- a/interface/src/tfm_initial_attestation_func_api.c
+++ b/interface/src/tfm_initial_attestation_func_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -13,7 +13,7 @@
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token(const uint8_t *challenge_obj,
uint32_t challenge_size,
uint8_t *token,
@@ -34,14 +34,14 @@
(uint32_t)in_vec, IOVEC_LEN(in_vec),
(uint32_t)out_vec, IOVEC_LEN(out_vec));
- if (res == (int32_t)PSA_ATTEST_ERR_SUCCESS) {
+ if (res == (int32_t)PSA_SUCCESS) {
*token_size = out_vec[0].len;
}
- return (enum psa_attest_err_t)res;
+ return res;
}
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token_size(uint32_t challenge_size,
uint32_t *token_size)
{
@@ -52,13 +52,13 @@
{token_size, sizeof(uint32_t)}
};
- return (enum psa_attest_err_t)tfm_ns_interface_dispatch(
+ return tfm_ns_interface_dispatch(
(veneer_fn)tfm_initial_attest_get_token_size_veneer,
(uint32_t)in_vec, IOVEC_LEN(in_vec),
(uint32_t)out_vec, IOVEC_LEN(out_vec));
}
-enum psa_attest_err_t
+psa_status_t
tfm_initial_attest_get_public_key(uint8_t *public_key,
size_t public_key_buf_size,
size_t *public_key_len,
@@ -77,5 +77,5 @@
(uint32_t)NULL, 0,
(uint32_t)out_vec, IOVEC_LEN(out_vec));
- return (enum psa_attest_err_t)res;
+ return (psa_status_t) res;
}
diff --git a/interface/src/tfm_initial_attestation_ipc_api.c b/interface/src/tfm_initial_attestation_ipc_api.c
index ed9264f..c60f8bd 100644
--- a/interface/src/tfm_initial_attestation_ipc_api.c
+++ b/interface/src/tfm_initial_attestation_ipc_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -14,7 +14,7 @@
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token(const uint8_t *challenge_obj,
uint32_t challenge_size,
uint8_t *token,
@@ -32,8 +32,8 @@
handle = psa_connect(TFM_ATTEST_GET_TOKEN_SID,
TFM_ATTEST_GET_TOKEN_VERSION);
- if (handle <= 0) {
- return PSA_ATTEST_ERR_GENERAL;
+ if (!PSA_HANDLE_IS_VALID(handle)) {
+ return PSA_HANDLE_TO_ERROR(handle);
}
status = psa_call(handle, PSA_IPC_CALL,
@@ -41,18 +41,14 @@
out_vec, IOVEC_LEN(out_vec));
psa_close(handle);
- if (status < PSA_SUCCESS) {
- return PSA_ATTEST_ERR_GENERAL;
- }
-
if (status == PSA_SUCCESS) {
*token_size = out_vec[0].len;
}
- return (enum psa_attest_err_t)status;
+ return status;
}
-enum psa_attest_err_t
+psa_status_t
psa_initial_attest_get_token_size(uint32_t challenge_size,
uint32_t *token_size)
{
@@ -67,8 +63,8 @@
handle = psa_connect(TFM_ATTEST_GET_TOKEN_SIZE_SID,
TFM_ATTEST_GET_TOKEN_SIZE_VERSION);
- if (handle <= 0) {
- return PSA_ATTEST_ERR_GENERAL;
+ if (!PSA_HANDLE_IS_VALID(handle)) {
+ return PSA_HANDLE_TO_ERROR(handle);
}
status = psa_call(handle, PSA_IPC_CALL,
@@ -76,14 +72,10 @@
out_vec, IOVEC_LEN(out_vec));
psa_close(handle);
- if (status < PSA_SUCCESS) {
- return PSA_ATTEST_ERR_GENERAL;
- }
-
- return (enum psa_attest_err_t)status;
+ return status;
}
-enum psa_attest_err_t
+psa_status_t
tfm_initial_attest_get_public_key(uint8_t *public_key,
size_t public_key_buf_size,
size_t *public_key_len,
@@ -101,7 +93,7 @@
handle = psa_connect(TFM_ATTEST_GET_PUBLIC_KEY_SID,
TFM_ATTEST_GET_PUBLIC_KEY_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_ATTEST_ERR_GENERAL;
+ return PSA_HANDLE_TO_ERROR(handle);
}
status = psa_call(handle, PSA_IPC_CALL,
@@ -109,5 +101,5 @@
out_vec, IOVEC_LEN(out_vec));
psa_close(handle);
- return (enum psa_attest_err_t)status;
+ return status;
}