register _check_file_measurement() method
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 17 Jul 2012 11:42:58 +0000 (13:42 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 17 Jul 2012 11:42:58 +0000 (13:42 +0200)
src/libpts/pts/pts_database.c
src/libpts/pts/pts_database.h

index 97de819..1c1812a 100644 (file)
@@ -39,38 +39,6 @@ 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)
 {
@@ -153,6 +121,38 @@ METHOD(pts_database_t, check_aik_keyid, status_t,
        return SUCCESS;
 }
 
+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_comp_evid_enumerator, enumerator_t*,
        private_pts_database_t *this, int kid)
 {
@@ -322,6 +322,7 @@ pts_database_t *pts_database_create(char *uri)
                        .create_comp_evid_enumerator = _create_comp_evid_enumerator,
                        .create_file_hash_enumerator = _create_file_hash_enumerator,
                        .check_aik_keyid = _check_aik_keyid,
+                       .check_file_measurement = _check_file_measurement,
                        .check_comp_measurement = _check_comp_measurement,
                        .insert_comp_measurement = _insert_comp_measurement,
                        .delete_comp_measurements = _delete_comp_measurements,
index 94acd33..649ef0e 100644 (file)
@@ -37,19 +37,6 @@ struct pts_database_t {
        * Get files/directories to be measured by PTS
        *
        * @param product                Software product (os, vpn client, etc.)
-       * @param algo                   File measurement hash algorithm used
-       * @param measurement    File measurement hash
-       * @param filename               Optional name of the file to be checked
-       * @return                               Status
-       */
-       status_t (*check_file_measurement)(pts_database_t *this, char *product,
-                                                                          pts_meas_algorithms_t algo,
-                                                                          chunk_t measurement, char *filename);
-
-       /**
-       * Get files/directories to be measured by PTS
-       *
-       * @param product                Software product (os, vpn client, etc.)
        * @return                               Enumerator over all matching files/directories
        */
        enumerator_t* (*create_file_meas_enumerator)(pts_database_t *this,
@@ -95,6 +82,19 @@ struct pts_database_t {
        enumerator_t* (*create_comp_evid_enumerator)(pts_database_t *this, int kid);
 
        /**
+       * Check PTS file measurement against reference stored in database
+       *
+       * @param product                Software product (os, vpn client, etc.)
+       * @param algo                   File measurement hash algorithm used
+       * @param measurement    File measurement hash
+       * @param filename               Optional name of the file to be checked
+       * @return                               Status
+       */
+       status_t (*check_file_measurement)(pts_database_t *this, char *product,
+                                                                          pts_meas_algorithms_t algo,
+                                                                          chunk_t measurement, char *filename);
+
+       /**
        * Check a functional component measurement against value stored in database
        *
        * @param measurement    measurement hash