tpm2-tss 4.1.0
TPM Software stack 2.0 TCG spec compliant implementation
ifapi_helpers.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*******************************************************************************
3 * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4 * All rights reserved.
5 *******************************************************************************/
6#ifndef IFAPI_HELPERS_H
7#define IFAPI_HELPERS_H
8
9#include <stdint.h>
10#include <stdarg.h>
11#include <stdbool.h>
12#include <sys/stat.h>
13#include <json-c/json.h>
14#include <json-c/json_util.h>
15
16#include "tss2_esys.h"
17#include "tss2_fapi.h"
18#include "fapi_int.h"
19
22typedef struct {
23 TPMI_ALG_HASH bank;
24 TPM2_HANDLE pcr;
25 TPM2B_DIGEST value;
27
28
29TSS2_RC
30ifapi_create_dirs(const char *supdir, const char *path);
31
32TSS2_RC
33ifapi_set_key_flags(const char *type, bool policy, IFAPI_KEY_TEMPLATE *template);
34
35TSS2_RC
36ifapi_set_nv_flags(const char *type, IFAPI_NV_TEMPLATE *template,
37 const char *policy);
38
39bool
40ifapi_path_type_p(const char *path, const char *type);
41
42ESYS_TR
43ifapi_get_hierary_handle(const char *path);
44
45bool
46ifapi_null_primary_p(const char *path);
47
48bool
49ifapi_hierarchy_path_p(const char *path);
50
51bool
52ifapi_TPMT_PUBLIC_cmp(TPMT_PUBLIC *in1, TPMT_PUBLIC *in2);
53
54void
55ifapi_init_hierarchy_object(
56 IFAPI_OBJECT *hierarchy,
57 ESYS_TR esys_handle);
58
59TSS2_RC
60ifapi_set_name_hierarchy_object(
61 IFAPI_OBJECT *hierarchy);
62
63char *
64get_description(IFAPI_OBJECT *object);
65
66size_t
67ifapi_path_length(NODE_STR_T *node);
68
69void
70ifapi_free_object_list(NODE_OBJECT_T *node);
71
72void
73ifapi_free_node_list(NODE_OBJECT_T *node);
74
75TSS2_RC
76ifapi_path_string(char **dest, const char *supdir, NODE_STR_T *node, char *name);
77
78TSS2_RC
79ifapi_path_string_n(
80 char **dest,
81 const char *supdir,
82 NODE_STR_T *node,
83 char *name,
84 size_t n);
85
86TSS2_RC
87ifapi_asprintf(char **str, const char *fmt, ...);
88
90split_string(const char *string, char *delimiter);
91
93init_string_list(const char *string);
94
95bool
96add_string_to_list(NODE_STR_T *str_list, char *string);
97
98void
99free_string_list(NODE_STR_T *node);
100
101void
102ifapi_cleanup_policy(
103 TPMS_POLICY *policy);
104
106ifapi_copy_policy(
107 const TPMS_POLICY *from_policy);
108
109TSS2_RC
110ifapi_get_name(
111 TPMT_PUBLIC *publicInfo,
112 TPM2B_NAME *name);
113
114TSS2_RC
115ifapi_nv_get_name(
116 TPMS_NV_PUBLIC *publicInfo,
117 TPM2B_NAME *name);
118
119TSS2_RC
120ifapi_object_cmp_name(
121 IFAPI_OBJECT *object,
122 void *name,
123 bool *equal);
124
125TSS2_RC
126ifapi_object_cmp_nv_public(
127 IFAPI_OBJECT *object,
128 void *nv_public,
129 bool *equal);
130
131TSS2_RC
132ifapi_tpm_to_fapi_signature(
133 IFAPI_OBJECT *sig_key_object,
134 TPMT_SIGNATURE *tpm_signature,
135 uint8_t **signature,
136 size_t *signatureSize);
137
138TSS2_RC
139ifapi_compute_quote_info(
140 IFAPI_OBJECT *sig_key_object,
141 TPM2B_ATTEST *tpm_quoted,
142 FAPI_QUOTE_INFO *fapi_quote_info,
143 char **quoteInfo);
144
145TSS2_RC
146ifapi_get_quote_info(
147 char const *quoteInfo,
148 TPM2B_ATTEST *tpm_quoted,
149 FAPI_QUOTE_INFO *fapi_quote_ingo);
150
151TSS2_RC
152push_object_to_list(void *object, NODE_OBJECT_T **object_list);
153
154TSS2_RC
155append_object_to_list(void *object, NODE_OBJECT_T **object_list);
156
157bool
158object_with_auth(IFAPI_OBJECT *object);
159
160TSS2_RC
161ifapi_get_nv_start_index(const char *path, TPM2_HANDLE *start_nv_index);
162
163TSS2_RC
164ifapi_check_nv_index(const char *path, TPM2_HANDLE nv_index);
165
166TSS2_RC
167ifapi_check_profile_pcr_selection(
168 const TPML_PCR_SELECTION *pcr_profile,
169 const TPML_PCR_SELECTION *pcr_capablity);
170
171TSS2_RC
172ifapi_filter_pcr_selection_by_index(
173 TPML_PCR_SELECTION *pcr_selection,
174 const TPM2_HANDLE *pcr_index,
175 size_t pcr_count);
176
177TSS2_RC
178ifapi_calculate_pcrs(
179 json_object *jso_event_list,
180 const TPML_PCR_SELECTION *pcr_selection,
181 TPMI_ALG_HASH pcr_digest_hash_alg,
182 const TPM2B_DIGEST *quote_digest,
183 IFAPI_PCR_REG *pcrs);
184
185TSS2_RC ifapi_calculate_pcr_digest(
186 json_object *jso_event_list,
187 const FAPI_QUOTE_INFO *quote_info);
188
189TSS2_RC
190ifapi_compute_policy_digest(
191 TPML_PCRVALUES *pcrs,
192 TPML_PCR_SELECTION *pcr_selection,
193 TPMI_ALG_HASH hash_alg,
194 TPM2B_DIGEST *pcr_digest);
195
196bool
197ifapi_cmp_public_key(
198 TPM2B_PUBLIC *key1,
199 TPM2B_PUBLIC *key2);
200
201void
202ifapi_check_json_object_fields(
203 json_object *jso,
204 char** field_tab,
205 size_t size_of_tab);
206
207TSS2_RC
208ifapi_extend_pcr(
209 TPMI_ALG_HASH alg,
210 uint8_t *pcr,
211 const uint8_t *digest,
212 size_t alg_size);
213
214TSS2_RC ifapi_pcr_selection_to_pcrvalues(
215 TPML_PCR_SELECTION *pcr_selection,
216 TPML_DIGEST *pcr_digests,
217 TPML_PCRVALUES **out);
218
219void
220ifapi_helper_init_policy_pcr_selections(
221 TSS2_POLICY_PCR_SELECTION *s,
222 TPMT_POLICYELEMENT *pol_element);
223
224#endif /* IFAPI_HELPERS_H */
Definition ifapi_keystore.h:150
Definition ifapi_eventlog.h:89
Definition fapi_int.h:178
Definition fapi_int.h:188
Definition ifapi_helpers.h:22
Definition ifapi_policy_types.h:275
Definition ifapi_policy_types.h:260
Definition fapi_types.h:34
Definition fapi_types.h:24