aboutsummaryrefslogtreecommitdiffstats
path: root/src/libimcv/tcg/pts/pts.h
blob: f88effa8d835d4637968c2daca321b206c706b36 (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
/*
 * Copyright (C) 2011 Sansar Choinyambuu
 * 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 pts pts
 * @{ @ingroup pts
 */

#ifndef PTS_H_
#define PTS_H_

typedef struct pts_t pts_t;

#include "pts_proto_caps.h"
#include "pts_meas_algo.h"
#include <utils/linked_list.h>


#include <library.h>

typedef struct file_meas_entry_t file_meas_entry_t;

/**
 * File Measurement entry
 */
struct file_meas_entry_t {
	chunk_t   measurement;
	u_int16_t file_name_len;
	chunk_t   file_name;
};

/**
 * Class implementing the TCG Platform Trust System (PTS)
 *
 */
struct pts_t {

	/**
	 * Get PTS Protocol Capabilities
	 *
	 * @return				protocol capabilities flags 
	 */
	pts_proto_caps_flag_t (*get_proto_caps)(pts_t *this);

	/**
	 * Set PTS Protocol Capabilities
	 *
	 * @param flags			protocol capabilities flags 
	 */
	void (*set_proto_caps)(pts_t *this, pts_proto_caps_flag_t flags);

	/**
	 * Get PTS Measurement Algorithm
	 *
	 * @return				measurement algorithm 
	 */
	pts_meas_algorithms_t (*get_meas_algorithm)(pts_t *this);

	/**
	 * Set PTS Measurement Algorithm
	 *
	 * @param algorithm		measurement algorithm 
	 */
	void (*set_meas_algorithm)(pts_t *this, pts_meas_algorithms_t algorithm);

	/**
	 * Get TPM 1.2 Version Info
	 *
	 * @param info			chunk containing a TPM_CAP_VERSION_INFO struct
	 * @return				TRUE if TPM Version Info available 
	 */
	bool (*get_tpm_version_info)(pts_t *this, chunk_t *info);

	/**
	 * Set TPM 1.2 Version Info
	 *
	 * @param info			chunk containing a TPM_CAP_VERSION_INFO struct 
	 */
	void (*set_tpm_version_info)(pts_t *this, chunk_t info);
	
	/**
	 * Get Attestation Identity Key
	 *
	 * @param aik			chunk containing a AIK naked public key or certificate
	 * @param is_naked_key		TRUE if AIK is naked public key, without certificate
	 * @return			TRUE if AIK available
	 */
	bool (*get_aik)(pts_t *this, chunk_t *aik, bool *is_naked_key);
	
	/**
	 * Set Attestation Identity Key
	 *
	 * @param aik			chunk containing a AIK naked public key or certificate 
	 * @param is_naked_key		TRUE if AIK is naked public key, without certificate
	 */
	void (*set_aik)(pts_t *this, chunk_t aik, bool is_naked_key);
	
	/**
	 * Hash the given file
	 *
	 * @param path			absolute path to file to be hashed
	 * @param out			hash output value of a given file
	 * @return			TRUE if hashing file was successful 
	 */
	bool (*hash_file)(pts_t *this, chunk_t path, chunk_t *out);
	
	/**
	 * Hash the given directory
	 *
	 * @param path			absolute path to directory to be hashed
	 * @param file_measurements	list of hash output values of files in a given folder
	 * @return			TRUE if hashing directory was successful 
	 */
	bool (*hash_directory)(pts_t *this, chunk_t path, linked_list_t **file_measurements);

	/**
	 * Destroys a pts_t object.
	 */
	void (*destroy)(pts_t *this);

};

/**
 * Creates an pts_t object
 *
 * @param is_imc			TRUE if running on an IMC
 */
pts_t* pts_create(bool is_imc);

#endif /** PTS_H_ @}*/