]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Set pcr transform field depending on measuring algorithm
authorSansar Choinyambuu <schoinya@hsr.ch>
Wed, 23 Nov 2011 11:02:00 +0000 (12:02 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 20:22:51 +0000 (21:22 +0100)
src/libimcv/plugins/imv_attestation/data.sql
src/libpts/pts/components/ita/ita_comp_tboot.c
src/libpts/pts/components/ita/ita_comp_tgrub.c

index ad5efb2d2d509c9c327966c9189855c5ee91512d..7769223fead9df2533481ae7381b209a71a8b5ee 100644 (file)
@@ -426,30 +426,12 @@ INSERT INTO product_file (
   7, 22
 );
 
-INSERT INTO product_file (
-  product, file
-) VALUES (
-  7, 23
-);
-
-INSERT INTO product_file (
-  product, file
-) VALUES (
-  7, 24
-);
-
 /* Product Component */
 
 INSERT INTO product_component (
   product, component, depth, sequence
 ) VALUES (
-  4, 2, 0, 2
-);
-
-INSERT INTO product_component (
-  product, component, depth, sequence
-) VALUES (
-  7, 2, 0, 2
+  4, 2, 0, 1
 );
 
 /* File Hashes */
index beb2a5283731c9562f76334a85d2fdfcfbeb0c8f..5ab6dc8444e2f48bce686cffe016c4d6931ceabf 100644 (file)
@@ -81,6 +81,8 @@ METHOD(pts_component_t, measure, status_t,
        pts_comp_evidence_t *evid;
        char *meas_hex, *pcr_before_hex, *pcr_after_hex;
        chunk_t measurement, pcr_before, pcr_after;
+       pts_pcr_transform_t pcr_transform;
+       pts_meas_algorithms_t hash_algo;
        
        switch (this->extended_pcr)
        {
@@ -109,6 +111,19 @@ METHOD(pts_component_t, measure, status_t,
                        return FAILED;
        }
 
+       hash_algo = pts->get_meas_algorithm(pts);
+       switch (hash_algo)
+       {
+               case PTS_MEAS_ALGO_SHA1:
+                       pcr_transform = PTS_PCR_TRANSFORM_MATCH;
+               case PTS_MEAS_ALGO_SHA256:
+               case PTS_MEAS_ALGO_SHA384:
+                       pcr_transform = PTS_PCR_TRANSFORM_LONG;
+               case PTS_MEAS_ALGO_NONE:
+               default:
+                       pcr_transform = PTS_PCR_TRANSFORM_NO;
+       }
+
        measurement = chunk_from_hex(
                                        chunk_create(meas_hex, strlen(meas_hex)), NULL);
        pcr_before = chunk_from_hex(
@@ -117,11 +132,13 @@ METHOD(pts_component_t, measure, status_t,
                                        chunk_create(pcr_after_hex, strlen(pcr_after_hex)), NULL);
 
        evid = *evidence = pts_comp_evidence_create(this->name->clone(this->name),
-                                                               0, this->extended_pcr,
-                                                               PTS_MEAS_ALGO_SHA1, PTS_PCR_TRANSFORM_NO,
+                                                               this->depth, this->extended_pcr,
+                                                               hash_algo, pcr_transform,
                                                                this->measurement_time, measurement);
        evid->set_pcr_info(evid, pcr_before, pcr_after);
 
+
+
        return (this->extended_pcr == PCR_TBOOT_MLE) ? SUCCESS : NEED_MORE;
 }
 
@@ -170,10 +187,10 @@ METHOD(pts_component_t, verify, status_t,
        {
                return FAILED;
        }
-
+       
        /* check measurement in database */
        enumerator = pts_db->create_comp_hash_enumerator(pts_db, file,
-                                                               platform_info, this->name, algo);
+                                                               platform_info, this->name, TRUSTED_HASH_ALGO);
        while (enumerator->enumerate(enumerator, &hash))
        {
                if (!chunk_equals(hash, measurement))
index d74451fdf653edbb33005163736119b429cd549e..d54333361f7e6e012855efb6f7fb4f4cc2c5bfe3 100644 (file)
@@ -71,6 +71,8 @@ METHOD(pts_component_t, measure, status_t,
        u_int32_t extended_pcr;
        time_t measurement_time;
        chunk_t measurement, pcr_before, pcr_after;
+       pts_pcr_transform_t pcr_transform;
+       pts_meas_algorithms_t hash_algo;
 
        /* Provisional implementation for TGRUB */
        extended_pcr = PCR_DEBUG;
@@ -82,6 +84,19 @@ METHOD(pts_component_t, measure, status_t,
                return FAILED;
        }
 
+       hash_algo = pts->get_meas_algorithm(pts);
+       switch (hash_algo)
+       {
+               case PTS_MEAS_ALGO_SHA1:
+                       pcr_transform = PTS_PCR_TRANSFORM_MATCH;
+               case PTS_MEAS_ALGO_SHA256:
+               case PTS_MEAS_ALGO_SHA384:
+                       pcr_transform = PTS_PCR_TRANSFORM_LONG;
+               case PTS_MEAS_ALGO_NONE:
+               default:
+                       pcr_transform = PTS_PCR_TRANSFORM_NO;
+       }
+
        measurement = chunk_alloc(HASH_SIZE_SHA1);
        memset(measurement.ptr, 0x00, measurement.len);
                
@@ -89,8 +104,8 @@ METHOD(pts_component_t, measure, status_t,
        memset(pcr_before.ptr, 0x00, pcr_before.len);
 
        evid = *evidence = pts_comp_evidence_create(this->name->clone(this->name),
-                                                               0, extended_pcr,
-                                                               PTS_MEAS_ALGO_SHA1, PTS_PCR_TRANSFORM_NO,
+                                                               this->depth, extended_pcr,
+                                                               hash_algo, pcr_transform,
                                                                measurement_time, measurement);
        evid->set_pcr_info(evid, pcr_before, pcr_after);