additional state waiting for the EvidenceFinal attribute response
[strongswan.git] / src / libpts / plugins / imv_attestation / imv_attestation_state.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 *
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/components/pts_component.h>
28 #include <library.h>
29
30 typedef struct imv_attestation_state_t imv_attestation_state_t;
31 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
32
33 /**
34 * IMV Attestation Handshake States (state machine)
35 */
36 enum imv_attestation_handshake_state_t {
37 IMV_ATTESTATION_STATE_INIT,
38 IMV_ATTESTATION_STATE_NONCE_REQ,
39 IMV_ATTESTATION_STATE_TPM_INIT,
40 IMV_ATTESTATION_STATE_MEAS,
41 IMV_ATTESTATION_STATE_COMP_EVID,
42 IMV_ATTESTATION_STATE_EVID_FINAL,
43 IMV_ATTESTATION_STATE_END,
44 };
45
46 /**
47 * Internal state of an imv_attestation_t connection instance
48 */
49 struct imv_attestation_state_t {
50
51 /**
52 * imv_state_t interface
53 */
54 imv_state_t interface;
55
56 /**
57 * Get state of the handshake
58 *
59 * @return the handshake state of IMV
60 */
61 imv_attestation_handshake_state_t (*get_handshake_state)(
62 imv_attestation_state_t *this);
63
64 /**
65 * Set state of the handshake
66 *
67 * @param new_state the handshake state of IMV
68 */
69 void (*set_handshake_state)(imv_attestation_state_t *this,
70 imv_attestation_handshake_state_t new_state);
71
72 /**
73 * Get the PTS object
74 *
75 * @return PTS object
76 */
77 pts_t* (*get_pts)(imv_attestation_state_t *this);
78
79 /**
80 * Add an entry to the list of pending file/directory measurement requests
81 *
82 * @param file_id primary key into file table
83 * @param is_dir TRUE if directory
84 * @return unique request ID
85 */
86 u_int16_t (*add_file_meas_request)(imv_attestation_state_t *this,
87 int file_id, bool is_dir);
88
89 /**
90 * Returns the number of pending file/directory measurement requests
91 *
92 * @return number of pending requests
93 */
94 int (*get_file_meas_request_count)(imv_attestation_state_t *this);
95
96 /**
97 * Check for presence of request_id and if found remove it from the list
98 *
99 * @param id unique request ID
100 * @param file_id primary key into file table
101 * @param is_dir return TRUE if request was for a directory
102 * @return TRUE if request ID found, FALSE otherwise
103 */
104 bool (*check_off_file_meas_request)(imv_attestation_state_t *this,
105 u_int16_t id, int *file_id, bool *is_dir);
106
107 /**
108 * Add an entry to the list of Functional Components waiting for evidence
109 *
110 * @param entry Functional Component
111 */
112 void (*add_component)(imv_attestation_state_t *this, pts_component_t *entry);
113
114 /**
115 * Returns the number of Functional Component waiting for evidence
116 *
117 * @return Number of waiting Functional Components
118 */
119 int (*get_component_count)(imv_attestation_state_t *this);
120
121 /**
122 * Check for presence of Functional Component and remove and return it
123 *
124 * @param name Name of the requested Functional Component
125 * @return Functional Component if found, NULL otherwise
126 */
127 pts_component_t* (*check_off_component)(imv_attestation_state_t *this,
128 pts_comp_func_name_t *name);
129
130 /**
131 * Tell the Functional Components to finalize any measurement registrations
132 */
133 void (*check_off_registrations)(imv_attestation_state_t *this);
134
135 /**
136 * Indicates if a file measurement error occurred
137 *
138 * @return TRUE in case of measurement error
139 */
140 bool (*get_measurement_error)(imv_attestation_state_t *this);
141
142 /**
143 * Call if a file measurement error is encountered
144 */
145 void (*set_measurement_error)(imv_attestation_state_t *this);
146
147 };
148
149 /**
150 * Create an imv_attestation_state_t instance
151 *
152 * @param id connection ID
153 */
154 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
155
156 #endif /** IMV_ATTESTATION_STATE_H_ @}*/