1 /*
2 * Copyright (c) 2022, Arm Ltd. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <stdarg.h>
8 #include <stdbool.h>
9 #include <stdio.h>
10
11 #include <delegated_attestation.h>
12 #include <measured_boot.h>
13 #include <psa/error.h>
14
15
16 psa_status_t
tfm_measured_boot_extend_measurement(uint8_t index,const uint8_t * signer_id,size_t signer_id_size,const uint8_t * version,size_t version_size,uint32_t measurement_algo,const uint8_t * sw_type,size_t sw_type_size,const uint8_t * measurement_value,size_t measurement_value_size,bool lock_measurement)17 tfm_measured_boot_extend_measurement(uint8_t index,
18 const uint8_t *signer_id,
19 size_t signer_id_size,
20 const uint8_t *version,
21 size_t version_size,
22 uint32_t measurement_algo,
23 const uint8_t *sw_type,
24 size_t sw_type_size,
25 const uint8_t *measurement_value,
26 size_t measurement_value_size,
27 bool lock_measurement)
28 {
29 return rss_measured_boot_extend_measurement(index,
30 signer_id,
31 signer_id_size,
32 version,
33 version_size,
34 measurement_algo,
35 sw_type,
36 sw_type_size,
37 measurement_value,
38 measurement_value_size,
39 lock_measurement);
40 }
41
42 psa_status_t
tfm_measured_boot_read_measurement(uint8_t index,uint8_t * signer_id,size_t signer_id_size,size_t * signer_id_len,uint8_t * version,size_t version_size,size_t * version_len,uint32_t * measurement_algo,uint8_t * sw_type,size_t sw_type_size,size_t * sw_type_len,uint8_t * measurement_value,size_t measurement_value_size,size_t * measurement_value_len,bool * is_locked)43 tfm_measured_boot_read_measurement(uint8_t index,
44 uint8_t *signer_id,
45 size_t signer_id_size,
46 size_t *signer_id_len,
47 uint8_t *version,
48 size_t version_size,
49 size_t *version_len,
50 uint32_t *measurement_algo,
51 uint8_t *sw_type,
52 size_t sw_type_size,
53 size_t *sw_type_len,
54 uint8_t *measurement_value,
55 size_t measurement_value_size,
56 size_t *measurement_value_len,
57 bool *is_locked)
58 {
59 return rss_measured_boot_read_measurement(index,
60 signer_id,
61 signer_id_size,
62 signer_id_len,
63 version,
64 version_size,
65 version_len,
66 measurement_algo,
67 sw_type,
68 sw_type_size,
69 sw_type_len,
70 measurement_value,
71 measurement_value_size,
72 measurement_value_len,
73 is_locked);
74 }
75
76 psa_status_t
tfm_delegated_attest_get_token(const uint8_t * dak_pub_hash,size_t dak_pub_hash_size,uint8_t * token_buf,size_t token_buf_size,size_t * token_size)77 tfm_delegated_attest_get_token(const uint8_t *dak_pub_hash,
78 size_t dak_pub_hash_size,
79 uint8_t *token_buf,
80 size_t token_buf_size,
81 size_t *token_size)
82 {
83 return rss_delegated_attest_get_token(dak_pub_hash,
84 dak_pub_hash_size,
85 token_buf,
86 token_buf_size,
87 token_size);
88 }
89
90 psa_status_t
tfm_delegated_attest_get_delegated_key(uint8_t ecc_curve,uint32_t key_bits,uint8_t * key_buf,size_t key_buf_size,size_t * key_size,uint32_t hash_algo)91 tfm_delegated_attest_get_delegated_key(uint8_t ecc_curve,
92 uint32_t key_bits,
93 uint8_t *key_buf,
94 size_t key_buf_size,
95 size_t *key_size,
96 uint32_t hash_algo)
97 {
98 return rss_delegated_attest_get_delegated_key(ecc_curve,
99 key_bits,
100 key_buf,
101 key_buf_size,
102 key_size,
103 hash_algo);
104 }
105
tfm_log_printf(const char * fmt,...)106 int tfm_log_printf(const char *fmt, ...)
107 {
108 int count;
109 va_list ap;
110
111 va_start(ap, fmt);
112 count = vprintf(fmt, ap);
113 va_end(ap);
114
115 return count;
116 }
117
printf_set_color(int color_id)118 void printf_set_color(int color_id)
119 {
120 (void)color_id;
121 }
122