Catch AIK errors
[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 #include <library.h>
33
34 typedef struct imv_attestation_state_t imv_attestation_state_t;
35 typedef enum imv_attestation_flag_t imv_attestation_flag_t;
36 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
37 typedef enum imv_meas_error_t imv_meas_error_t;
38
39 /**
40 * IMV Attestation Flags set for completed actions
41 */
42 enum imv_attestation_flag_t {
43 IMV_ATTESTATION_FLAG_ATTR_REQ = (1<<0),
44 IMV_ATTESTATION_FLAG_ALGO = (1<<1),
45 IMV_ATTESTATION_FLAG_FILE_MEAS = (1<<2),
46 IMV_ATTESTATION_FLAG_REC = (1<<3)
47 };
48
49 /**
50 * IMV Attestation Handshake States (state machine)
51 */
52 enum imv_attestation_handshake_state_t {
53 IMV_ATTESTATION_STATE_INIT,
54 IMV_ATTESTATION_STATE_DISCOVERY,
55 IMV_ATTESTATION_STATE_NONCE_REQ,
56 IMV_ATTESTATION_STATE_TPM_INIT,
57 IMV_ATTESTATION_STATE_COMP_EVID,
58 IMV_ATTESTATION_STATE_EVID_FINAL,
59 IMV_ATTESTATION_STATE_END,
60 };
61
62 /**
63 * IMV Measurement Error Types
64 */
65 enum imv_meas_error_t {
66 IMV_ATTESTATION_ERROR_FILE_MEAS_FAIL = 1,
67 IMV_ATTESTATION_ERROR_FILE_MEAS_PEND = 2,
68 IMV_ATTESTATION_ERROR_NO_TRUSTED_AIK = 4,
69 IMV_ATTESTATION_ERROR_COMP_EVID_FAIL = 8,
70 IMV_ATTESTATION_ERROR_COMP_EVID_PEND = 16,
71 IMV_ATTESTATION_ERROR_TPM_QUOTE_FAIL = 32
72 };
73
74 /**
75 * Internal state of an imv_attestation_t connection instance
76 */
77 struct imv_attestation_state_t {
78
79 /**
80 * imv_state_t interface
81 */
82 imv_state_t interface;
83
84 /**
85 * Get state of the handshake
86 *
87 * @return the handshake state of IMV
88 */
89 imv_attestation_handshake_state_t (*get_handshake_state)(
90 imv_attestation_state_t *this);
91
92 /**
93 * Set state of the handshake
94 *
95 * @param new_state the handshake state of IMV
96 */
97 void (*set_handshake_state)(imv_attestation_state_t *this,
98 imv_attestation_handshake_state_t new_state);
99
100 /**
101 * Get the PTS object
102 *
103 * @return PTS object
104 */
105 pts_t* (*get_pts)(imv_attestation_state_t *this);
106
107 /**
108 * Create and add an entry to the list of Functional Components
109 *
110 * @param name Component Functional Name
111 * @param depth Sub-component Depth
112 * @param pts_db PTS measurement database
113 * @return created functional component instance or NULL
114 */
115 pts_component_t* (*create_component)(imv_attestation_state_t *this,
116 pts_comp_func_name_t *name,
117 u_int32_t depth,
118 pts_database_t *pts_db);
119
120 /**
121 * Enumerate over all Functional Components
122 *
123 * @return Functional Component enumerator
124 */
125 enumerator_t* (*create_component_enumerator)(imv_attestation_state_t *this);
126
127 /**
128 * Get a Functional Component with a given name
129 *
130 * @param name Name of the requested Functional Component
131 * @return Functional Component if found, NULL otherwise
132 */
133 pts_component_t* (*get_component)(imv_attestation_state_t *this,
134 pts_comp_func_name_t *name);
135
136 /**
137 * Tell the Functional Components to finalize any measurement registrations
138 * and to check if all expected measurements were received
139 */
140 void (*finalize_components)(imv_attestation_state_t *this);
141
142 /**
143 * Indicates the types of measurement errors that occurred
144 *
145 * @return Measurement error flags
146 */
147 u_int32_t (*get_measurement_error)(imv_attestation_state_t *this);
148
149 /**
150 * Call if a measurement error is encountered
151 *
152 * @param error Measurement error type
153 */
154 void (*set_measurement_error)(imv_attestation_state_t *this,
155 u_int32_t error);
156
157 /**
158 * Returns a concatenation of File Measurement reason strings
159 *
160 * @param reason_string Concatenated reason strings
161 */
162 void (*add_file_meas_reasons)(imv_attestation_state_t *this,
163 imv_reason_string_t *reason_string);
164
165 /**
166 * Returns a concatenation of Component Evidence reason strings
167 *
168 * @param reason_string Concatenated reason strings
169 */
170 void (*add_comp_evid_reasons)(imv_attestation_state_t *this,
171 imv_reason_string_t *reason_string);
172 };
173
174 /**
175 * Create an imv_attestation_state_t instance
176 *
177 * @param id connection ID
178 */
179 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
180
181 #endif /** IMV_ATTESTATION_STATE_H_ @}*/