f6c79c0f57ce9845ed3fa986d8f96b6761fe0fbc
[strongswan.git] / src / libimcv / tcg / tcg_pts_attr_simple_comp_evid.h
1 /*
2 * Copyright (C) 2011 Sansar Choinyambuu
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tcg_pts_attr_simple_comp_evid tcg_pts_attr_simple_comp_evid
18 * @{ @ingroup tcg_pts_attr_simple_comp_evid
19 */
20
21 #ifndef TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_
22 #define TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_
23
24 typedef struct tcg_pts_attr_simple_comp_evid_t tcg_pts_attr_simple_comp_evid_t;
25 typedef enum pts_attr_simple_comp_evid_flag_t pts_attr_simple_comp_evid_flag_t;
26 typedef enum pts_attr_simple_comp_evid_pcr_transform_t pts_attr_simple_comp_evid_pcr_transform_t;
27
28 #include "tcg_attr.h"
29 #include "pa_tnc/pa_tnc_attr.h"
30 /* For Qualifier and Component Name fields, tcg_pts_qualifier_t,
31 * pts_attr_req_funct_comp_name_bin_enum_t, pts_attr_req_funct_comp_type_t */
32 #include "tcg_pts_attr_req_funct_comp_evid.h"
33 /* For Hash Algorithm field, pts_attr_meas_algorithms_t*/
34 #include "tcg_pts_attr_meas_algo_selection.h"
35
36 /**
37 * PTS Simple Component Evidence Flags
38 */
39 enum pts_attr_simple_comp_evid_flag_t {
40 /** PCR information fields inlcuded */
41 PTS_SIMPLE_COMP_EVID_FLAG_PCR = 0,
42 /** No Validation was attempted */
43 PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID = 1,
44 /** Attempted validation, unable to verify */
45 PTS_SIMPLE_COMP_EVID_FLAG_NO_VER = 2,
46 /** Attempted validation, verification failed */
47 PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL = 3,
48 /** Attempted validation, verification passed */
49 PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS = 4,
50 };
51
52 /**
53 * PTS Simple Component Evidence PCR Transformations
54 */
55 enum pts_attr_simple_comp_evid_pcr_transform_t {
56 /** No Transformation */
57 PTS_SIMPLE_COMP_EVID_PCR_TRANS_NO = 0,
58 /** Hash Value matched PCR size */
59 PTS_SIMPLE_COMP_EVID_PCR_TRANS_MATCH = 1,
60 /** Hash value shorter than PCR size */
61 PTS_SIMPLE_COMP_EVID_PCR_TRANS_SHORT = 2,
62 /** Hash value longer than PCR size */
63 PTS_SIMPLE_COMP_EVID_PCR_TRANS_LONG = 3,
64 };
65
66 /**
67 * Class implementing the TCG PTS Simple Component Evidence attribute
68 *
69 */
70 struct tcg_pts_attr_simple_comp_evid_t {
71
72 /**
73 * Public PA-TNC attribute interface
74 */
75 pa_tnc_attr_t pa_tnc_attribute;
76
77 /**
78 * Get flags for PTS Simple Component Evidence
79 *
80 * @return Set of flags
81 */
82 pts_attr_simple_comp_evid_flag_t (*get_flags)(tcg_pts_attr_simple_comp_evid_t *this);
83
84 /**
85 * Set flags for PTS Simple Component Evidence
86 *
87 * @param flags Set of flags
88 */
89 void (*set_flags)(tcg_pts_attr_simple_comp_evid_t *this,
90 pts_attr_simple_comp_evid_flag_t flags);
91
92 /**
93 * Get Sub-component Depth
94 *
95 * @return Sub-component Depth
96 */
97 u_int32_t (*get_sub_component_depth)(tcg_pts_attr_simple_comp_evid_t *this);
98
99 /**
100 * Get Specific Component Functional Name Vendor ID
101 *
102 * @return Component Functional Name Vendor ID
103 */
104 u_int32_t (*get_spec_comp_funct_name_vendor_id)(tcg_pts_attr_simple_comp_evid_t *this);
105
106 /**
107 * Get Family
108 *
109 * @return Functional Name Family
110 */
111 u_int8_t (*get_family)(tcg_pts_attr_simple_comp_evid_t *this);
112
113 /**
114 * Get Qualifier
115 *
116 * @return Functional Name Category Qualifier
117 */
118 tcg_pts_qualifier_t (*get_qualifier)(tcg_pts_attr_simple_comp_evid_t *this);
119
120 /**
121 * Set qualifier for Component Functional Name
122 *
123 * @param qualifier Functional Name Category Qualifier
124 */
125 void (*set_qualifier)(tcg_pts_attr_simple_comp_evid_t *this,
126 tcg_pts_qualifier_t qualifier);
127
128 /**
129 * Get Special Component Functional Name
130 *
131 * @return Component Functional Name
132 */
133 pts_attr_req_funct_comp_name_bin_enum_t (*get_comp_funct_name)(tcg_pts_attr_simple_comp_evid_t *this);
134
135
136 /**
137 * Set Component Functional Name
138 *
139 * @param name Component Functional Name
140 */
141 void (*set_comp_funct_name)(tcg_pts_attr_simple_comp_evid_t *this,
142 pts_attr_req_funct_comp_name_bin_enum_t name);
143
144 /**
145 * Get Measurement Type
146 *
147 * @return Measurement Type
148 */
149 u_int8_t (*get_measurement_type)(tcg_pts_attr_simple_comp_evid_t *this);
150
151 /**
152 * Get which PCR the functional component is extended into
153 *
154 * @return Number of PCR
155 */
156 u_int32_t (*get_extended_pcr)(tcg_pts_attr_simple_comp_evid_t *this);
157
158 /**
159 * Set which PCR the functional component is extended into
160 *
161 * @param pcr_number Number of PCR
162 */
163 void (*set_extended_pcr)(tcg_pts_attr_simple_comp_evid_t *this,
164 u_int32_t extended_pcr);
165
166 /**
167 * Get Hash Algorithm
168 *
169 * @return Hash Algorithm
170 */
171 pts_attr_meas_algorithms_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this);
172
173 /**
174 * Set Hash Algorithm
175 *
176 * @param hash_algorithm Hash Algorithm
177 */
178 void (*set_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this,
179 pts_attr_meas_algorithms_t hash_algorithm);
180
181 /**
182 * Get PCR Transformation
183 *
184 * @return Transformation type of PCR
185 */
186 pts_attr_simple_comp_evid_pcr_transform_t (*get_pcr_trans)(tcg_pts_attr_simple_comp_evid_t *this);
187
188 /**
189 * Set PCR Transformation
190 *
191 * @param transformation Transformation type of PCR
192 */
193 void (*set_pcr_trans)(tcg_pts_attr_simple_comp_evid_t *this,
194 pts_attr_simple_comp_evid_pcr_transform_t transformation);
195
196 /**
197 * Get Measurement Time
198 *
199 * @return Measurement time
200 */
201 chunk_t (*get_measurement_time)(tcg_pts_attr_simple_comp_evid_t *this);
202
203 /**
204 * Set Measurement Time
205 *
206 * @param time Measurement time
207 */
208 void (*set_measurement_time)(tcg_pts_attr_simple_comp_evid_t *this,
209 chunk_t time);
210
211 /**
212 * Get Optional Policy URI
213 *
214 * @return Policy URI
215 */
216 chunk_t (*get_policy_uri)(tcg_pts_attr_simple_comp_evid_t *this);
217
218 /**
219 * Set Optional Policy URI
220 *
221 * @param policy_uri Policy URI
222 */
223 void (*set_policy_uri)(tcg_pts_attr_simple_comp_evid_t *this,
224 chunk_t policy_uri);
225
226 /**
227 * Get Optional PCR Length
228 *
229 * @return Length of PCR before/after values
230 */
231 u_int16_t (*get_pcr_len)(tcg_pts_attr_simple_comp_evid_t *this);
232
233 /**
234 * Get Optional PCR before value
235 *
236 * @return PCR before value
237 */
238 chunk_t (*get_pcr_before_value)(tcg_pts_attr_simple_comp_evid_t *this);
239
240 /**
241 * Set Optional PCR before value
242 *
243 * @param pcr_before PCR before value
244 */
245 void (*set_pcr_before_value)(tcg_pts_attr_simple_comp_evid_t *this,
246 chunk_t pcr_before);
247
248 /**
249 * Get Optional PCR after value
250 *
251 * @return PCR after value
252 */
253 chunk_t (*get_pcr_after_value)(tcg_pts_attr_simple_comp_evid_t *this);
254
255 /**
256 * Set Optional PCR after value
257 *
258 * @param pcr_after PCR after value
259 */
260 void (*set_pcr_after_value)(tcg_pts_attr_simple_comp_evid_t *this,
261 chunk_t pcr_after);
262
263 /**
264 * Get Component Measurement
265 *
266 * @return Component Measurement Hash
267 */
268 chunk_t (*get_comp_measurement)(tcg_pts_attr_simple_comp_evid_t *this);
269
270 /**
271 * Set Component Measurement
272 *
273 * @param measurement Component Measurement Hash
274 */
275 void (*set_comp_measurement)(tcg_pts_attr_simple_comp_evid_t *this,
276 chunk_t measurement);
277
278 };
279
280 /**
281 * Creates an tcg_pts_attr_simple_comp_evid_t object
282 *
283 * @param flags Set of flags
284 * @param depth Sub-component Depth
285 * @param vendor_id Component Functional Name Vendor ID
286 * @param qualifier Functional Name Category Qualifier
287 * @param name Component Functional Name
288 * @param extended_pcr Which PCR the functional component is extended into
289 * @param hash_algorithm Hash Algorithm
290 * @param transformation Transformation type for PCR
291 * @param measurement_time Measurement time
292 * @param policy_uri Optional Policy URI
293 * @param pcr_before Optional PCR before value
294 * @param pcr_after Optional PCR after value
295 * @param measurement Component Measurement
296 */
297 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(pts_attr_simple_comp_evid_flag_t flags,
298 u_int32_t depth,
299 u_int32_t vendor_id,
300 tcg_pts_qualifier_t qualifier,
301 pts_attr_req_funct_comp_name_bin_enum_t name,
302 u_int32_t extended_pcr,
303 pts_attr_meas_algorithms_t hash_algorithm,
304 pts_attr_simple_comp_evid_pcr_transform_t transformation,
305 chunk_t measurement_time,
306 chunk_t policy_uri,
307 chunk_t pcr_before,
308 chunk_t pcr_after,
309 chunk_t measurement);
310
311 /**
312 * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
313 *
314 * @param value unparsed attribute value
315 */
316 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
317
318 #endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/