decoupled request ID from files table primary key
[strongswan.git] / src / libimcv / plugins / imv_attestation / imv_attestation.c
index f4c5383..096ee5a 100644 (file)
@@ -233,6 +233,7 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
                        enumerator_t *enumerator;
                        u_int32_t delimiter = SOLIDUS_UTF;
                        char *platform_info, *pathname;
+                       u_int16_t request_id;
                        int id, type;
                        bool is_dir;
 
@@ -277,11 +278,12 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
                                is_dir = (type != 0);
                                DBG2(DBG_IMV, "measurement request %d for %s '%s'",
                                         id, is_dir ? "directory" : "file", pathname);
-                               attr = tcg_pts_attr_req_file_meas_create(is_dir, id, delimiter,
-                                                                                                                pathname);
+                               request_id = attestation_state->add_request(attestation_state,
+                                                                                                                       id, is_dir);
+                               attr = tcg_pts_attr_req_file_meas_create(is_dir, request_id,
+                                                                                                        delimiter, pathname);
                                attr->set_noskip_flag(attr, TRUE);
                                msg->add_attribute(msg, attr);
-                               attestation_state->add_request(attestation_state, id , is_dir);
                        }
                        enumerator->destroy(enumerator);
                        break;
@@ -486,7 +488,7 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
                                {
                                        tcg_pts_attr_file_meas_t *attr_cast;
                                        u_int16_t request_id;
-                                       int file_count;
+                                       int file_count, file_id;
                                        pts_meas_algorithms_t algo;
                                        pts_file_meas_t *measurements;
                                        char *platform_info;
@@ -509,7 +511,7 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
                                                 request_id, file_count, (file_count == 1) ? "":"s");
 
                                        if (!attestation_state->check_off_request(attestation_state,
-                                               request_id, &is_dir))
+                                               request_id, &file_id, &is_dir))
                                        {
                                                DBG1(DBG_IMV, "  no entry found for this request"); 
                                                break;
@@ -517,7 +519,7 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
 
                                        /* check hashes from database against measurements */
                                        e_hash = pts_db->create_hash_enumerator(pts_db, 
-                                                                       platform_info, algo, request_id, is_dir);
+                                                                       platform_info, algo, file_id, is_dir);
                                        if (!measurements->verify(measurements, e_hash, is_dir))
                                        {
                                                measurement_error = TRUE;