attest displays dates either in local time or UTC
[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 *
18 * @defgroup imv_attestation_state_t imv_attestation_state
19 * @{ @ingroup imv_attestation_state
20 */
21
22 #ifndef IMV_ATTESTATION_STATE_H_
23 #define IMV_ATTESTATION_STATE_H_
24
25 #include <imv/imv_state.h>
26 #include <pts/pts.h>
27 #include <pts/pts_database.h>
28 #include <pts/components/pts_component.h>
29 #include <library.h>
30
31 typedef struct imv_attestation_state_t imv_attestation_state_t;
32 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
33 typedef enum imv_meas_error_t imv_meas_error_t;
34
35 /**
36 * IMV Attestation Handshake States (state machine)
37 */
38 enum imv_attestation_handshake_state_t {
39 IMV_ATTESTATION_STATE_INIT,
40 IMV_ATTESTATION_STATE_NONCE_REQ,
41 IMV_ATTESTATION_STATE_TPM_INIT,
42 IMV_ATTESTATION_STATE_MEAS,
43 IMV_ATTESTATION_STATE_COMP_EVID,
44 IMV_ATTESTATION_STATE_EVID_FINAL,
45 IMV_ATTESTATION_STATE_END,
46 };
47
48 /**
49 * IMV Measurement Error Types
50 */
51 enum imv_meas_error_t {
52 IMV_ATTESTATION_ERROR_FILE_MEAS_FAIL = 1,
53 IMV_ATTESTATION_ERROR_FILE_MEAS_PEND = 2,
54 IMV_ATTESTATION_ERROR_COMP_EVID_FAIL = 4,
55 IMV_ATTESTATION_ERROR_COMP_EVID_PEND = 8,
56 IMV_ATTESTATION_ERROR_TPM_QUOTE_FAIL = 16
57 };
58
59 /**
60 * Internal state of an imv_attestation_t connection instance
61 */
62 struct imv_attestation_state_t {
63
64 /**
65 * imv_state_t interface
66 */
67 imv_state_t interface;
68
69 /**
70 * Get state of the handshake
71 *
72 * @return the handshake state of IMV
73 */
74 imv_attestation_handshake_state_t (*get_handshake_state)(
75 imv_attestation_state_t *this);
76
77 /**
78 * Set state of the handshake
79 *
80 * @param new_state the handshake state of IMV
81 */
82 void (*set_handshake_state)(imv_attestation_state_t *this,
83 imv_attestation_handshake_state_t new_state);
84
85 /**
86 * Get the PTS object
87 *
88 * @return PTS object
89 */
90 pts_t* (*get_pts)(imv_attestation_state_t *this);
91
92 /**
93 * Add an entry to the list of pending file/directory measurement requests
94 *
95 * @param file_id primary key into file table
96 * @param is_dir TRUE if directory
97 * @return unique request ID
98 */
99 u_int16_t (*add_file_meas_request)(imv_attestation_state_t *this,
100 int file_id, bool is_dir);
101
102 /**
103 * Returns the number of pending file/directory measurement requests
104 *
105 * @return number of pending requests
106 */
107 int (*get_file_meas_request_count)(imv_attestation_state_t *this);
108
109 /**
110 * Check for presence of request_id and if found remove it from the list
111 *
112 * @param id unique request ID
113 * @param file_id primary key into file table
114 * @param is_dir return TRUE if request was for a directory
115 * @return TRUE if request ID found, FALSE otherwise
116 */
117 bool (*check_off_file_meas_request)(imv_attestation_state_t *this,
118 u_int16_t id, int *file_id, bool *is_dir);
119
120 /**
121 * Create and add an entry to the list of Functional Components
122 *
123 * @param name Component Functional Name
124 * @param depth Sub-component Depth
125 * @param pts_db PTS measurement database
126 * @return created functional component instance or NULL
127 */
128 pts_component_t* (*create_component)(imv_attestation_state_t *this,
129 pts_comp_func_name_t *name,
130 u_int32_t depth,
131 pts_database_t *pts_db);
132
133 /**
134 * Get a Functional Component with a given name
135 *
136 * @param name Name of the requested Functional Component
137 * @return Functional Component if found, NULL otherwise
138 */
139 pts_component_t* (*get_component)(imv_attestation_state_t *this,
140 pts_comp_func_name_t *name);
141
142 /**
143 * Tell the Functional Components to finalize any measurement registrations
144 * and to check if all expected measurements were received
145 */
146 void (*finalize_components)(imv_attestation_state_t *this);
147
148 /**
149 * Have the Functional Component measurements been finalized?
150 */
151 bool (*components_finalized)(imv_attestation_state_t *this);
152
153 /**
154 * Indicates the types of measurement errors that occurred
155 *
156 * @return Measurement error flags
157 */
158 u_int32_t (*get_measurement_error)(imv_attestation_state_t *this);
159
160 /**
161 * Call if a measurement error is encountered
162 *
163 * @param error Measurement error type
164 */
165 void (*set_measurement_error)(imv_attestation_state_t *this,
166 u_int32_t error);
167
168 };
169
170 /**
171 * Create an imv_attestation_state_t instance
172 *
173 * @param id connection ID
174 */
175 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
176
177 #endif /** IMV_ATTESTATION_STATE_H_ @}*/