blob: 0ac143a1e5078f17e3f20be523deb2a6a9082040 [file] [log] [blame]
Tamas Band2b2f092019-01-23 22:29:14 +00001/*
David Vinczee13a48b2020-01-08 17:42:30 +01002 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Tamas Band2b2f092019-01-23 22:29:14 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include "tfm_api.h"
9#include "tfm_secure_api.h"
10#include "attestation.h"
Jamie Foxcc31d402019-01-28 17:13:52 +000011#include "psa/initial_attestation.h"
Mingyang Sun8a19e7a2020-06-04 15:36:58 +080012#include "tfm_boot_status.h"
Tamas Band2b2f092019-01-23 22:29:14 +000013
Kevin Peng2ed30222019-04-30 09:26:11 +080014#ifdef TFM_PSA_API
15extern int32_t g_attest_caller_id;
16#endif
17
Tamas Band2b2f092019-01-23 22:29:14 +000018enum psa_attest_err_t
Tamas Band2b2f092019-01-23 22:29:14 +000019attest_get_caller_client_id(int32_t *caller_id)
20{
Tamas Band2b2f092019-01-23 22:29:14 +000021 enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
Kevin Peng2ed30222019-04-30 09:26:11 +080022#ifndef TFM_PSA_API
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010023 int32_t tfm_res;
Tamas Band2b2f092019-01-23 22:29:14 +000024
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010025 tfm_res = tfm_core_get_caller_client_id(caller_id);
Tamas Band2b2f092019-01-23 22:29:14 +000026 if (tfm_res) {
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010027 attest_res = PSA_ATTEST_ERR_CLAIM_UNAVAILABLE;
28 }
Kevin Peng2ed30222019-04-30 09:26:11 +080029#else
30 *caller_id = g_attest_caller_id;
31#endif
Tamas Band2b2f092019-01-23 22:29:14 +000032
33 return attest_res;
34}
35
36enum psa_attest_err_t
Tamas Bana24ce042019-02-20 11:50:22 +000037attest_get_boot_data(uint8_t major_type,
38 struct tfm_boot_data *boot_data,
39 uint32_t len)
Tamas Band2b2f092019-01-23 22:29:14 +000040{
Tamas Band2b2f092019-01-23 22:29:14 +000041 enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010042 int32_t tfm_res;
Tamas Banca682b22019-01-29 22:03:43 +000043
Tamas Bana24ce042019-02-20 11:50:22 +000044 tfm_res = tfm_core_get_boot_data(major_type, boot_data, len);
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010045 if (tfm_res != (int32_t)TFM_SUCCESS) {
Tamas Band2b2f092019-01-23 22:29:14 +000046 attest_res = PSA_ATTEST_ERR_INIT_FAILED;
47 }
Tamas Band2b2f092019-01-23 22:29:14 +000048
49 return attest_res;
50}