2 * Copyright (C) 2011 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup pts_database pts_database
21 #ifndef PTS_DATABASE_H_
22 #define PTS_DATABASE_H_
24 typedef struct pts_database_t pts_database_t
;
26 #include "pts_meas_algo.h"
27 #include "components/pts_comp_func_name.h"
31 * Class implementing the PTS File Measurement database
34 struct pts_database_t
{
37 * Get files/directories to be measured by PTS
39 * @param product Software product (os, vpn client, etc.)
40 * @return Enumerator over all matching files/directories
42 enumerator_t
* (*create_file_meas_enumerator
)(pts_database_t
*this,
46 * Get files/directories to request metadata of
48 * @param product Software product (os, vpn client, etc.)
49 * @return Enumerator over all matching files/directories
51 enumerator_t
* (*create_file_meta_enumerator
)(pts_database_t
*this,
55 * Get stored measurement hash for single file or directory entries
57 * @param product Software product (os, vpn client, etc.)
58 * @param algo Hash algorithm used for measurement
59 * @param id Primary key of measured file/directory
60 * @param is_dir TRUE if directory was measured
61 * @return Enumerator over all matching measurement hashes
63 enumerator_t
* (*create_file_hash_enumerator
)(pts_database_t
*this,
64 char *product
, pts_meas_algorithms_t algo
,
68 * Get functional components to request evidence of
70 * @param keyid SHA-1 hash of AIK public key info
71 * @return Enumerator over all matching components
73 enumerator_t
* (*create_comp_evid_enumerator
)(pts_database_t
*this,
77 * Check a functional component measurement against value stored in database
79 * @param measurement measurement hash
80 * @param cid Primary key of Component Functional Name entry
81 * @param kid Primary key of AIK entry in keys table
82 * @param seq_no Measurement sequence number
83 * @param prc Number of the PCR the measurement was extended into
84 * @param algo Hash algorithm used for measurement
85 * @return SUCCESS if check was successful
87 status_t (*check_comp_measurement
)(pts_database_t
*this, chunk_t measurement
,
88 int cid
, int kid
, int seq_no
, int pcr
,
89 pts_meas_algorithms_t algo
);
92 * Insert a functional component measurement into the database
94 * @param measurement Measurement hash
95 * @param cid Primary key of Component Functional Name entry
96 * @param kid Primary key of AIK entry in keys table
97 * @param seq_no Measurement sequence number
98 * @param prc Number of the PCR the measurement was extended into
99 * @param algo Hash algorithm used for measurement
100 * @return SUCCESS if INSERT was successful
102 status_t (*insert_comp_measurement
)(pts_database_t
*this, chunk_t measurement
,
103 int cid
, int kid
, int seq_no
, int pcr
,
104 pts_meas_algorithms_t algo
);
107 * Delete functional component measurements from the database
109 * @param cid Primary key of Component Functional Name entry
110 * @param kid Primary key of AIK entry in keys table
111 * @return number of deleted measurement entries
113 int (*delete_comp_measurements
)(pts_database_t
*this, int cid
, int kid
);
116 * Get the number of measurements for a functional component and AIK
118 * @param comp_name Component Functional Name
119 * @param keyid SHA-1 hash of AIK public key info
120 * @param algo Hash algorithm used for measurement
121 * @param cid Primary key of Component Functional Name entry
122 * @param kid Primary key of AIK entry in keys table
123 * @param count measurement count
124 * @return SUCCESS if COUNT was successful
126 status_t (*get_comp_measurement_count
)(pts_database_t
*this,
127 pts_comp_func_name_t
*comp_name
, chunk_t keyid
,
128 pts_meas_algorithms_t algo
, int *cid
, int *kid
,
132 * Destroys a pts_database_t object.
134 void (*destroy
)(pts_database_t
*this);
139 * Creates an pts_database_t object
141 * @param uri database uri
143 pts_database_t
* pts_database_create(char *uri
);
145 #endif /** PTS_DATABASE_H_ @}*/