aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2011-10-30 23:28:07 +0100
committerAndreas Steffen <andreas.steffen@strongswan.org>2011-11-28 14:39:53 +0100
commit645f55eb20ad6226bd17d316432ce805103a1c78 (patch)
tree3e004a3898d1117884f63adf4faf1ec757cc8cc7
parent0ee1fe15161de2a3d407316b5540ddf3a6d367c5 (diff)
downloadstrongswan-645f55eb20ad6226bd17d316432ce805103a1c78.tar.bz2
strongswan-645f55eb20ad6226bd17d316432ce805103a1c78.tar.xz
allow file and product selection in hash query
-rw-r--r--src/libimcv/plugins/imv_attestation/attest_db.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/libimcv/plugins/imv_attestation/attest_db.c b/src/libimcv/plugins/imv_attestation/attest_db.c
index 957a8e06b..652950241 100644
--- a/src/libimcv/plugins/imv_attestation/attest_db.c
+++ b/src/libimcv/plugins/imv_attestation/attest_db.c
@@ -179,7 +179,7 @@ METHOD(attest_db_t, set_fid, bool,
enumerator_t *e;
char *file;
- if (this->product_set)
+ if (this->file_set)
{
printf("file has already been set\n");
return FALSE;
@@ -394,7 +394,34 @@ METHOD(attest_db_t, list_hashes, void,
dir = strdup("");
- if (this->pid)
+ if (this->pid && this->fid)
+ {
+ e = this->db->query(this->db,
+ "SELECT hash FROM file_hashes "
+ "WHERE algo = ? AND file = ? AND directory = ? AND product = ?",
+ DB_INT, this->algo, DB_INT, this->fid, DB_INT, this->did,
+ DB_INT, this->pid, DB_BLOB);
+ if (e)
+ {
+ while (e->enumerate(e, &hash))
+ {
+ if (this->fid != fid_old)
+ {
+ printf("%3d: %s%s%s\n", this->fid, this->dir,
+ slash(this->dir, this->file) ? "/" : "", this->file);
+ fid_old = this->fid;
+ }
+ printf(" %#B\n", &hash);
+ count++;
+ }
+ e->destroy(e);
+
+ printf("%d %N value%s found for product '%s'\n", count,
+ hash_algorithm_names, pts_meas_algo_to_hash(this->algo),
+ (count == 1) ? "" : "s", this->product);
+ }
+ }
+ else if (this->pid)
{
e = this->db->query(this->db,
"SELECT f.id, f. f.path, fh.hash, fh.directory "