check IMA file measurements against database reference

This commit is contained in:
Andreas Steffen
2012-07-17 11:16:19 +02:00
parent 082b0d7249
commit 964de0abde
5 changed files with 84 additions and 9 deletions
+32
View File
@@ -39,6 +39,38 @@ struct private_pts_database_t {
};
METHOD(pts_database_t, check_file_measurement, status_t,
private_pts_database_t *this, char *product, pts_meas_algorithms_t algo,
chunk_t measurement, char *filename)
{
enumerator_t *e;
chunk_t hash;
status_t status;
e = this->db->query(this->db,
"SELECT fh.hash FROM file_hashes AS fh"
"JOIN files AS f ON f.id = fh.file"
"JOIN products AS p ON p.id = fh.product "
"WHERE p.product = ? AND f.file = ? AND fh.algo = ?",
DB_TEXT, product, DB_TEXT, filename, DB_INT, algo, DB_BLOB);
if (!e)
{
return FAILED;
}
if (e->enumerate(e, &hash))
{
status = chunk_equals(measurement, hash) ?
SUCCESS : VERIFY_ERROR;
}
else
{
status = NOT_FOUND;
}
e->destroy(e);
return status;
}
METHOD(pts_database_t, create_file_meas_enumerator, enumerator_t*,
private_pts_database_t *this, char *product)
{