ipsec attest now can measure all files in a directory
[strongswan.git] / src / libpts / pts / pts_file_meas.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_file_meas pts_file_meas
18 * @{ @ingroup pts
19 */
20
21 #ifndef PTS_FILE_MEAS_H_
22 #define PTS_FILE_MEAS_H_
23
24 #include "pts/pts_database.h"
25
26 #include <library.h>
27
28 typedef struct pts_file_meas_t pts_file_meas_t;
29
30 /**
31 * Class storing PTS File Measurements
32 */
33 struct pts_file_meas_t {
34
35 /**
36 * Get the ID of the PTS File Measurement Request
37 *
38 * @return ID of PTS File Measurement Request
39 */
40 u_int16_t (*get_request_id)(pts_file_meas_t *this);
41
42 /**
43 * Get the number of measured files
44 *
45 * @return Number of measured files
46 */
47 int (*get_file_count)(pts_file_meas_t *this);
48
49 /**
50 * Add a PTS File Measurement
51 *
52 * @param filename Name of measured file or directory
53 * @param measurement PTS Measurement hash
54 */
55 void (*add)(pts_file_meas_t *this, char *filename, chunk_t measurement);
56
57 /**
58 * Create a PTS File Measurement enumerator
59 *
60 * @return Enumerator returning filename and measurement
61 */
62 enumerator_t* (*create_enumerator)(pts_file_meas_t *this);
63
64 /**
65 * Insert PTS File Measurements into the database
66 *
67 * @param db PTS Measurement database
68 * @param product Software product (os, vpn client, etc.)
69 * @return TRUE if all measurements could be inserted
70 */
71 bool (*insert)(pts_file_meas_t *this, pts_database_t *db, char* product);
72
73 /**
74 * Verify stored hashes against PTS File Measurements
75 *
76 * @param e_hash Hash enumerator
77 * @paraem is_dir TRUE for directory contents hashes
78 * @return TRUE if all hashes match a measurement
79 */
80 bool (*verify)(pts_file_meas_t *this, enumerator_t *e_hash, bool is_dir);
81
82 /**
83 * Destroys a pts_file_meas_t object.
84 */
85 void (*destroy)(pts_file_meas_t *this);
86
87 };
88
89 /**
90 * Creates a pts_file_meas_t object
91 *
92 * @param request_id ID of PTS File Measurement Request
93 */
94 pts_file_meas_t* pts_file_meas_create(u_int16_t request_id);
95
96 /**
97 * Creates a pts_file_meas_t object measuring a file/directory
98 *
99 * @param request_id ID of PTS File Measurement Request
100 * @param pathname Absolute file or directory pathname
101 * @param is_dir TRUE if directory path
102 * @param use_rel_name TRUE if relative filenames are to be used
103 * @param alg PTS hash measurement algorithm to be used
104 */
105 pts_file_meas_t* pts_file_meas_create_from_path(u_int16_t request_id,
106 char* pathname, bool is_dir, bool use_rel_name,
107 pts_meas_algorithms_t alg);
108
109 #endif /** PTS_FILE_MEAS_H_ @}*/