tpm2-tss 4.0.1
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
20TSS2_RC
21ifapi_create_dirs(const char *supdir, const char *path);
22
23TSS2_RC
24ifapi_set_key_flags(const char *type, bool policy, IFAPI_KEY_TEMPLATE *template);
25
26TSS2_RC
27ifapi_set_nv_flags(const char *type, IFAPI_NV_TEMPLATE *template,
28 const char *policy);
29
30bool
31ifapi_path_type_p(const char *path, const char *type);
32
33ESYS_TR
34ifapi_get_hierary_handle(const char *path);
35
36bool
37ifapi_null_primary_p(const char *path);
38
39bool
40ifapi_hierarchy_path_p(const char *path);
41
42bool
43ifapi_TPMT_PUBLIC_cmp(TPMT_PUBLIC *in1, TPMT_PUBLIC *in2);
44
45void
46ifapi_init_hierarchy_object(
47 IFAPI_OBJECT *hierarchy,
48 ESYS_TR esys_handle);
49
50TSS2_RC
51ifapi_set_name_hierarchy_object(
52 IFAPI_OBJECT *hierarchy);
53
54char *
55get_description(IFAPI_OBJECT *object);
56
57size_t
58ifapi_path_length(NODE_STR_T *node);
59
60void
61ifapi_free_object_list(NODE_OBJECT_T *node);
62
63void
64ifapi_free_node_list(NODE_OBJECT_T *node);
65
66TSS2_RC
67ifapi_path_string(char **dest, const char *supdir, NODE_STR_T *node, char *name);
68
69TSS2_RC
70ifapi_path_string_n(
71 char **dest,
72 const char *supdir,
73 NODE_STR_T *node,
74 char *name,
75 size_t n);
76
77TSS2_RC
78ifapi_asprintf(char **str, const char *fmt, ...);
79
81split_string(const char *string, char *delimiter);
82
84init_string_list(const char *string);
85
86bool
87add_string_to_list(NODE_STR_T *str_list, char *string);
88
89void
90free_string_list(NODE_STR_T *node);
91
92void
93ifapi_cleanup_policy(
94 TPMS_POLICY *policy);
95
97ifapi_copy_policy(
98 const TPMS_POLICY *from_policy);
99
100TSS2_RC
101ifapi_get_name(
102 TPMT_PUBLIC *publicInfo,
103 TPM2B_NAME *name);
104
105TSS2_RC
106ifapi_nv_get_name(
107 TPMS_NV_PUBLIC *publicInfo,
108 TPM2B_NAME *name);
109
110TSS2_RC
111ifapi_object_cmp_name(
112 IFAPI_OBJECT *object,
113 void *name,
114 bool *equal);
115
116TSS2_RC
117ifapi_object_cmp_nv_public(
118 IFAPI_OBJECT *object,
119 void *nv_public,
120 bool *equal);
121
122TSS2_RC
123ifapi_tpm_to_fapi_signature(
124 IFAPI_OBJECT *sig_key_object,
125 TPMT_SIGNATURE *tpm_signature,
126 uint8_t **signature,
127 size_t *signatureSize);
128
129TSS2_RC
130ifapi_compute_quote_info(
131 IFAPI_OBJECT *sig_key_object,
132 TPM2B_ATTEST *tpm_quoted,
133 char **quoteInfo);
134
135TSS2_RC
136ifapi_get_quote_info(
137 char const *quoteInfo,
138 TPM2B_ATTEST *tpm_quoted,
139 FAPI_QUOTE_INFO *fapi_quote_ingo);
140
141TSS2_RC
142push_object_to_list(void *object, NODE_OBJECT_T **object_list);
143
144TSS2_RC
145append_object_to_list(void *object, NODE_OBJECT_T **object_list);
146
147bool
148object_with_auth(IFAPI_OBJECT *object);
149
150TSS2_RC
151ifapi_get_nv_start_index(const char *path, TPM2_HANDLE *start_nv_index);
152
153TSS2_RC
154ifapi_check_nv_index(const char *path, TPM2_HANDLE nv_index);
155
156TSS2_RC
157ifapi_check_profile_pcr_selection(
158 const TPML_PCR_SELECTION *pcr_profile,
159 const TPML_PCR_SELECTION *pcr_capablity);
160
161TSS2_RC
162ifapi_filter_pcr_selection_by_index(
163 TPML_PCR_SELECTION *pcr_selection,
164 const TPM2_HANDLE *pcr_index,
165 size_t pcr_count);
166
167TSS2_RC ifapi_calculate_pcr_digest(
168 json_object *jso_event_list,
169 const FAPI_QUOTE_INFO *quote_info,
170 TPM2B_DIGEST *pcr_digest);
171
172TSS2_RC
173ifapi_compute_policy_digest(
174 TPML_PCRVALUES *pcrs,
175 TPML_PCR_SELECTION *pcr_selection,
176 TPMI_ALG_HASH hash_alg,
177 TPM2B_DIGEST *pcr_digest);
178
179bool
180ifapi_cmp_public_key(
181 TPM2B_PUBLIC *key1,
182 TPM2B_PUBLIC *key2);
183
184void
185ifapi_check_json_object_fields(
186 json_object *jso,
187 char** field_tab,
188 size_t size_of_tab);
189
190TSS2_RC
191ifapi_extend_pcr(
192 TPMI_ALG_HASH alg,
193 uint8_t *pcr,
194 const uint8_t *digest,
195 size_t alg_size);
196
197TSS2_RC ifapi_pcr_selection_to_pcrvalues(
198 TPML_PCR_SELECTION *pcr_selection,
199 TPML_DIGEST *pcr_digests,
200 TPML_PCRVALUES **out);
201
202void
203ifapi_helper_init_policy_pcr_selections(
204 TSS2_POLICY_PCR_SELECTION *s,
205 TPMT_POLICYELEMENT *pol_element);
206
207#endif /* IFAPI_HELPERS_H */
Definition ifapi_keystore.h:150
Definition fapi_int.h:190
Definition fapi_int.h:170
Definition fapi_int.h:180
Definition ifapi_policy_types.h:275
Definition ifapi_policy_types.h:260
Definition fapi_types.h:34
Definition fapi_types.h:24