Replaced DH_NONCE state with TPM_INIT state
[strongswan.git] / src / libimcv / plugins / imc_attestation / imc_attestation_state.c
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 #include "imc_attestation_state.h"
17
18 #include <debug.h>
19
20 typedef struct private_imc_attestation_state_t private_imc_attestation_state_t;
21
22 /**
23 * Private data of an imc_attestation_state_t object.
24 */
25 struct private_imc_attestation_state_t {
26
27 /**
28 * Public members of imc_attestation_state_t
29 */
30 imc_attestation_state_t public;
31
32 /**
33 * TNCCS connection ID
34 */
35 TNC_ConnectionID connection_id;
36
37 /**
38 * TNCCS connection state
39 */
40 TNC_ConnectionState state;
41
42 /**
43 * PTS object
44 */
45 pts_t *pts;
46
47 };
48
49 METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
50 private_imc_attestation_state_t *this)
51 {
52 return this->connection_id;
53 }
54
55 METHOD(imc_state_t, change_state, void,
56 private_imc_attestation_state_t *this, TNC_ConnectionState new_state)
57 {
58 this->state = new_state;
59 }
60
61 METHOD(imc_state_t, destroy, void,
62 private_imc_attestation_state_t *this)
63 {
64 this->pts->destroy(this->pts);
65 free(this);
66 }
67
68 METHOD(imc_attestation_state_t, get_pts, pts_t*,
69 private_imc_attestation_state_t *this)
70 {
71 return this->pts;
72 }
73
74 /**
75 * Described in header.
76 */
77 imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
78 {
79 private_imc_attestation_state_t *this;
80 char *platform_info;
81
82 INIT(this,
83 .public = {
84 .interface = {
85 .get_connection_id = _get_connection_id,
86 .change_state = _change_state,
87 .destroy = _destroy,
88 },
89 .get_pts = _get_pts,
90 },
91 .connection_id = connection_id,
92 .state = TNC_CONNECTION_STATE_CREATE,
93 .pts = pts_create(TRUE),
94 );
95
96 platform_info = lib->settings->get_str(lib->settings,
97 "libimcv.plugins.imc-attestation.platform_info", NULL);
98 if (platform_info)
99 {
100 this->pts->set_platform_info(this->pts, platform_info);
101 }
102
103 return &this->public.interface;
104 }
105
106