d4693b9c6f9e4bf62a95b645fa3c860fbc41d1e3
[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 #define PTS_SIMPLE_COMP_EVID_FAMILY_MASK 0xC0
35
36 /**
37 * PTS Simple Component Evidence Flags
38 */
39 enum pts_attr_simple_comp_evid_flag_t {
40 /** No Validation was attempted */
41 PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID = 1,
42 /** Attempted validation, unable to verify */
43 PTS_SIMPLE_COMP_EVID_FLAG_NO_VER = 2,
44 /** Attempted validation, verification failed */
45 PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL = 3,
46 /** Attempted validation, verification passed */
47 PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS = 4,
48 };
49
50 /**
51 * PTS PCR Transformations
52 */
53 enum pts_pcr_transform_t {
54 /** No Transformation */
55 PTS_PCR_TRANSFORM_NO = 0,
56 /** Hash Value matched PCR size */
57 PTS_PCR_TRANSFORM_MATCH = 1,
58 /** Hash value shorter than PCR size */
59 PTS_PCR_TRANSFORM_SHORT = 2,
60 /** Hash value longer than PCR size */
61 PTS_PCR_TRANSFORM_LONG = 3,
62 };
63
64 /**
65 * Parameters for Simple Component Evidence Attribute
66 */
67 struct tcg_pts_attr_simple_comp_evid_params_t {
68 bool pcr_info_included;
69 pts_attr_simple_comp_evid_flag_t flags;
70 u_int32_t depth;
71 pts_comp_func_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 Special Component Functional Name
116 *
117 * @return Component Functional Name
118 */
119 pts_comp_func_name_t* (*get_comp_func_name)(tcg_pts_attr_simple_comp_evid_t *this);
120
121 /**
122 * Get Measurement Type
123 *
124 * @return Measurement Type
125 */
126 u_int8_t (*get_measurement_type)(tcg_pts_attr_simple_comp_evid_t *this);
127
128 /**
129 * Get which PCR the functional component is extended into
130 *
131 * @return Number of PCR
132 */
133 u_int32_t (*get_extended_pcr)(tcg_pts_attr_simple_comp_evid_t *this);
134
135 /**
136 * Get Hash Algorithm
137 *
138 * @return Hash Algorithm
139 */
140 pts_meas_algorithms_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this);
141
142 /**
143 * Get PCR Transformation
144 *
145 * @return Transformation type of PCR
146 */
147 pts_pcr_transform_t (*get_pcr_trans)(tcg_pts_attr_simple_comp_evid_t *this);
148
149 /**
150 * Get Measurement Time
151 *
152 * @return Measurement time
153 */
154 chunk_t (*get_measurement_time)(tcg_pts_attr_simple_comp_evid_t *this);
155
156 /**
157 * Get Optional Policy URI
158 *
159 * @return Policy URI
160 */
161 chunk_t (*get_policy_uri)(tcg_pts_attr_simple_comp_evid_t *this);
162
163 /**
164 * Get Optional PCR Length
165 *
166 * @return Length of PCR before/after values
167 */
168 u_int16_t (*get_pcr_len)(tcg_pts_attr_simple_comp_evid_t *this);
169
170 /**
171 * Get Optional PCR before value
172 *
173 * @return PCR before value
174 */
175 chunk_t (*get_pcr_before_value)(tcg_pts_attr_simple_comp_evid_t *this);
176
177 /**
178 * Get Optional PCR after value
179 *
180 * @return PCR after value
181 */
182 chunk_t (*get_pcr_after_value)(tcg_pts_attr_simple_comp_evid_t *this);
183
184 /**
185 * Get Component Measurement
186 *
187 * @return Component Measurement Hash
188 */
189 chunk_t (*get_comp_measurement)(tcg_pts_attr_simple_comp_evid_t *this);
190
191 };
192
193 /**
194 * Creates an tcg_pts_attr_simple_comp_evid_t object
195 *
196 * @param params Struct of parameters
197 */
198 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evid_params_t params);
199
200 /**
201 * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
202 *
203 * @param value Unparsed attribute value
204 */
205 pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
206
207 #endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/