ff846fc8b3ef56e545074c4687cad30a6306e5fb
[strongswan.git] / src / libpts / 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_pcr_transform_t pts_pcr_transform_t;
27 typedef struct tcg_pts_attr_simple_comp_evid_params_t tcg_pts_attr_simple_comp_evid_params_t;
28
29 #include "tcg_attr.h"
30 #include "pts/pts_meas_algo.h"
31 #include "pts/pts_funct_comp_name.h"
32 #include "pa_tnc/pa_tnc_attr.h"
33
34 /**
35 * PTS Simple Component Evidence Flags
36 */
37 enum pts_attr_simple_comp_evid_flag_t {
38 /** No Validation was attempted */
39 PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID = 1,
40 /** Attempted validation, unable to verify */
41 PTS_SIMPLE_COMP_EVID_FLAG_NO_VER = 2,
42 /** Attempted validation, verification failed */
43 PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL = 3,
44 /** Attempted validation, verification passed */
45 PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS = 4,
46 };
47
48 /**
49 * PTS PCR Transformations
50 */
51 enum pts_pcr_transform_t {
52 /** No Transformation */
53 PTS_PCR_TRANSFORM_NO = 0,
54 /** Hash Value matched PCR size */
55 PTS_PCR_TRANSFORM_MATCH = 1,
56 /** Hash value shorter than PCR size */
57 PTS_PCR_TRANSFORM_SHORT = 2,
58 /** Hash value longer than PCR size */
59 PTS_PCR_TRANSFORM_LONG = 3,
60 };
61
62 /**
63 * Parameters for Simple Component Evidence Attribute
64 */
65 struct tcg_pts_attr_simple_comp_evid_params_t {
66 bool pcr_info_included;
67 pts_attr_simple_comp_evid_flag_t flags;
68 u_int32_t depth;
69 u_int32_t vendor_id;
70 pts_qualifier_t qualifier;
71 pts_ita_funct_comp_name_t name;
72 u_int32_t extended_pcr;
73 pts_meas_algorithms_t hash_algorithm;
74 pts_pcr_transform_t transformation;
75 chunk_t measurement_time;
76 chunk_t policy_uri;
77 chunk_t pcr_before;
78 chunk_t pcr_after;
79 chunk_t measurement;
80 };
81
82 /**
83 * Class implementing the TCG PTS Simple Component Evidence attribute
84 *
85 */
86 struct tcg_pts_attr_simple_comp_evid_t {
87
88 /**
89 * Public PA-TNC attribute interface
90 */
91 pa_tnc_attr_t pa_tnc_attribute;
92
93 /**
94 * Is Optional PCR Information fields included
95 *
96 * @return TRUE if included, FALSE otherwise
97 */
98 bool (*is_pcr_info_included)(tcg_pts_attr_simple_comp_evid_t *this);
99
100 /**
101 * Get flags for PTS Simple Component Evidence
102 *
103 * @return Set of flags
104 */
105 pts_attr_simple_comp_evid_flag_t (*get_flags)(tcg_pts_attr_simple_comp_evid_t *this);
106
107 /**
108 * Get Sub-component Depth
109 *
110 * @return Sub-component Depth
111 */
112 u_int32_t (*get_sub_component_depth)(tcg_pts_attr_simple_comp_evid_t *this);
113
114 /**
115 * Get Specific Component Functional Name Vendor ID
116 *
117 * @return Component Functional Name Vendor ID
118 */
119 u_int32_t (*get_spec_comp_funct_name_vendor_id)(tcg_pts_attr_simple_comp_evid_t *this);
120
121 /**
122 * Get Family
123 *
124 * @return Functional Name Family
125 */
126 u_int8_t (*get_family)(tcg_pts_attr_simple_comp_evid_t *this);
127
128 /**
129 * Get Qualifier
130 *
131 * @return Functional Name Category Qualifier
132 */
133 pts_qualifier_t (*get_qualifier)(tcg_pts_attr_simple_comp_evid_t *this);
134
135 /**
136 * Get Special Component Functional Name
137 *
138 * @return Component Functional Name
139 */
140 pts_ita_funct_comp_name_t (*get_comp_funct_name)(tcg_pts_attr_simple_comp_evid_t *this);
141
142 /**
143 * Get Measurement Type
144 *
145 * @return Measurement Type
146 */
147 u_int8_t (*get_measurement_type)(tcg_pts_attr_simple_comp_evid_t *this);
148
149 /**
150 * Get which PCR the functional component is extended into
151 *
152 * @return Number of PCR
153 */
154 u_int32_t (*get_extended_pcr)(tcg_pts_attr_simple_comp_evid_t *this);
155
156 /**
157 * Get Hash Algorithm
158 *
159 * @return Hash Algorithm
160 */
161 pts_meas_algorithms_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this);
162
163 /**
164 * Get PCR Transformation
165 *
166 * @return Transformation type of PCR
167 */
168 pts_pcr_transform_t (*get_pcr_trans)(tcg_pts_attr_simple_comp_evid_t *this);
169
170 /**
171 * Get Measurement Time
172 *
173 * @return Measurement time
174 */
175 chunk_t (*get_measurement_time)(tcg_pts_attr_simple_comp_evid_t *this);
176
177 /**
178 * Get Optional Policy URI
179 *
180 * @return Policy URI
181 */
182 chunk_t (*get_policy_uri)(tcg_pts_attr_simple_comp_evid_t *this);
183
184 /**
185 * Get Optional PCR Length
186 *
187 * @return Length of PCR before/after values
188 */
189 u_int16_t (*get_pcr_len)(tcg_pts_attr_simple_comp_evid_t *this);
190
191 /**
192 * Get Optional PCR before value
193 *
194 * @return PCR before value
195 */
196 chunk_t (*get_pcr_before_value)(tcg_pts_attr_simple_comp_evid_t *this);
197
198 /**
199 * Get Optional PCR after value
200 *
201 * @return PCR after value
202 */
203 chunk_t (*get_pcr_after_value)(tcg_pts_attr_simple_comp_evid_t *this);
204
205 /**
206 * Get Component Measurement
207 *
208 * @return Component Measurement Hash
209 */
210 chunk_t (*get_comp_measurement)(tcg_pts_attr_simple_comp_evid_t *this);
211
212 };
213
214 /**
215 * Creates an tcg_pts_attr_simple_comp_evid_t object
216 *
217 * @param params Struct of parameters
218 */
219 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evid_params_t params);
220
221 /**
222 * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
223 *
224 * @param value Unparsed attribute value
225 */
226 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
227
228 #endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/