Moved hashing functionalities to pts object
[strongswan.git] / src / libimcv / tcg / 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_proto_caps.h"
27 #include "pts_meas_algo.h"
28 #include <utils/linked_list.h>
29
30 #include <library.h>
31
32 typedef struct measurement_req_entry_t measurement_req_entry_t;
33 typedef struct file_meas_entry_t file_meas_entry_t;
34
35 /**
36 * Struct to hold file or directory name with the request ID for Request File Measurement attribute
37 */
38 struct measurement_req_entry_t {
39 char *path;
40 u_int16_t request_id;
41 };
42
43 /**
44 * File Measurement entry
45 */
46 struct file_meas_entry_t {
47 chunk_t measurement;
48 u_int16_t file_name_len;
49 chunk_t file_name;
50 };
51
52 /**
53 * Class implementing the TCG Platform Trust System (PTS)
54 *
55 */
56 struct pts_t {
57
58 /**
59 * Get PTS Protocol Capabilities
60 *
61 * @return protocol capabilities flags
62 */
63 pts_proto_caps_flag_t (*get_proto_caps)(pts_t *this);
64
65 /**
66 * Set PTS Protocol Capabilities
67 *
68 * @param flags protocol capabilities flags
69 */
70 void (*set_proto_caps)(pts_t *this, pts_proto_caps_flag_t flags);
71
72 /**
73 * Get PTS Measurement Algorithm
74 *
75 * @return measurement algorithm
76 */
77 pts_meas_algorithms_t (*get_meas_algorithm)(pts_t *this);
78
79 /**
80 * Set PTS Measurement Algorithm
81 *
82 * @param algorithm measurement algorithm
83 */
84 void (*set_meas_algorithm)(pts_t *this, pts_meas_algorithms_t algorithm);
85
86 /**
87 * Get TPM 1.2 Version Info
88 *
89 * @param info chunk containing a TPM_CAP_VERSION_INFO struct
90 * @return TRUE if TPM Version Info available
91 */
92 bool (*get_tpm_version_info)(pts_t *this, chunk_t *info);
93
94 /**
95 * Set TPM 1.2 Version Info
96 *
97 * @param info chunk containing a TPM_CAP_VERSION_INFO struct
98 */
99 void (*set_tpm_version_info)(pts_t *this, chunk_t info);
100
101 /**
102 * Hash the given file
103 *
104 * @param path absolute path to file to be hashed
105 * @param out hash output value of a given file
106 * @return TRUE if hashing file was successful
107 */
108 bool (*hash_file)(pts_t *this, char *path, char *out);
109
110 /**
111 * Hash the given directory
112 *
113 * @param path absolute path to directory to be hashed
114 * @param file_measurements list of hash output values of files in a given folder
115 * @return TRUE if hashing directory was successful
116 */
117 bool (*hash_directory)(pts_t *this, char *path, linked_list_t *file_measurements);
118
119 /**
120 * Destroys a pts_t object.
121 */
122 void (*destroy)(pts_t *this);
123
124 };
125
126 /**
127 * Creates an pts_t object
128 *
129 * @param is_imc TRUE if running on an IMC
130 */
131 pts_t* pts_create(bool is_imc);
132
133 #endif /** PTS_H_ @}*/