Started implementing handling of DH Nonce attributes
[strongswan.git] / src / libpts / pts / pts.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 * @defgroup pts pts
18 * @{ @ingroup pts
19 */
20
21 #ifndef PTS_H_
22 #define PTS_H_
23
24 typedef struct pts_t pts_t;
25
26 #include "pts_error.h"
27 #include "pts_proto_caps.h"
28 #include "pts_meas_algo.h"
29 #include "pts_file_meas.h"
30 #include "pts_file_meta.h"
31 #include "pts_dh_group.h"
32
33 #include <library.h>
34
35 /**
36 * UTF-8 encoding of the character used to delimiter the filename
37 */
38 #define SOLIDUS_UTF 0x2F
39 #define REVERSE_SOLIDUS_UTF 0x5C
40
41 /**
42 * Class implementing the TCG Platform Trust System (PTS)
43 *
44 */
45 struct pts_t {
46
47 /**
48 * Get PTS Protocol Capabilities
49 *
50 * @return protocol capabilities flags
51 */
52 pts_proto_caps_flag_t (*get_proto_caps)(pts_t *this);
53
54 /**
55 * Set PTS Protocol Capabilities
56 *
57 * @param flags protocol capabilities flags
58 */
59 void (*set_proto_caps)(pts_t *this, pts_proto_caps_flag_t flags);
60
61 /**
62 * Get PTS Measurement Algorithm
63 *
64 * @return measurement algorithm
65 */
66 pts_meas_algorithms_t (*get_meas_algorithm)(pts_t *this);
67
68 /**
69 * Set PTS Measurement Algorithm
70 *
71 * @param algorithm measurement algorithm
72 */
73 void (*set_meas_algorithm)(pts_t *this, pts_meas_algorithms_t algorithm);
74
75 /**
76 * Get PTS Diffie Hellman Group
77 *
78 * @return DH Group
79 */
80 pts_dh_group_t (*get_dh_group)(pts_t *this);
81
82 /**
83 * Set PTS Diffie Hellman Group
84 *
85 * @param dh_group DH Group
86 */
87 void (*set_dh_group)(pts_t *this, pts_dh_group_t dh_group);
88
89 /**
90 * Get Platform and OS Info
91 *
92 * @return platform and OS info
93 */
94 char* (*get_platform_info)(pts_t *this);
95
96 /**
97 * Set Platform and OS Info
98 *
99 * @param info platform and OS info
100 */
101 void (*set_platform_info)(pts_t *this, char *info);
102
103 /**
104 * Get TPM 1.2 Version Info
105 *
106 * @param info chunk containing a TPM_CAP_VERSION_INFO struct
107 * @return TRUE if TPM Version Info available
108 */
109 bool (*get_tpm_version_info)(pts_t *this, chunk_t *info);
110
111 /**
112 * Set TPM 1.2 Version Info
113 *
114 * @param info chunk containing a TPM_CAP_VERSION_INFO struct
115 */
116 void (*set_tpm_version_info)(pts_t *this, chunk_t info);
117
118 /**
119 * Get Attestation Identity Certificate or Public Key
120 *
121 * @return AIK Certificate or Public Key
122 */
123 certificate_t* (*get_aik)(pts_t *this);
124
125 /**
126 * Set Attestation Identity Certificate or Public Key
127 *
128 * @param aik AIK Certificate or Public Key
129 */
130 void (*set_aik)(pts_t *this, certificate_t *aik);
131
132 /**
133 * Check whether path is valid file/directory on filesystem
134 *
135 * @param path Absolute path
136 * @param error_code Output variable for PTS error code
137 * @return TRUE if path is valid or file/directory doesn't exist
138 * or path is invalid
139 * FALSE if local error occurred within stat function
140 */
141 bool (*is_path_valid)(pts_t *this, char *path, pts_error_code_t *error_code);
142
143 /**
144 * Do PTS File Measurements
145 *
146 * @param request_id ID of PTS File Measurement Request
147 * @param pathname Absolute pathname of file to be measured
148 * @param is_directory if TRUE directory contents are measured
149 * @return PTS File Measurements of NULL if FAILED
150 */
151 pts_file_meas_t* (*do_measurements)(pts_t *this, u_int16_t request_id,
152 char *pathname, bool is_directory);
153
154 /**
155 * Obtain file metadata
156 *
157 * @param pathname Absolute pathname of file/directory
158 * @param is_directory if TRUE directory contents are requested
159 * @return PTS File Metadata or NULL if FAILED
160 */
161 pts_file_meta_t* (*get_metadata)(pts_t *this, char *pathname, bool is_directory);
162
163 /**
164 * Destroys a pts_t object.
165 */
166 void (*destroy)(pts_t *this);
167
168 };
169
170 /**
171 * Creates an pts_t object
172 *
173 * @param is_imc TRUE if running on an IMC
174 */
175 pts_t* pts_create(bool is_imc);
176
177 #endif /** PTS_H_ @}*/