summaryrefslogtreecommitdiff
path: root/src/libpts/plugins/imv_attestation/attest_db.h
blob: e2297d0c4e53e34491a9cd56c898abed780dba2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
 * Copyright (C) 2011 Andreas Steffen
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

/**
 *
 * @defgroup attest_db_t attest_db
 * @{ @ingroup attest_db
 */

#ifndef ATTEST_DB_H_
#define ATTEST_DB_H_

#include <pts/pts_meas_algo.h>
#include <os_info/os_info.h>
#include <library.h>

typedef struct attest_db_t attest_db_t;

/**
 * Attestation database object
 */
struct attest_db_t {

	/**
	 * Set functional component to be queried
	 *
	 * @param comp			functional component
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_component)(attest_db_t *this, char *comp, bool create);

	/**
	 * Set primary key of the functional component to be queried
	 *
	 * @param fid			primary key of functional component
	 * @return				TRUE if successful
	 */
	bool (*set_cid)(attest_db_t *this, int fid);

	/**
	 * Set directory to be queried
	 *
	 * @param dir			directory
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_directory)(attest_db_t *this, char *dir, bool create);

	/**
	 * Set primary key of the directory to be queried
	 *
	 * @param did			primary key of directory
	 * @return				TRUE if successful
	 */
	bool (*set_did)(attest_db_t *this, int did);

	/**
	 * Set measurement file to be queried
	 *
	 * @param file			measurement file
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_file)(attest_db_t *this, char *file, bool create);

	/**
	 * Set primary key of the measurement file to be queried
	 *
	 * @param fid			primary key of measurement file
	 * @return				TRUE if successful
	 */
	bool (*set_fid)(attest_db_t *this, int fid);

	/**
	 * Set functional component to be queried
	 *
	 * @param key			AIK
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_key)(attest_db_t *this, chunk_t key, bool create);

	/**
	 * Set primary key of the AIK to be queried
	 *
	 * @param kid			primary key of AIK
	 * @return				TRUE if successful
	 */
	bool (*set_kid)(attest_db_t *this, int kid);

	/**
	 * Set software package to be queried
	 *
	 * @param product		software package
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_package)(attest_db_t *this, char *package, bool create);

	/**
	 * Set primary key of the software package to be queried
	 *
	 * @param gid			primary key of software package
	 * @return				TRUE if successful
	 */
	bool (*set_gid)(attest_db_t *this, int gid);

	/**
	 * Set software product to be queried
	 *
	 * @param product		software product
	 * @param create		if TRUE create database entry if it doesn't exist
	 * @return				TRUE if successful
	 */
	bool (*set_product)(attest_db_t *this, char *product, bool create);

	/**
	 * Set primary key of the software product to be queried
	 *
	 * @param pid			primary key of software product
	 * @return				TRUE if successful
	 */
	bool (*set_pid)(attest_db_t *this, int pid);

	/**
	 * Set software package version to be queried
	 *
	 * @param version		software package version
	 * @return				TRUE if successful
	 */
	bool (*set_version)(attest_db_t *this, char *version);

	/**
	 * Set measurement hash algorithm
	 *
	 * @param algo			hash algorithm
	 */
	void (*set_algo)(attest_db_t *this, pts_meas_algorithms_t algo);

	/**
	 * Set that the IMA-specific SHA-1 template hash be computed
	 */
	void (*set_ima)(attest_db_t *this);

	/**
	 * Set that relative filenames are to be used
	 */
	void (*set_relative)(attest_db_t *this);

	/**
	 * Set the package security state
	 */
	void (*set_security)(attest_db_t *this, os_package_state_t security);

	/**
	 * Set the sequence number
	 */
	void (*set_sequence)(attest_db_t *this, int seq_no);

	/**
	 * Set owner [user/host] of an AIK
	 *
	 * @param owner			user/host name
	 * @return				TRUE if successful
	 */
	void (*set_owner)(attest_db_t *this, char *owner);

	/**
	 * Display all dates in UTC
	 */
	void (*set_utc)(attest_db_t *this);

	/**
	 * List all packages stored in the database
	 */
	void (*list_packages)(attest_db_t *this);

	/**
	 * List all products stored in the database
	 */
	void (*list_products)(attest_db_t *this);

	/**
	 * List selected files stored in the database
	 */
	void (*list_files)(attest_db_t *this);

	/**
	 * List all components stored in the database
	 */
	void (*list_components)(attest_db_t *this);

	/**
	 * List all devices stored in the database
	 */
	void (*list_devices)(attest_db_t *this);

	/**
	 * List all AIKs stored in the database
	 */
	void (*list_keys)(attest_db_t *this);

	/**
	 * List selected measurement hashes stored in the database
	 */
	void (*list_hashes)(attest_db_t *this);

	/**
	 * List selected component measurement stored in the database
	 */
	void (*list_measurements)(attest_db_t *this);

	/**
	 * Add an entry to the database
	 */
	bool (*add)(attest_db_t *this);

	/**
	 * Delete an entry from the database
	 */
	bool (*delete)(attest_db_t *this);

	/**
	 * Destroy attest_db_t object
	 */
	void (*destroy)(attest_db_t *this);

};

/**
 * Create an attest_db_t instance
 *
 * @param uri				database URI
 */
attest_db_t* attest_db_create(char *uri);

#endif /** ATTEST_DB_H_ @}*/