b26f750f1aeba6d67a2cfa2b637d0094e70e8624
[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/components/pts_comp_func_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 pts_comp_func_name_t *name;
70 u_int32_t extended_pcr;
71 pts_meas_algorithms_t hash_algorithm;
72 pts_pcr_transform_t transformation;
73 chunk_t measurement_time;
74 chunk_t policy_uri;
75 chunk_t pcr_before;
76 chunk_t pcr_after;
77 chunk_t measurement;
78 };
79
80 /**
81 * Class implementing the TCG PTS Simple Component Evidence attribute
82 *
83 */
84 struct tcg_pts_attr_simple_comp_evid_t {
85
86 /**
87 * Public PA-TNC attribute interface
88 */
89 pa_tnc_attr_t pa_tnc_attribute;
90
91 /**
92 * Is Optional PCR Information fields included
93 *
94 * @return TRUE if included, FALSE otherwise
95 */
96 bool (*is_pcr_info_included)(tcg_pts_attr_simple_comp_evid_t *this);
97
98 /**
99 * Get flags for PTS Simple Component Evidence
100 *
101 * @return Set of flags
102 */
103 pts_attr_simple_comp_evid_flag_t (*get_flags)(tcg_pts_attr_simple_comp_evid_t *this);
104
105 /**
106 * Get Sub-component Depth
107 *
108 * @return Sub-component Depth
109 */
110 u_int32_t (*get_sub_component_depth)(tcg_pts_attr_simple_comp_evid_t *this);
111
112 /**
113 * Get Special Component Functional Name
114 *
115 * @return Component Functional Name
116 */
117 pts_comp_func_name_t* (*get_comp_func_name)(tcg_pts_attr_simple_comp_evid_t *this);
118
119 /**
120 * Get Measurement Type
121 *
122 * @return Measurement Type
123 */
124 u_int8_t (*get_measurement_type)(tcg_pts_attr_simple_comp_evid_t *this);
125
126 /**
127 * Get which PCR the functional component is extended into
128 *
129 * @return Number of PCR
130 */
131 u_int32_t (*get_extended_pcr)(tcg_pts_attr_simple_comp_evid_t *this);
132
133 /**
134 * Get Hash Algorithm
135 *
136 * @return Hash Algorithm
137 */
138 pts_meas_algorithms_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this);
139
140 /**
141 * Get PCR Transformation
142 *
143 * @return Transformation type of PCR
144 */
145 pts_pcr_transform_t (*get_pcr_trans)(tcg_pts_attr_simple_comp_evid_t *this);
146
147 /**
148 * Get Measurement Time
149 *
150 * @return Measurement time
151 */
152 chunk_t (*get_measurement_time)(tcg_pts_attr_simple_comp_evid_t *this);
153
154 /**
155 * Get Optional Policy URI
156 *
157 * @return Policy URI
158 */
159 chunk_t (*get_policy_uri)(tcg_pts_attr_simple_comp_evid_t *this);
160
161 /**
162 * Get Optional PCR Length
163 *
164 * @return Length of PCR before/after values
165 */
166 u_int16_t (*get_pcr_len)(tcg_pts_attr_simple_comp_evid_t *this);
167
168 /**
169 * Get Optional PCR before value
170 *
171 * @return PCR before value
172 */
173 chunk_t (*get_pcr_before_value)(tcg_pts_attr_simple_comp_evid_t *this);
174
175 /**
176 * Get Optional PCR after value
177 *
178 * @return PCR after value
179 */
180 chunk_t (*get_pcr_after_value)(tcg_pts_attr_simple_comp_evid_t *this);
181
182 /**
183 * Get Component Measurement
184 *
185 * @return Component Measurement Hash
186 */
187 chunk_t (*get_comp_measurement)(tcg_pts_attr_simple_comp_evid_t *this);
188
189 };
190
191 /**
192 * Creates an tcg_pts_attr_simple_comp_evid_t object
193 *
194 * @param params Struct of parameters
195 */
196 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evid_params_t params);
197
198 /**
199 * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
200 *
201 * @param value Unparsed attribute value
202 */
203 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
204
205 #endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/