added the IMV_ATTESTATION_STATE_NONCE_REQ state
[strongswan.git] / src / libimcv / 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 <library.h>
28
29 typedef struct imv_attestation_state_t imv_attestation_state_t;
30 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
31
32 /**
33 * IMV Attestation Handshake States (state machine)
34 */
35 enum imv_attestation_handshake_state_t {
36 IMV_ATTESTATION_STATE_INIT,
37 IMV_ATTESTATION_STATE_NONCE_REQ,
38 IMV_ATTESTATION_STATE_TPM_INIT,
39 IMV_ATTESTATION_STATE_MEAS,
40 IMV_ATTESTATION_STATE_COMP_EVID,
41 IMV_ATTESTATION_STATE_END,
42 };
43
44 /**
45 * Internal state of an imv_attestation_t connection instance
46 */
47 struct imv_attestation_state_t {
48
49 /**
50 * imv_state_t interface
51 */
52 imv_state_t interface;
53
54 /**
55 * Get state of the handshake
56 *
57 * @return the handshake state of IMV
58 */
59 imv_attestation_handshake_state_t (*get_handshake_state)(imv_attestation_state_t *this);
60
61 /**
62 * Set state of the handshake
63 *
64 * @param new_state the handshake state of IMV
65 */
66 void (*set_handshake_state)(imv_attestation_state_t *this,
67 imv_attestation_handshake_state_t new_state);
68
69 /**
70 * Get the PTS object
71 *
72 * @return PTS object
73 */
74 pts_t* (*get_pts)(imv_attestation_state_t *this);
75
76 /**
77 * Add an entry to the list of pending file/directory measurement requests
78 *
79 * @param file_id primary key into file table
80 * @param is_dir TRUE if directory
81 * @return unique request ID
82 */
83 u_int16_t (*add_request)(imv_attestation_state_t *this, int file_id,
84 bool is_dir);
85
86 /**
87 * Returns the number of pending file/directory measurement requests
88 *
89 * @return number of pending requests
90 */
91 int (*get_request_count)(imv_attestation_state_t *this);
92
93 /**
94 * Check for presence of request_id and if found remove it from the list
95 *
96 * @param id unique request ID
97 * @param file_id primary key into file table
98 * @param is_dir return TRUE if request was for a directory
99 * @return TRUE if request ID found, FALSE otherwise
100 */
101 bool (*check_off_request)(imv_attestation_state_t *this, u_int16_t id,
102 int *file_id, bool *is_dir);
103
104 /**
105 * Indicates if a file measurement error occurred
106 *
107 * @return TRUE in case of measurement error
108 */
109 bool (*get_measurement_error)(imv_attestation_state_t *this);
110
111 /**
112 * Call if a file measurement error is encountered
113 */
114 void (*set_measurement_error)(imv_attestation_state_t *this);
115
116 };
117
118 /**
119 * Create an imv_attestation_state_t instance
120 *
121 * @param id connection ID
122 */
123 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
124
125 #endif /** IMV_ATTESTATION_STATE_H_ @}*/