Wait for the arrival of the TCPG_PTS_DH_NONCE_PARAMS_RESP
[strongswan.git] / src / libpts / plugins / imv_attestation / imv_attestation_state.h
1 /*
2 * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
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 imv_attestation imv_attestation
18 * @ingroup libpts_plugins
19 *
20 * @defgroup imv_attestation_state_t imv_attestation_state
21 * @{ @ingroup imv_attestation
22 */
23
24 #ifndef IMV_ATTESTATION_STATE_H_
25 #define IMV_ATTESTATION_STATE_H_
26
27 #include <imv/imv_state.h>
28 #include <imv/imv_reason_string.h>
29 #include <pts/pts.h>
30 #include <pts/pts_database.h>
31 #include <pts/components/pts_component.h>
32
33 #include <library.h>
34 #include <bio/bio_writer.h>
35
36 typedef struct imv_attestation_state_t imv_attestation_state_t;
37 typedef enum imv_attestation_flag_t imv_attestation_flag_t;
38 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
39 typedef enum imv_meas_error_t imv_meas_error_t;
40
41 /**
42 * IMV Attestation Flags set for completed actions
43 */
44 enum imv_attestation_flag_t {
45 IMV_ATTESTATION_ATTR_PRODUCT_INFO = (1<<0),
46 IMV_ATTESTATION_ATTR_STRING_VERSION = (1<<1),
47 IMV_ATTESTATION_ATTR_DEVICE_ID = (1<<2),
48 IMV_ATTESTATION_ATTR_MUST = (1<<3)-1,
49 IMV_ATTESTATION_ATTR_REQ = (1<<3),
50 IMV_ATTESTATION_ALGO = (1<<4),
51 IMV_ATTESTATION_DH_NONCE = (1<<5),
52 IMV_ATTESTATION_FILE_MEAS = (1<<6),
53 IMV_ATTESTATION_REC = (1<<7)
54 };
55
56 /**
57 * IMV Attestation Handshake States (state machine)
58 */
59 enum imv_attestation_handshake_state_t {
60 IMV_ATTESTATION_STATE_INIT,
61 IMV_ATTESTATION_STATE_DISCOVERY,
62 IMV_ATTESTATION_STATE_NONCE_REQ,
63 IMV_ATTESTATION_STATE_TPM_INIT,
64 IMV_ATTESTATION_STATE_COMP_EVID,
65 IMV_ATTESTATION_STATE_EVID_FINAL,
66 IMV_ATTESTATION_STATE_END,
67 };
68
69 /**
70 * IMV Measurement Error Types
71 */
72 enum imv_meas_error_t {
73 IMV_ATTESTATION_ERROR_FILE_MEAS_FAIL = 1,
74 IMV_ATTESTATION_ERROR_FILE_MEAS_PEND = 2,
75 IMV_ATTESTATION_ERROR_NO_TRUSTED_AIK = 4,
76 IMV_ATTESTATION_ERROR_COMP_EVID_FAIL = 8,
77 IMV_ATTESTATION_ERROR_COMP_EVID_PEND = 16,
78 IMV_ATTESTATION_ERROR_TPM_QUOTE_FAIL = 32
79 };
80
81 /**
82 * Internal state of an imv_attestation_t connection instance
83 */
84 struct imv_attestation_state_t {
85
86 /**
87 * imv_state_t interface
88 */
89 imv_state_t interface;
90
91 /**
92 * Get state of the handshake
93 *
94 * @return the handshake state of IMV
95 */
96 imv_attestation_handshake_state_t (*get_handshake_state)(
97 imv_attestation_state_t *this);
98
99 /**
100 * Set state of the handshake
101 *
102 * @param new_state the handshake state of IMV
103 */
104 void (*set_handshake_state)(imv_attestation_state_t *this,
105 imv_attestation_handshake_state_t new_state);
106
107 /**
108 * Get the PTS object
109 *
110 * @return PTS object
111 */
112 pts_t* (*get_pts)(imv_attestation_state_t *this);
113
114 /**
115 * Create and add an entry to the list of Functional Components
116 *
117 * @param name Component Functional Name
118 * @param depth Sub-component Depth
119 * @param pts_db PTS measurement database
120 * @return created functional component instance or NULL
121 */
122 pts_component_t* (*create_component)(imv_attestation_state_t *this,
123 pts_comp_func_name_t *name,
124 uint32_t depth,
125 pts_database_t *pts_db);
126
127 /**
128 * Enumerate over all Functional Components
129 *
130 * @return Functional Component enumerator
131 */
132 enumerator_t* (*create_component_enumerator)(imv_attestation_state_t *this);
133
134 /**
135 * Get a Functional Component with a given name
136 *
137 * @param name Name of the requested Functional Component
138 * @return Functional Component if found, NULL otherwise
139 */
140 pts_component_t* (*get_component)(imv_attestation_state_t *this,
141 pts_comp_func_name_t *name);
142
143 /**
144 * Tell the Functional Components to finalize any measurement registrations
145 * and to check if all expected measurements were received
146 *
147 * @param result Writer appending component measurement results
148 */
149 void (*finalize_components)(imv_attestation_state_t *this,
150 bio_writer_t *result);
151
152 /**
153 * Indicates the types of measurement errors that occurred
154 *
155 * @return Measurement error flags
156 */
157 uint32_t (*get_measurement_error)(imv_attestation_state_t *this);
158
159 /**
160 * Call if a measurement error is encountered
161 *
162 * @param error Measurement error type
163 */
164 void (*set_measurement_error)(imv_attestation_state_t *this,
165 uint32_t error);
166
167 /**
168 * Returns a concatenation of File Measurement reason strings
169 *
170 * @param reason_string Concatenated reason strings
171 */
172 void (*add_file_meas_reasons)(imv_attestation_state_t *this,
173 imv_reason_string_t *reason_string);
174
175 /**
176 * Returns a concatenation of Component Evidence reason strings
177 *
178 * @param reason_string Concatenated reason strings
179 */
180 void (*add_comp_evid_reasons)(imv_attestation_state_t *this,
181 imv_reason_string_t *reason_string);
182 };
183
184 /**
185 * Create an imv_attestation_state_t instance
186 *
187 * @param id connection ID
188 */
189 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
190
191 #endif /** IMV_ATTESTATION_STATE_H_ @}*/