Factored IMC/V Attestation build/process of Component Functional Name
[strongswan.git] / src / libimcv / plugins / imv_attestation / imv_attestation_build.c
index 3f21afa..d4ec8a6 100644 (file)
@@ -16,6 +16,7 @@
 #include "imv_attestation_build.h"
 #include "imv_attestation_state.h"
 
+#include <libpts.h>
 #include <tcg/tcg_pts_attr_proto_caps.h>
 #include <tcg/tcg_pts_attr_meas_algo.h>
 #include <tcg/tcg_pts_attr_dh_nonce_params_req.h>
@@ -207,22 +208,21 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
                }
                case IMV_ATTESTATION_STATE_COMP_EVID:
                {
-                       pts_attr_req_funct_comp_evid_flag_t flags;
-                       u_int32_t sub_comp_depth;
-                       pts_qualifier_t qualifier;
-                       pts_ita_funct_comp_name_t name;
                        enumerator_t *enumerator;
-                       char *platform_info, *pathname;
+                       /* TODO: pts_components undeclared */
+                       /*char flags[8];
+                       int type;
+                       */
+                       char *platform_info;
+                       pts_funct_comp_evid_req_t *requests = NULL;
+                       funct_comp_evid_req_entry_t *entry;
+                       int vid, name, qualifier;
+                       
+                       bool first_req = TRUE;
 
                        attestation_state->set_handshake_state(attestation_state,
                                                                                IMV_ATTESTATION_STATE_END);
 
-                       flags = PTS_REQ_FUNC_COMP_FLAG_PCR;
-                       sub_comp_depth = 0;
-                       qualifier.kernel = FALSE;
-                       qualifier.sub_component = FALSE;
-                       qualifier.type = PTS_ITA_FUNC_COMP_TYPE_TRUSTED;
-
                        /* Get Platform and OS of the PTS-IMC */
                        platform_info = pts->get_platform_info(pts);
                        if (!pts_db || !platform_info)
@@ -236,41 +236,45 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
                        DBG1(DBG_IMV, "platform is '%s'", platform_info);
 
                        
-                       enumerator = pts_db->create_comp_evid_enumerator(pts_db,
-                                                                                                                        platform_info);
+                       enumerator = pts_db->create_comp_evid_enumerator(pts_db, platform_info);
                        if (!enumerator)
                        {
                                break;
                        }
-                       while (enumerator->enumerate(enumerator, &pathname))
+                       while (enumerator->enumerate(enumerator, &vid, &name, &qualifier))
                        {
-                               if (strcmp(pathname, TBOOT_POLICY_STR) == 0)
-                               {
-                                       name = PTS_ITA_FUNC_COMP_NAME_TBOOT_POLICY;
-                               }
-                               else if (strcmp(pathname, TBOOT_MLE_STR) == 0)
-                               {
-                                       name = PTS_ITA_FUNC_COMP_NAME_TBOOT_MLE;
-                               }
-                               else
+                               entry = malloc_thing(funct_comp_evid_req_entry_t);
+                               entry->flags = PTS_REQ_FUNC_COMP_FLAG_PCR;
+                               entry->sub_comp_depth = 0;
+                               entry->name = pts_comp_func_name_create(vid, name, qualifier);
+
+                               /* TODO: pts_components undeclared */
+                               /*type = pts_components->get_qualifier(pts_components,
+                                                                                                        entry->name, &flags);
+
+                               DBG2(DBG_TNC, "%N functional component '%N' with qualifier %s '%N'",
+                                        pen_names, vid,
+                                        pts_components->get_comp_func_names(pts_components, vid),
+                                        name, flags,
+                                        pts_components->get_qualifier_type_names(pts_components, vid),
+                                        type);
+                               */
+                               if (first_req)
                                {
-                                       DBG1(DBG_IMV, "Unknown functional component name: \"%s\"",
-                                                pathname);
-                                       enumerator->destroy(enumerator);
-                                       return FALSE;
+                                       /* Create a requests object */
+                                       requests = pts_funct_comp_evid_req_create();
+                                       first_req = FALSE;
                                }
-
-                               /* Send Request Functional Component Evidence attribute */
-                               attr = tcg_pts_attr_req_funct_comp_evid_create(flags,
-                                                                       sub_comp_depth, PEN_ITA, qualifier, name);
-                               attr->set_noskip_flag(attr, TRUE);
-                               msg->add_attribute(msg, attr);
-                               attestation_state->add_comp_evid_request( attestation_state,
-                                                                        PEN_ITA, qualifier, name);
+                               requests->add(requests, entry);
+                               attestation_state->add_comp_evid_request(attestation_state, entry);
                        }
                        enumerator->destroy(enumerator);
-                       
-                       
+
+                       /* Send Request Functional Component Evidence attribute */
+                       attr = tcg_pts_attr_req_funct_comp_evid_create(requests);
+                       attr->set_noskip_flag(attr, TRUE);
+                       msg->add_attribute(msg, attr);
+
                        /* Send Generate Attestation Evidence attribute */
                        attr = tcg_pts_attr_gen_attest_evid_create();
                        attr->set_noskip_flag(attr, TRUE);