blob: c5c418872c637999aca52af230fcccede6ff6197 [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"
Summer Qind0f42b12020-06-24 16:19:23 +080010#include "service_api.h"
Tamas Banc3c08492020-08-27 10:15:42 +010011#include "attest.h"
Jamie Foxcc31d402019-01-28 17:13:52 +000012#include "psa/initial_attestation.h"
Mingyang Sun8a19e7a2020-06-04 15:36:58 +080013#include "tfm_boot_status.h"
Tamas Band2b2f092019-01-23 22:29:14 +000014
Kevin Peng2ed30222019-04-30 09:26:11 +080015#ifdef TFM_PSA_API
16extern int32_t g_attest_caller_id;
17#endif
18
Tamas Band2b2f092019-01-23 22:29:14 +000019enum psa_attest_err_t
Tamas Band2b2f092019-01-23 22:29:14 +000020attest_get_caller_client_id(int32_t *caller_id)
21{
Tamas Band2b2f092019-01-23 22:29:14 +000022 enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
Kevin Peng2ed30222019-04-30 09:26:11 +080023#ifndef TFM_PSA_API
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010024 int32_t tfm_res;
Tamas Band2b2f092019-01-23 22:29:14 +000025
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010026 tfm_res = tfm_core_get_caller_client_id(caller_id);
Tamas Band2b2f092019-01-23 22:29:14 +000027 if (tfm_res) {
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010028 attest_res = PSA_ATTEST_ERR_CLAIM_UNAVAILABLE;
29 }
Kevin Peng2ed30222019-04-30 09:26:11 +080030#else
31 *caller_id = g_attest_caller_id;
32#endif
Tamas Band2b2f092019-01-23 22:29:14 +000033
34 return attest_res;
35}
36
37enum psa_attest_err_t
Tamas Bana24ce042019-02-20 11:50:22 +000038attest_get_boot_data(uint8_t major_type,
39 struct tfm_boot_data *boot_data,
40 uint32_t len)
Tamas Band2b2f092019-01-23 22:29:14 +000041{
Tamas Band2b2f092019-01-23 22:29:14 +000042 enum psa_attest_err_t attest_res = PSA_ATTEST_ERR_SUCCESS;
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010043 int32_t tfm_res;
Tamas Banca682b22019-01-29 22:03:43 +000044
Tamas Bana24ce042019-02-20 11:50:22 +000045 tfm_res = tfm_core_get_boot_data(major_type, boot_data, len);
Hugues de Valonba1fa9a2019-06-18 16:12:54 +010046 if (tfm_res != (int32_t)TFM_SUCCESS) {
Tamas Band2b2f092019-01-23 22:29:14 +000047 attest_res = PSA_ATTEST_ERR_INIT_FAILED;
48 }
Tamas Band2b2f092019-01-23 22:29:14 +000049
50 return attest_res;
51}