object oriented approach to pts functional components
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 17 Nov 2011 23:08:33 +0000 (00:08 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 20:20:23 +0000 (21:20 +0100)
26 files changed:
src/libimcv/plugins/imv_attestation/imv_attestation_process.c
src/libimcv/plugins/imv_attestation/imv_attestation_state.c
src/libimcv/plugins/imv_attestation/imv_attestation_state.h
src/libpts/Makefile.am
src/libpts/libpts.c
src/libpts/libpts.h
src/libpts/pts/components/ita/ita_comp_func_name.c [new file with mode: 0644]
src/libpts/pts/components/ita/ita_comp_func_name.h [new file with mode: 0644]
src/libpts/pts/components/ita/ita_comp_tboot.c [new file with mode: 0644]
src/libpts/pts/components/ita/ita_comp_tboot.h [new file with mode: 0644]
src/libpts/pts/components/ita/ita_comp_tgrub.c [new file with mode: 0644]
src/libpts/pts/components/ita/ita_comp_tgrub.h [new file with mode: 0644]
src/libpts/pts/components/pts_comp_func_name.c [new file with mode: 0644]
src/libpts/pts/components/pts_comp_func_name.h [new file with mode: 0644]
src/libpts/pts/components/pts_component.h [new file with mode: 0644]
src/libpts/pts/components/pts_component_manager.c [new file with mode: 0644]
src/libpts/pts/components/pts_component_manager.h [new file with mode: 0644]
src/libpts/pts/components/tcg/tcg_comp_func_name.c [new file with mode: 0644]
src/libpts/pts/components/tcg/tcg_comp_func_name.h [new file with mode: 0644]
src/libpts/pts/pts.h
src/libpts/pts/pts_funct_comp_evid_req.h
src/libpts/pts/pts_funct_comp_name.h [deleted file]
src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c
src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h
src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c
src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h

index 03f1359..4b01b56 100644 (file)
@@ -266,7 +266,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
                        bool pcr_info_inclided, component_meas_error = FALSE;
                        pts_attr_simple_comp_evid_flag_t flags;
                        u_int32_t depth, comp_vendor_id, extended_pcr;
-                       u_int8_t family, measurement_type;
+                       u_int8_t  measurement_type;
                        pts_qualifier_t qualifier;
                        pts_ita_funct_comp_name_t name;
                        pts_meas_algorithms_t hash_algorithm;
index 518ab41..9923204 100644 (file)
@@ -21,7 +21,6 @@
 
 typedef struct private_imv_attestation_state_t private_imv_attestation_state_t;
 typedef struct file_meas_request_t file_meas_request_t;
-typedef struct comp_evid_request_t comp_evid_request_t;
 
 /**
  * PTS File/Directory Measurement request entry
@@ -33,15 +32,6 @@ struct file_meas_request_t {
 };
 
 /**
- * Functional Component Evidence Request entry
- */
-struct comp_evid_request_t {
-       u_int32_t vendor_id;
-       pts_qualifier_t qualifier;
-       pts_ita_funct_comp_name_t name;
-};
-
-/**
  * Private data of an imv_attestation_state_t object.
  */
 struct private_imv_attestation_state_t {
@@ -273,31 +263,23 @@ METHOD(imv_attestation_state_t, get_file_meas_request_count, int,
 METHOD(imv_attestation_state_t, add_comp_evid_request, void,
        private_imv_attestation_state_t *this, funct_comp_evid_req_entry_t *entry)
 {
-       comp_evid_request_t *request;
+       pts_comp_func_name_t *request;
 
-       request = malloc_thing(comp_evid_request_t);
-       request->vendor_id = entry->vendor_id;
-       request->qualifier = entry->qualifier;
-       request->name = entry->name;
+       request = entry->name->clone(entry->name);
        this->comp_evid_requests->insert_last(this->comp_evid_requests, request);
 }
 
 METHOD(imv_attestation_state_t, check_off_comp_evid_request, bool,
-       private_imv_attestation_state_t *this, u_int32_t vendor_id,
-       pts_qualifier_t qualifier, pts_ita_funct_comp_name_t comp_name)
+       private_imv_attestation_state_t *this, pts_comp_func_name_t *name)
 {
        enumerator_t *enumerator;
-       comp_evid_request_t *request;
+       pts_comp_func_name_t *request;
        bool found = FALSE;
 
        enumerator = this->comp_evid_requests->create_enumerator(this->comp_evid_requests);
        while (enumerator->enumerate(enumerator, &request))
        {
-               if (request->vendor_id == vendor_id &&
-                       request->qualifier.kernel == qualifier.kernel &&
-                       request->qualifier.sub_component == qualifier.sub_component &&
-                       request->qualifier.type == qualifier.type &&
-                       request->name == comp_name)
+               if (name->equals(name, request))
                {
                        found = TRUE;
                        this->comp_evid_requests->remove_at(this->comp_evid_requests, enumerator);
index 310f702..b62f477 100644 (file)
@@ -81,8 +81,8 @@ struct imv_attestation_state_t {
         * @param is_dir                        TRUE if directory
         * @return                                      unique request ID
         */
-       u_int16_t (*add_file_meas_request)(imv_attestation_state_t *this, int file_id,
-                                                        bool is_dir);
+       u_int16_t (*add_file_meas_request)(imv_attestation_state_t *this,
+                                                                          int file_id, bool is_dir);
 
        /**
         * Returns the number of pending file/directory measurement requests
@@ -100,7 +100,7 @@ struct imv_attestation_state_t {
         * @return                                      TRUE if request ID found, FALSE otherwise
         */
        bool (*check_off_file_meas_request)(imv_attestation_state_t *this,
-                                               u_int16_t id, int *file_id, bool *is_dir);
+                                                                               u_int16_t id, int *file_id, bool *is_dir);
 
        /**
         * Add an entry to the list of pending Function Component Evidences
@@ -108,26 +108,23 @@ struct imv_attestation_state_t {
         * @param entry                         Functional Component Evidence Request
         */
        void (*add_comp_evid_request)(imv_attestation_state_t *this,
-                               funct_comp_evid_req_entry_t *entry);
+                                                                 funct_comp_evid_req_entry_t *entry);
 
        /**
         * Returns the number of pending Function Component Evidences
         *
-        * @return                                      number of pending evidences
+        * @return                                      Number of pending evidences
         */
        int (*get_comp_evid_request_count)(imv_attestation_state_t *this);
 
        /**
         * Check for presence of Component Evidence Request and remove if exists
         *
-        * @param vendor_id                     Functional Component Name Vendor ID
-        * @param qualifier                     Qualifier of the requested Functional Component
-        * @param comp_name                     Name of the requested Functional Component
+        * @param name                          Name of the requested Functional Component
         * @return                                      TRUE if component request found, FALSE otherwise
         */
        bool (*check_off_comp_evid_request)(imv_attestation_state_t *this,
-                                       u_int32_t vendor_id, pts_qualifier_t qualifier,
-                                       pts_ita_funct_comp_name_t comp_name);
+                                                                               pts_comp_func_name_t *name);
 
        /**
         * Indicates if a file measurement error occurred
index 12bd2a7..4b050a5 100644 (file)
@@ -18,6 +18,13 @@ libpts_la_SOURCES = \
        pts/pts_file_meta.h pts/pts_file_meta.c \
        pts/pts_file_type.h pts/pts_file_type.c \
        pts/pts_meas_algo.h pts/pts_meas_algo.c \
+       pts/components/pts_component.h \
+       pts/components/pts_component_manager.h pts/components/pts_component_manager.c \
+       pts/components/pts_comp_func_name.h pts/components/pts_comp_func_name.c \
+       pts/components/ita/ita_comp_func_name.h pts/components/ita/ita_comp_func_name.c \
+       pts/components/ita/ita_comp_tboot.h pts/components/ita/ita_comp_tboot.c \
+       pts/components/ita/ita_comp_tgrub.h pts/components/ita/ita_comp_tgrub.c \
+       pts/components/tcg/tcg_comp_func_name.h pts/components/tcg/tcg_comp_func_name.c \
        tcg/tcg_attr.h tcg/tcg_attr.c \
        tcg/tcg_pts_attr_proto_caps.h tcg/tcg_pts_attr_proto_caps.c \
        tcg/tcg_pts_attr_dh_nonce_params_req.h tcg/tcg_pts_attr_dh_nonce_params_req.c \
index bd4c3a4..268f438 100644 (file)
 
 #include "libpts.h"
 #include "tcg/tcg_attr.h"
+#include "pts/components/pts_component.h"
+#include "pts/components/pts_component_manager.h"
+#include "pts/components/tcg/tcg_comp_func_name.h"
+#include "pts/components/ita/ita_comp_func_name.h"
+#include "pts/components/ita/ita_comp_tboot.h"
+#include "pts/components/ita/ita_comp_tgrub.h"
 
 #include <imcv.h>
-
 #include <debug.h>
 
 /**
+ * PTS Functional Component manager
+ */
+pts_component_manager_t *pts_components;
+
+/**
  * Reference count for IMC/IMV instances
  */
 static refcount_t libpts_ref = 0;
@@ -37,6 +47,22 @@ bool libpts_init(void)
                }
                imcv_pa_tnc_attributes->add_vendor(imcv_pa_tnc_attributes, PEN_TCG,
                                                        tcg_attr_create_from_data, tcg_attr_names);
+
+               pts_components = pts_component_manager_create();
+               pts_components->add_vendor(pts_components, PEN_TCG,
+                                       pts_tcg_comp_func_names, PTS_TCG_QUALIFIER_TYPE_SIZE,
+                                       pts_tcg_qualifier_flag_names, pts_tcg_qualifier_type_names);
+               pts_components->add_vendor(pts_components, PEN_ITA,
+                                       pts_ita_comp_func_names, PTS_ITA_QUALIFIER_TYPE_SIZE,
+                                       pts_ita_qualifier_flag_names, pts_ita_qualifier_type_names);
+
+               pts_components->add_component(pts_components, PEN_ITA,
+                                                                         PTS_ITA_COMP_FUNC_NAME_TGRUB,
+                                                                         pts_ita_comp_tgrub_create);
+               pts_components->add_component(pts_components, PEN_ITA,
+                                                                         PTS_ITA_COMP_FUNC_NAME_TBOOT,
+                                                                         pts_ita_comp_tboot_create);
+
                DBG1(DBG_LIB, "libpts initialized");
        }
        ref_get(&libpts_ref);
@@ -51,6 +77,10 @@ void libpts_deinit(void)
 {
        if (ref_put(&libpts_ref))
        {
+               pts_components->remove_vendor(pts_components, PEN_TCG);
+               pts_components->remove_vendor(pts_components, PEN_ITA);
+               pts_components->destroy(pts_components);
+
                if (!imcv_pa_tnc_attributes)
                {
                        return;
index 4c771d2..7b29597 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef LIBPTS_H_
 #define LIBPTS_H_
 
+#include "pts/components/pts_component_manager.h"
+
 #include <library.h>
 
 /**
@@ -39,4 +41,9 @@ bool libpts_init(void);
  */
 void libpts_deinit(void);
 
+/**
+ * PTS Functional Component manager
+ */
+extern pts_component_manager_t* pts_components;
+
 #endif /** LIBPTS_H_ @}*/
diff --git a/src/libpts/pts/components/ita/ita_comp_func_name.c b/src/libpts/pts/components/ita/ita_comp_func_name.c
new file mode 100644 (file)
index 0000000..f0a1cdc
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "ita_comp_func_name.h"
+
+char pts_ita_qualifier_flag_names[] = { 'K', 'S' };
+
+ENUM_BEGIN(pts_ita_qualifier_type_names, PTS_ITA_QUALIFIER_TYPE_UNKNOWN,
+                                                                                PTS_ITA_QUALIFIER_TYPE_TNC,
+       "Unknown",
+       "Trusted Platform",
+       "Operating System",
+       "Graphical User Interface",
+       "Application",
+       "Networking",
+       "Library",
+       "TNC Defined Component"
+);
+ENUM_NEXT(pts_ita_qualifier_type_names, PTS_ITA_QUALIFIER_TYPE_ALL,
+                                                                               PTS_ITA_QUALIFIER_TYPE_ALL,
+                                                                               PTS_ITA_QUALIFIER_TYPE_TNC,
+       "All Matching Components"
+);
+ENUM_END(pts_ita_qualifier_type_names, PTS_ITA_QUALIFIER_TYPE_ALL);
+
+ENUM(pts_ita_comp_func_names, PTS_ITA_COMP_FUNC_NAME_IGNORE,
+                                                         PTS_ITA_COMP_FUNC_NAME_TBOOT,
+       "Ignore",
+       "Trusted GRUB Boot Loader",
+       "Trusted Boot"
+);
+
diff --git a/src/libpts/pts/components/ita/ita_comp_func_name.h b/src/libpts/pts/components/ita/ita_comp_func_name.h
new file mode 100644 (file)
index 0000000..d5729b4
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 Sansar Choinyambuu
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_ita_comp_func_name pts_ita_comp_func_name
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_ITA_COMP_FUNC_NAME_H_
+#define PTS_ITA_COMP_FUNC_NAME_H_
+
+typedef enum pts_ita_qualifier_type_t pts_ita_qualifier_type_t;
+typedef enum pts_ita_comp_func_name_t pts_ita_comp_func_name_t;
+
+#include <library.h>
+
+/**
+ * PTS Component Functional Name Qualifier Flags for the ITA namespace
+ */
+#define PTS_ITA_QUALIFIER_FLAG_KERNEL                  (1<<5)
+#define PTS_ITA_QUALIFIER_FLAG_SUB                             (1<<4)
+
+extern char pts_ita_qualifier_flag_names[];
+
+/**
+ * Size of the PTS Component Functional Name Qualifier Type field
+ */
+#define PTS_ITA_QUALIFIER_TYPE_SIZE                            4
+
+/**
+ * PTS Component Functional Name Qualifier Types for the ITA namespace
+ * equal to section 5.2 of PTS Protocol: Binding to TNC IF-M Specification
+ */
+enum pts_ita_qualifier_type_t {
+       /** Unknown */
+       PTS_ITA_QUALIFIER_TYPE_UNKNOWN =                        0x0,
+       /** Trusted Platform */
+       PTS_ITA_QUALIFIER_TYPE_TRUSTED =                        0x1,
+       /** Operating System */
+       PTS_ITA_QUALIFIER_TYPE_OS =                                     0x2,
+       /** Graphical User Interface */
+       PTS_ITA_QUALIFIER_TYPE_GUI =                            0x3,
+       /** Application */
+       PTS_ITA_QUALIFIER_TYPE_APP =                            0x4,
+       /** Networking */
+       PTS_ITA_QUALIFIER_TYPE_NET =                            0x5,
+       /** Library */
+       PTS_ITA_QUALIFIER_TYPE_LIB =                            0x6,
+       /** TNC Defined Component */
+       PTS_ITA_QUALIFIER_TYPE_TNC =                            0x7,
+       /** All Matching Components */
+       PTS_ITA_QUALIFIER_TYPE_ALL =                            0xF,
+};
+
+extern enum_name_t *pts_ita_qualifier_type_names;
+
+/**
+ * PTS Component Functional Name Binary Enumeration for the ITA namespace
+ */
+enum pts_ita_comp_func_name_t {
+       /** Ignore */
+       PTS_ITA_COMP_FUNC_NAME_IGNORE =                         0x0000,
+       /** Trusted GRUB Boot Loader */
+       PTS_ITA_COMP_FUNC_NAME_TGRUB =                          0x0001,
+       /** Trusted Boot */
+       PTS_ITA_COMP_FUNC_NAME_TBOOT =                          0x0002,
+};
+
+extern enum_name_t *pts_ita_comp_func_names;
+
+#endif /** PTS_ITA_COMP_FUNC_NAME_H_ @}*/
diff --git a/src/libpts/pts/components/ita/ita_comp_tboot.c b/src/libpts/pts/components/ita/ita_comp_tboot.c
new file mode 100644 (file)
index 0000000..a18ed16
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ *
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "ita_comp_tboot.h"
+#include "ita_comp_func_name.h"
+
+#include "pts/components/pts_component.h"
+
+#include <debug.h>
+#include <pen/pen.h>
+
+typedef struct pts_ita_comp_tboot_t pts_ita_comp_tboot_t;
+
+/**
+ * Private data of a pts_ita_comp_tboot_t object.
+ *
+ */
+struct pts_ita_comp_tboot_t {
+
+       /**
+        * Public pts_component_manager_t interface.
+        */
+       pts_component_t public;
+
+       /**
+        * Component Functional Name
+        */
+       pts_comp_func_name_t *name;
+};
+
+METHOD(pts_component_t, get_comp_func_name, pts_comp_func_name_t*,
+       pts_ita_comp_tboot_t *this)
+{
+       return this->name;
+}
+
+METHOD(pts_component_t, measure, bool,
+       pts_ita_comp_tboot_t *this)
+{
+       /* TODO measure the tboot functional component */
+       return FALSE;
+}
+
+METHOD(pts_component_t, verify, bool,
+       pts_ita_comp_tboot_t *this)
+{
+       /* TODO verify the measurement of the tboot functional component */
+       return FALSE;
+}
+
+METHOD(pts_component_t, destroy, void,
+       pts_ita_comp_tboot_t *this)
+{
+       this->name->destroy(this->name);
+       free(this);
+}
+
+/**
+ * See header
+ */
+pts_component_t *pts_ita_comp_tboot_create(u_int8_t qualifier)
+{
+       pts_ita_comp_tboot_t *this;
+
+       INIT(this,
+               .public = {
+                       .get_comp_func_name = _get_comp_func_name,
+                       .measure = _measure,
+                       .verify = _verify,
+                       .destroy = _destroy,
+               },
+               .name = pts_comp_func_name_create(PEN_ITA, PTS_ITA_COMP_FUNC_NAME_TBOOT,
+                                                                                 qualifier),
+       );
+
+       return &this->public;
+}
+
diff --git a/src/libpts/pts/components/ita/ita_comp_tboot.h b/src/libpts/pts/components/ita/ita_comp_tboot.h
new file mode 100644 (file)
index 0000000..f8945cb
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 Sansar Choinyambuu
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_ita_comp_func_name pts_ita_comp_func_name
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_ITA_COMP_TBOOT_H_
+#define PTS_ITA_COMP_TBOOT_H_
+
+#include "pts/components/pts_component.h"
+
+/**
+ * Create a PTS ITS Functional Component object
+ *
+ * @param qualifier            PTS Component Functional Name Qualifier
+ *
+ */
+pts_component_t* pts_ita_comp_tboot_create(u_int8_t qualifier);
+
+#endif /** PTS_ITA_COMP_TBOOT_H_ @}*/
diff --git a/src/libpts/pts/components/ita/ita_comp_tgrub.c b/src/libpts/pts/components/ita/ita_comp_tgrub.c
new file mode 100644 (file)
index 0000000..e99dbd1
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ *
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "ita_comp_tgrub.h"
+#include "ita_comp_func_name.h"
+
+#include "pts/components/pts_component.h"
+
+#include <debug.h>
+#include <pen/pen.h>
+
+typedef struct pts_ita_comp_tgrub_t pts_ita_comp_tgrub_t;
+
+/**
+ * Private data of a pts_ita_comp_tgrub_t object.
+ *
+ */
+struct pts_ita_comp_tgrub_t {
+
+       /**
+        * Public pts_component_manager_t interface.
+        */
+       pts_component_t public;
+
+       /**
+        * Component Functional Name
+        */
+       pts_comp_func_name_t *name;
+};
+
+METHOD(pts_component_t, get_comp_func_name, pts_comp_func_name_t*,
+       pts_ita_comp_tgrub_t *this)
+{
+       return this->name;
+}
+
+METHOD(pts_component_t, measure, bool,
+       pts_ita_comp_tgrub_t *this)
+{
+       /* TODO measure the tgrub functional component */
+       return FALSE;
+}
+
+METHOD(pts_component_t, verify, bool,
+       pts_ita_comp_tgrub_t *this)
+{
+       /* TODO verify the measurement of the tgrub functional component */
+       return FALSE;
+}
+
+METHOD(pts_component_t, destroy, void,
+       pts_ita_comp_tgrub_t *this)
+{
+       this->name->destroy(this->name);
+       free(this);
+}
+
+/**
+ * See header
+ */
+pts_component_t *pts_ita_comp_tgrub_create(u_int8_t qualifier)
+{
+       pts_ita_comp_tgrub_t *this;
+
+       INIT(this,
+               .public = {
+                       .get_comp_func_name = _get_comp_func_name,
+                       .measure = _measure,
+                       .verify = _verify,
+                       .destroy = _destroy,
+               },
+               .name = pts_comp_func_name_create(PEN_ITA, PTS_ITA_COMP_FUNC_NAME_TBOOT,
+                                                                                 qualifier),
+       );
+
+       return &this->public;
+}
+
diff --git a/src/libpts/pts/components/ita/ita_comp_tgrub.h b/src/libpts/pts/components/ita/ita_comp_tgrub.h
new file mode 100644 (file)
index 0000000..345c105
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 Sansar Choinyambuu
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_ita_comp_func_name pts_ita_comp_func_name
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_ITA_COMP_TGRUB_H_
+#define PTS_ITA_COMP_TGRUB_H_
+
+#include "pts/components/pts_component.h"
+
+/**
+ * Create a PTS ITS Functional Component object
+ *
+ * @param qualifier            PTS Component Functional Name Qualifier
+ *
+ */
+pts_component_t* pts_ita_comp_tgrub_create(u_int8_t qualifier);
+
+#endif /** PTS_ITA_COMP_TGRUB_H_ @}*/
diff --git a/src/libpts/pts/components/pts_comp_func_name.c b/src/libpts/pts/components/pts_comp_func_name.c
new file mode 100644 (file)
index 0000000..818e722
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ *
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "pts/components/pts_comp_func_name.h"
+
+#include <debug.h>
+
+#define PTS_QUALIFIER_UNKNOWN          0x00
+#define PTS_QUALIFIER_WILDCARD         0x3F
+
+typedef struct private_pts_comp_func_name_t private_pts_comp_func_name_t;
+
+/**
+ * Private data of a pts_comp_func_name_t object.
+ *
+ */
+struct private_pts_comp_func_name_t {
+
+       /**
+        * Public pts_comp_func_name_t interface.
+        */
+       pts_comp_func_name_t public;
+
+       /**
+        * PTS Component Functional Name Vendor ID
+        */
+       u_int32_t vendor_id;
+
+       /**
+        * PTS Component Functional Name
+        */
+       u_int32_t name;
+
+       /**
+        * PTS Component Functional Name Qualifier
+        */
+       u_int8_t qualifier;
+
+};
+
+METHOD(pts_comp_func_name_t, get_vendor_id, u_int32_t,
+       private_pts_comp_func_name_t *this)
+{
+       return this->vendor_id;
+}
+
+METHOD(pts_comp_func_name_t, get_name, u_int32_t,
+       private_pts_comp_func_name_t *this)
+{
+       return this->name;
+}
+
+METHOD(pts_comp_func_name_t, get_qualifier, u_int8_t,
+       private_pts_comp_func_name_t *this)
+{
+       return this->qualifier;
+}
+
+static bool equals(private_pts_comp_func_name_t *this,
+                                  private_pts_comp_func_name_t *other)
+{
+       if (this->vendor_id != other->vendor_id ||
+               this->name  != other->name)
+       {
+               return FALSE;
+       }
+       if (this->qualifier == PTS_QUALIFIER_UNKNOWN ||
+               other->qualifier == PTS_QUALIFIER_UNKNOWN)
+       {
+               return TRUE;
+       }
+       /* TODO handle qualifier wildcards */
+
+       return this->qualifier == other->qualifier;
+}
+
+METHOD(pts_comp_func_name_t, clone_, pts_comp_func_name_t*,
+       private_pts_comp_func_name_t *this)
+{
+       private_pts_comp_func_name_t *clone;
+
+       clone = malloc_thing(private_pts_comp_func_name_t);
+       memcpy(clone, this, sizeof(private_pts_comp_func_name_t));
+
+       return &clone->public;
+}
+
+METHOD(pts_comp_func_name_t, destroy, void,
+       private_pts_comp_func_name_t *this)
+{
+       free(this);
+}
+
+/**
+ * See header
+ */
+pts_comp_func_name_t* pts_comp_func_name_create(u_int32_t vendor_id, 
+                                                                                               u_int32_t name,
+                                                                                               u_int8_t qualifier)
+{
+       private_pts_comp_func_name_t *this;
+
+       INIT(this,
+               .public = {
+                       .get_vendor_id = _get_vendor_id,
+                       .get_name = _get_name,
+                       .get_qualifier = _get_qualifier,
+                       .equals = (bool(*)(pts_comp_func_name_t*,pts_comp_func_name_t*))equals,
+                       .clone = _clone_,
+                       .destroy = _destroy,
+               },
+               .vendor_id = vendor_id,
+               .name = name,
+               .qualifier = qualifier,
+       );
+
+       return &this->public;
+}
+
diff --git a/src/libpts/pts/components/pts_comp_func_name.h b/src/libpts/pts/components/pts_comp_func_name.h
new file mode 100644 (file)
index 0000000..fe4f19b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011 Sansar Choinyambuu
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_comp_func_name pts_comp_func_name
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_FUNC_COMP_NAME_H_
+#define PTS_FUNC_COMP_NAME_H_
+
+typedef struct pts_comp_func_name_t pts_comp_func_name_t;
+
+#include <library.h>
+
+/**
+ * PTS Component Functional Name object
+ */
+struct pts_comp_func_name_t {
+
+       /**
+        * Get the PTS Component Functional Name Vendor ID
+        *
+        * @return                              PTS Component Functional Name Vendor ID
+        */
+       u_int32_t (*get_vendor_id)(pts_comp_func_name_t *this);
+
+       /**
+        * Get the PTS Component Functional Name
+        *
+        * @return                              PTS Component Functional Name
+        */
+       u_int32_t (*get_name)(pts_comp_func_name_t *this);
+
+       /**
+        * Get the PTS Component Functional Name Qualifier
+        *
+        * @return                              PTS Component Functional Name Qualifier
+        */
+       u_int8_t (*get_qualifier)(pts_comp_func_name_t *this);
+
+       /**
+        * Check to PTS Component Functional Names for equality
+        *
+        * @param other                 Other PTS Component Functional Name
+        * @return                              TRUE if equal
+        */
+       bool (*equals)(pts_comp_func_name_t *this, pts_comp_func_name_t *other);
+
+       /**
+        * Clone a PTS Component Functional Name
+        *
+        * @return                              Cloned PTS Component Functional Name
+        */
+       pts_comp_func_name_t* (*clone)(pts_comp_func_name_t *this);
+
+       /**
+        * Destroys a pts_component_t object.
+        */
+       void (*destroy)(pts_comp_func_name_t *this);
+
+};
+
+/**
+ * Create a PTS Component Functional Name object
+ *
+ * @param vendor_id                    PTS Component Functional Name Vendor ID
+ * @param name                         PTS Component Functional Name
+ * @param                                      PTS Component Functional Name Qualifier
+ */
+pts_comp_func_name_t* pts_comp_func_name_create(u_int32_t vendor_id, 
+                                                                                               u_int32_t name,
+                                                                                               u_int8_t qualifier);
+
+#endif /** PTS_FUNC_COMP_NAME_H_ @}*/
diff --git a/src/libpts/pts/components/pts_component.h b/src/libpts/pts/components/pts_component.h
new file mode 100644 (file)
index 0000000..dd77073
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_component pts_component
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_COMPONENT_H_
+#define PTS_COMPONENT_H_
+
+typedef struct pts_component_t pts_component_t;
+
+#include "pts/components/pts_comp_func_name.h"
+
+#include <library.h>
+
+/**
+ * PTS Functional Component Interface 
+ */
+struct pts_component_t {
+
+       /**
+        * Get the PTS Component Functional Name
+        *
+        * @return                              PTS Component Functional Name
+        */
+       pts_comp_func_name_t* (*get_comp_func_name)(pts_component_t *this);
+
+       /**
+        * Do measurements on the PTS Functional Component
+        *
+        * @return                              TRUE if component measurements are successful
+        */
+       bool (*measure)(pts_component_t *this);
+
+       /**
+        * Verify the measurements of the PTS Functional Component
+        *
+        * @return                              TRUE if verification is successful
+        */
+       bool (*verify)(pts_component_t *this);
+
+       /**
+        * Destroys a pts_component_t object.
+        */
+       void (*destroy)(pts_component_t *this);
+
+};
+
+#endif /** PTS_COMPONENT_H_ @}*/
diff --git a/src/libpts/pts/components/pts_component_manager.c b/src/libpts/pts/components/pts_component_manager.c
new file mode 100644 (file)
index 0000000..cfcccc0
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ *
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "pts/components/pts_component_manager.h"
+
+#include <utils/linked_list.h>
+#include <debug.h>
+
+typedef struct private_pts_component_manager_t private_pts_component_manager_t;
+typedef struct vendor_entry_t vendor_entry_t;
+typedef struct component_entry_t component_entry_t;
+
+#define PTS_QUALIFIER_SIZE             6
+
+/**
+ * Vendor-specific namespace information and list of registered components
+ */
+struct vendor_entry_t {
+
+       /**
+        * Vendor ID
+     */
+       pen_t vendor_id;
+
+       /**
+        * Vendor-specific Component Functional names
+        */
+       enum_name_t *comp_func_names;
+
+       /**
+        * Vendor-specific Qualifier Type names
+        */
+       enum_name_t *qualifier_type_names;
+
+       /**
+        * Vendor-specific Qualifier Flag names
+        */
+       char *qualifier_flag_names;
+
+       /**
+        * Vendor-specific size of Qualfiier Type field
+        */
+       int qualifier_type_size;
+
+       /**
+        * List of vendor-specific registered Functional Components
+        */     
+       linked_list_t *components;
+};
+
+/**
+ * Destroy a vendor_entry_t object
+ */
+static void vendor_entry_destroy(vendor_entry_t *entry)
+{
+       entry->components->destroy_function(entry->components, free);
+       free(entry);
+}
+
+/**
+ * Creation method for a vendor-specific Functional Component
+ */
+struct component_entry_t {
+
+       /**
+        * Vendor-Specific Component Functional Name
+        */
+       u_int32_t name;
+
+       /**
+        * Functional Component creation method
+        */
+       pts_component_create_t create;
+};
+
+/**
+ * Private data of a pts_component_manager_t object.
+ *
+ */
+struct private_pts_component_manager_t {
+
+       /**
+        * Public pts_component_manager_t interface.
+        */
+       pts_component_manager_t public;
+
+       /**
+        * List of vendor-specific namespaces and registered components
+        */
+       linked_list_t *list;
+};
+
+METHOD(pts_component_manager_t, add_vendor, void,
+       private_pts_component_manager_t *this, pen_t vendor_id, 
+       enum_name_t *comp_func_names, int qualifier_type_size,
+       char *qualifier_flag_names, enum_name_t *qualifier_type_names)
+{
+       vendor_entry_t *entry;
+
+       entry = malloc_thing(vendor_entry_t);
+       entry->vendor_id = vendor_id;
+       entry->comp_func_names = comp_func_names;
+       entry->qualifier_type_size = qualifier_type_size;
+       entry->qualifier_flag_names = qualifier_flag_names;
+       entry->qualifier_type_names = qualifier_type_names;
+       entry->components = linked_list_create();
+
+       this->list->insert_last(this->list, entry);
+       DBG2(DBG_TNC, "added %N functional component namespace",
+                pen_names, vendor_id);
+}
+
+METHOD(pts_component_manager_t, get_comp_func_names, enum_name_t*,
+       private_pts_component_manager_t *this, pen_t vendor_id)
+{
+       enumerator_t *enumerator;
+       vendor_entry_t *entry;
+       enum_name_t *names = NULL;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == vendor_id)
+               {
+                       names = entry->comp_func_names;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return names;
+}
+
+METHOD(pts_component_manager_t, get_qualifier_type_names, enum_name_t*,
+       private_pts_component_manager_t *this, pen_t vendor_id)
+{
+       enumerator_t *enumerator;
+       vendor_entry_t *entry;
+       enum_name_t *names = NULL;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == vendor_id)
+               {
+                       names = entry->qualifier_type_names;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return names;
+}
+
+METHOD(pts_component_manager_t, add_component, void,
+       private_pts_component_manager_t *this, pen_t vendor_id, u_int32_t name,
+       pts_component_create_t create)
+{
+       enumerator_t *enumerator;
+       vendor_entry_t *entry;
+       component_entry_t *component;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == vendor_id)
+               {
+                       component = malloc_thing(component_entry_t);
+                       component->name = name;
+                       component->create = create;
+
+                       entry->components->insert_last(entry->components, component);
+                       DBG2(DBG_TNC, "added %N functional component \"%N\"",
+                                pen_names, vendor_id,
+                                get_comp_func_names(this, vendor_id), name);
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
+METHOD(pts_component_manager_t, remove_vendor, void,
+       private_pts_component_manager_t *this, pen_t vendor_id)
+{
+       enumerator_t *enumerator;
+       vendor_entry_t *entry;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == vendor_id)
+               {
+                       this->list->remove_at(this->list, enumerator);
+                       vendor_entry_destroy(entry);
+                       DBG2(DBG_TNC, "removed %N functional component namespace",
+                                pen_names, vendor_id);
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
+METHOD(pts_component_manager_t, get_qualifier, u_int8_t,
+       private_pts_component_manager_t *this, pts_comp_func_name_t *name,
+       char *flags)
+{
+       enumerator_t *enumerator;
+       vendor_entry_t *entry;
+       u_int8_t qualifier, size, flag, type = 0;
+       int i;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == name->get_vendor_id(name))
+               {
+                       qualifier = name->get_qualifier(name);
+                       size = entry->qualifier_type_size;
+                       flag = (1 << size);
+
+                       /* mask qualifier type field */
+                       type = qualifier & (flag - 1);
+
+                       /* determine flags */
+                       size = PTS_QUALIFIER_SIZE - size;
+                       if (flags)
+                       {
+                               for (i = 0 ; i < size; i++)
+                               {
+                                       flags[size-i+1] = (qualifier & flag) ? 
+                                                                          entry->qualifier_flag_names[i] : '.';
+                                       flag <<= 1;
+                               }
+                       }
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return type;
+}
+
+METHOD(pts_component_manager_t, create, pts_component_t*,
+       private_pts_component_manager_t *this, pts_comp_func_name_t *name)
+{
+       enumerator_t *enumerator, *e2;
+       vendor_entry_t *entry;
+       component_entry_t *entry2;
+       pts_component_t *component = NULL;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               if (entry->vendor_id == name->get_vendor_id(name))
+               {
+                       e2 = entry->components->create_enumerator(entry->components);
+                       while (e2->enumerate(e2, &entry2))
+                       {
+                               if (entry2->name == name->get_name(name) && entry2->create)
+                               {
+                                       component = entry2->create(name->get_qualifier(name));
+                                       break;
+                               }
+                       }
+                       e2->destroy(e2);
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return component;
+}
+
+METHOD(pts_component_manager_t, destroy, void,
+       private_pts_component_manager_t *this)
+{
+       this->list->destroy_function(this->list, (void *)vendor_entry_destroy); 
+       free(this);
+}
+
+/**
+ * See header
+ */
+pts_component_manager_t *pts_component_manager_create(void)
+{
+       private_pts_component_manager_t *this;
+
+       INIT(this,
+               .public = {
+                       .add_vendor = _add_vendor,
+                       .add_component = _add_component,
+                       .remove_vendor = _remove_vendor,
+                       .get_comp_func_names = _get_comp_func_names,
+                       .get_qualifier_type_names = _get_qualifier_type_names,
+                       .get_qualifier = _get_qualifier,
+                       .create = _create,
+                       .destroy = _destroy,
+               },
+               .list = linked_list_create(),
+       );
+
+       return &this->public;
+}
+
diff --git a/src/libpts/pts/components/pts_component_manager.h b/src/libpts/pts/components/pts_component_manager.h
new file mode 100644 (file)
index 0000000..81efb03
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_component_manager pts_component_manager
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_COMPONENT_MANAGER_H_
+#define PTS_COMPONENT_MANAGER_H_
+
+typedef struct pts_component_manager_t pts_component_manager_t;
+
+#include "pts/components/pts_component.h"
+#include "pts/components/pts_comp_func_name.h"
+
+#include <library.h>
+#include <pen/pen.h>
+
+typedef pts_component_t* (*pts_component_create_t)(u_int8_t qualifier);
+
+/**
+ * Manages PTS Functional Components
+ */
+struct pts_component_manager_t {
+
+       /**
+        * Add vendor-specific functional component names
+        *
+        * @param vendor_id                             Private Enterprise Number (PEN)
+        * @param comp_func_names               Vendor-specific Component Functional names
+        * @param qualifier_type_size   Vendor-specific Qualifier Type size
+        * @param qualifier_flag_names  Vendor-specific Qualifier Flag names
+        * @param qualifier_type_names  Vendor-specific Qualifier Type names 
+        */
+       void (*add_vendor)(pts_component_manager_t *this, pen_t vendor_id,
+                                          enum_name_t *comp_func_names,
+                                          int qualifier_type_size,
+                                          char *qualifier_flag_names,
+                                          enum_name_t *qualifier_type_names);
+
+       /**
+        * Add vendor-specific functional component
+        *
+        * @param vendor_id                             Private Enterprise Number (PEN)
+        * @param names                                 Component Functional Name
+        * @param create                                Functional Component creation method
+        */
+       void (*add_component)(pts_component_manager_t *this, pen_t vendor_id,
+                                                 u_int32_t name, pts_component_create_t create);
+
+       /**
+        * Remove vendor-specific components and associated namespace
+        *
+        * @param vendor_id                             Private Enterprise Number (PEN)
+        */
+       void (*remove_vendor)(pts_component_manager_t *this, pen_t vendor_id);
+
+       /*
+        * Return the Functional Component names for a given vendor ID
+        *
+        * @param vendor_id                             Private Enterprise Number (PEN)
+        * @return                                              Comp. Func. names if found, NULL else
+        */
+       enum_name_t* (*get_comp_func_names)(pts_component_manager_t *this,
+                                                                               pen_t vendor_id);
+
+       /*
+        * Return the Functional Component Qualifier Type names for a given vendor ID
+        *
+        * @param vendor_id                             Private Enterprise Number (PEN)
+        * @return                                              Qualifier Type names if found, NULL else
+        */
+       enum_name_t* (*get_qualifier_type_names)(pts_component_manager_t *this,
+                                                                                        pen_t vendor_id);
+
+       /*
+        * Return the Qualifier Type and Flags
+        *
+        * @param name                                  Component Functional Name
+        * @param flags                                 Qualifier Flags as a string in a char buffer
+        * @return                                              Qualifier Type
+        */
+       u_int8_t (*get_qualifier)(pts_component_manager_t *this,
+                                                         pts_comp_func_name_t *name, char *flags);
+
+       /**
+        * Create a PTS Component object from a Functional Component Name object
+        *
+        * @param name                                  Component Functional Name
+        * @return                                              Component object if supported, NULL else
+        */
+       pts_component_t* (*create)(pts_component_manager_t *this, 
+                                                          pts_comp_func_name_t *name);
+
+       /**
+        * Destroys a pts_component_manager_t object.
+        */
+       void (*destroy)(pts_component_manager_t *this);
+};
+
+/**
+ * Create a PA-TNC attribute manager
+ */
+pts_component_manager_t* pts_component_manager_create(void);
+
+#endif /** PTS_COMPONENT_MANAGER_H_ @}*/
diff --git a/src/libpts/pts/components/tcg/tcg_comp_func_name.c b/src/libpts/pts/components/tcg/tcg_comp_func_name.c
new file mode 100644 (file)
index 0000000..a70c84e
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+#include "tcg_comp_func_name.h"
+
+char pts_tcg_qualifier_flag_names[] = { 'K', 'S' };
+
+ENUM_BEGIN(pts_tcg_qualifier_type_names, PTS_TCG_QUALIFIER_TYPE_UNKNOWN,
+                                                                                PTS_TCG_QUALIFIER_TYPE_TNC,
+       "Unknown",
+       "Trusted Platform",
+       "Operating System",
+       "Graphical User Interface",
+       "Application",
+       "Networking",
+       "Library",
+       "TNC Defined Component"
+);
+ENUM_NEXT(pts_tcg_qualifier_type_names, PTS_TCG_QUALIFIER_TYPE_ALL,
+                                                                               PTS_TCG_QUALIFIER_TYPE_ALL,
+                                                                               PTS_TCG_QUALIFIER_TYPE_TNC,
+       "All Matching Components"
+);
+ENUM_END(pts_tcg_qualifier_type_names, PTS_TCG_QUALIFIER_TYPE_ALL);
+
+ENUM(pts_tcg_comp_func_names, PTS_TCG_COMP_FUNC_NAME_IGNORE,
+                                                         PTS_TCG_COMP_FUNC_NAME_OPT_ROMS,
+       "Ignore",
+       "CRTM",
+       "BIOS",
+       "Platform Extensions",
+       "Motherboard Firmware",
+       "Initial Program Loader",
+       "Option ROMs"
+);
+
diff --git a/src/libpts/pts/components/tcg/tcg_comp_func_name.h b/src/libpts/pts/components/tcg/tcg_comp_func_name.h
new file mode 100644 (file)
index 0000000..9708ad0
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2011 Sansar Choinyambuu
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup pts_tcg_comp_func_name pts_tcg_comp_func_name
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_TCG_COMP_FUNC_NAME_H_
+#define PTS_TCG_COMP_FUNC_NAME_H_
+
+typedef enum pts_tcg_qualifier_type_t pts_tcg_qualifier_type_t;
+typedef enum pts_tcg_comp_func_name_t pts_tcp_comp_func_name_t;
+
+#include <library.h>
+
+/**
+ * PTS Component Functional Name Qualifier Flags for the TCG namespace
+ * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification
+ *     
+ *      0 1 2 3 4 5
+ *  +-+-+-+-+-+-+
+ *  |K|S| Type  |
+ *  +-+-+-+-+-+-+
+ */
+#define PTS_TCG_QUALIFIER_FLAG_KERNEL                  (1<<5)
+#define PTS_TCG_QUALIFIER_FLAG_SUB                             (1<<4)
+
+extern char pts_tcg_qualifier_flag_names[];
+
+/**
+ * Size of the PTS Component Functional Name Qualifier Type field
+ */
+#define PTS_TCG_QUALIFIER_TYPE_SIZE                            4
+
+/**
+ * PTS Component Functional Name Qualifier Types for the TCG namespace
+ * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification
+ */
+enum pts_tcg_qualifier_type_t {
+       /** Unknown */
+       PTS_TCG_QUALIFIER_TYPE_UNKNOWN =                        0x0,
+       /** Trusted Platform */
+       PTS_TCG_QUALIFIER_TYPE_TRUSTED =                        0x1,
+       /** Operating System */
+       PTS_TCG_QUALIFIER_TYPE_OS =                                     0x2,
+       /** Graphical User Interface */
+       PTS_TCG_QUALIFIER_TYPE_GUI =                            0x3,
+       /** Application */
+       PTS_TCG_QUALIFIER_TYPE_APP =                            0x4,
+       /** Networking */
+       PTS_TCG_QUALIFIER_TYPE_NET =                            0x5,
+       /** Library */
+       PTS_TCG_QUALIFIER_TYPE_LIB =                            0x6,
+       /** TNC Defined Component */
+       PTS_TCG_QUALIFIER_TYPE_TNC =                            0x7,
+       /** All matching Components */
+       PTS_TCG_QUALIFIER_TYPE_ALL =                            0xF,
+};
+
+extern enum_name_t *pts_tcg_qualifier_type_names;
+
+/**
+ * PTS Component Functional Name Binary Enumeration for the TCG namespace
+ * see section 5.3 of PTS Protocol: Binding to TNC IF-M Specification
+ */
+enum pts_tcg_comp_func_name_t {
+       /** Ignore */
+       PTS_TCG_COMP_FUNC_NAME_IGNORE =                         0x0000,
+       /** CRTM */
+       PTS_TCG_COMP_FUNC_NAME_CRTM =                           0x0001,
+       /** BIOS */
+       PTS_TCG_COMP_FUNC_NAME_BIOS =                           0x0002,
+       /** Platform Extensions */
+       PTS_TCG_COMP_FUNC_NAME_PLATFORM_EXT =           0x0003,
+       /** Motherboard Firmware */
+       PTS_TCG_COMP_FUNC_NAME_BOARD =                          0x0004,
+       /** Initial Program Loader */
+       PTS_TCG_COMP_FUNC_NAME_INIT_LOADER =            0x0005,
+       /** Option ROMs */
+       PTS_TCG_COMP_FUNC_NAME_OPT_ROMS =                       0x0006,
+};
+
+extern enum_name_t *pts_tcg_comp_func_names;
+
+#endif /** PTS_TCG_COMP_FUNC_NAME_H_ @}*/
index 4fb247c..6861243 100644 (file)
@@ -30,7 +30,6 @@ typedef struct pcr_entry_t pcr_entry_t;
 #include "pts_file_meas.h"
 #include "pts_file_meta.h"
 #include "pts_dh_group.h"
-#include "pts_funct_comp_name.h"
 #include "pts_funct_comp_evid_req.h"
 
 #include <library.h>
index 7e2dbd3..b09054e 100644 (file)
@@ -25,8 +25,9 @@ typedef struct pts_funct_comp_evid_req_t pts_funct_comp_evid_req_t;
 typedef enum pts_attr_req_funct_comp_evid_flag_t pts_attr_req_funct_comp_evid_flag_t;
 typedef struct funct_comp_evid_req_entry_t funct_comp_evid_req_entry_t;
 
+#include "pts/components/pts_comp_func_name.h"
+
 #include <library.h>
-#include "pts_funct_comp_name.h"
 
 #define PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM                0x00
 
@@ -50,10 +51,7 @@ enum pts_attr_req_funct_comp_evid_flag_t {
 struct funct_comp_evid_req_entry_t {
        pts_attr_req_funct_comp_evid_flag_t flags;
        u_int32_t sub_comp_depth;
-       u_int32_t vendor_id;
-       u_int8_t family;
-       pts_qualifier_t qualifier;
-       pts_ita_funct_comp_name_t name;
+       pts_comp_func_name_t *name;
 };
 
 /**
diff --git a/src/libpts/pts/pts_funct_comp_name.h b/src/libpts/pts/pts_funct_comp_name.h
deleted file mode 100644 (file)
index 81c153a..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 Sansar Choinyambuu
- * HSR Hochschule fuer Technik Rapperswil
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- */
-
-/**
- * @defgroup pts_funct_comp_name pts_funct_comp_name
- * @{ @ingroup pts
- */
-
-#ifndef PTS_FUNCT_COMP_NAME_H_
-#define PTS_FUNCT_COMP_NAME_H_
-
-typedef enum pts_funct_comp_type_t pts_funct_comp_type_t;
-typedef enum pts_funct_comp_name_t pts_funct_comp_name_t;
-typedef enum pts_ita_funct_comp_type_t pts_ita_funct_comp_type_t;
-typedef enum pts_ita_funct_comp_name_t pts_ita_funct_comp_name_t;
-typedef struct pts_qualifier_t pts_qualifier_t;
-typedef struct pts_comp_funct_name_t pts_comp_funct_name_t;
-
-/**
- * PTS Component Functional Type for Qualifier field
- */
-enum pts_funct_comp_type_t {
-       /** Unknown */
-       PTS_FUNC_COMP_TYPE_UNKNOWN =                    0x0,
-       /** Trusted Platform */
-       PTS_FUNC_COMP_TYPE_TRUSTED =                    0x1,
-       /** Operating System */
-       PTS_FUNC_COMP_TYPE_OS =                                 0x2,
-       /** Graphical User Interface */
-       PTS_FUNC_COMP_TYPE_GUI =                                0x3,
-       /** Application */
-       PTS_FUNC_COMP_TYPE_APP =                                0x4,
-       /** Networking */
-       PTS_FUNC_COMP_TYPE_NET =                                0x5,
-       /** Library */
-       PTS_FUNC_COMP_TYPE_LIB =                                0x6,
-       /** TNC Defined Component */
-       PTS_FUNC_COMP_TYPE_TNC =                                0x7,
-       /** All matching Components */
-       PTS_FUNC_COMP_TYPE_ALL =                                0xF,
-};
-
-/**
- * PTS Component Functional Name Binary Enumeration
- */
-enum pts_funct_comp_name_t {
-       /** Ignore */
-       PTS_FUNC_COMP_NAME_IGNORE =                             0x0000,
-       /** CRTM */
-       PTS_FUNC_COMP_NAME_CRTM =                               0x0001,
-       /** BIOS */
-       PTS_FUNC_COMP_NAME_BIOS =                               0x0002,
-       /** Platform Extensions */
-       PTS_FUNC_COMP_NAME_PLATFORM_EXT =               0x0003,
-       /** Motherboard firmware */
-       PTS_FUNC_COMP_NAME_BOARD =                              0x0004,
-       /** Initial Program Loader */
-       PTS_FUNC_COMP_NAME_INIT_LOADER =                0x0005,
-       /** Option ROMs */
-       PTS_FUNC_COMP_NAME_OPT_ROMS =                   0x0006,
-};
-
-/**
- * PTS Component Functional Type for Qualifier field in ITA namespace
- */
-enum pts_ita_funct_comp_type_t {
-       /** Unknown */
-       PTS_ITA_FUNC_COMP_TYPE_UNKNOWN =                0x0,
-       /** Trusted Platform */
-       PTS_ITA_FUNC_COMP_TYPE_TRUSTED =                0x1,
-       /** All matching Components */
-       PTS_ITA_FUNC_COMP_TYPE_ALL =                    0xF,
-};
-
-/**
- * PTS Component Functional Name Binary Enumeration in ITA namespace
- */
-enum pts_ita_funct_comp_name_t {
-       /** Components measured into PCR17 during tboot */
-       PTS_ITA_FUNC_COMP_NAME_TBOOT_POLICY =                           0x0000,
-       /** Components measured into PCR18 during tboot */
-       PTS_ITA_FUNC_COMP_NAME_TBOOT_MLE =                                      0x0001,
-       /** MBR information and stage1 during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_MBR_STAGE1 =                       0x0002,
-       /** bootloader information stage2 part1 during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_STAGE2_PART1 =                     0x0003,
-       /** bootloader information stage2 part2 during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_STAGE2_PART2 =                     0x0004,
-       /** all commandline arguments from menu.lst and those entered in the shell
-        * during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_CMD_LINE_ARGS =            0x0005,
-       /** all files checked via the checkfile-routine during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_CHECKFILE =                        0x0006,
-       /** all files which are actually loaded during boot by trustedGRUB */
-       PTS_ITA_FUNC_COMP_NAME_TGRUB_LOADED_FILES =                     0x0007,
-};
-
-/**
- * Qualifier for Functional Component
- */
-struct pts_qualifier_t {
-       bool      kernel;
-       bool      sub_component;
-       pts_ita_funct_comp_type_t  type;
-};
-
-/**
- * Component Functional Name
- */
-struct pts_comp_funct_name_t {
-       u_int32_t vendor_id;
-       u_int8_t  family_qualifier;
-       u_int32_t name;
-};
-
-#endif /** PTS_FUNCT_COMP_NAME_H_ @}*/
index 0d9796f..28fa19b 100644 (file)
@@ -29,19 +29,19 @@ typedef struct private_tcg_pts_attr_req_funct_comp_evid_t private_tcg_pts_attr_r
  *                                        1                               2                               3
  *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |   Flags          |               Sub-component Depth     (for Component #1)      |
+ *  |     Flags     |     Sub-component Depth (for Component #1)    |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                  Component Functional Name #1                            |
+ *  |                                  Component Functional Name #1                |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                  Component Functional Name #1                            |
+ *  |                                  Component Functional Name #1                |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                                  ........                                                        |
+ *  |                           ........                            |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |   Flags          |               Sub-component Depth     (for Component #N)      |
+ *  |     Flags     |    Sub-component Depth  (for Component #N)    |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                  Component Functional Name #N                            |
+ *  |                   Component Functional Name #N                |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                  Component Functional Name #N                            |
+ *  |                   Component Functional Name #N                |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
@@ -52,25 +52,14 @@ typedef struct private_tcg_pts_attr_req_funct_comp_evid_t private_tcg_pts_attr_r
  *                                        1                               2                               3
  *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |   Component Functional Name Vendor ID            |Fam| Qualifier |
+ *  |   Component Functional Name Vendor ID        |Fam| Qualifier |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |                                  Component Functional Name                                 |
+ *  |                   Component Functional Name                   |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-
-/**
- * Qualifier for Functional Component
- * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification
- *
- *     
- *     0 1 2 3 4 5
- *  +-+-+-+-+-+-+
- *  |K|S| Type  |
- *  +-+-+-+-+-+-+
  */
-
 #define PTS_REQ_FUNCT_COMP_EVID_SIZE           12
+#define PTS_REQ_FUNCT_COMP_FAMILY_MASK         0xC0
 
 /**
  * Private data of an tcg_pts_attr_req_funct_comp_evid_t object.
@@ -143,7 +132,6 @@ METHOD(pa_tnc_attr_t, build, void,
 {
        bio_writer_t *writer;
        enumerator_t *enumerator;
-       u_int8_t qualifier = 0;
        funct_comp_evid_req_entry_t *entry;
 
        writer = bio_writer_create(PTS_REQ_FUNCT_COMP_EVID_SIZE);
@@ -151,26 +139,11 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator = this->requests->create_enumerator(this->requests);
        while (enumerator->enumerate(enumerator, &entry))
        {
-               writer->write_uint8(writer, entry->flags);
-               writer->write_uint24 (writer, entry->sub_comp_depth);
-               writer->write_uint24 (writer, entry->vendor_id);
-
-               if (entry->family != PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM)
-               {
-                       DBG1(DBG_TNC, "Functional Name Encoding Family is not set to 00");
-               }
-
-               qualifier += entry->qualifier.type;
-               if (entry->qualifier.kernel)
-               {
-                       qualifier += 16;
-               }
-               if (entry->qualifier.sub_component)
-               {
-                       qualifier += 32;
-               }
-               writer->write_uint8 (writer, qualifier);
-               writer->write_uint32 (writer, entry->name);
+               writer->write_uint8 (writer, entry->flags);
+               writer->write_uint24(writer, entry->sub_comp_depth);
+               writer->write_uint24(writer, entry->name->get_vendor_id(entry->name));
+               writer->write_uint8 (writer, entry->name->get_qualifier(entry->name));
+               writer->write_uint32(writer, entry->name->get_name(entry->name));
        }
        enumerator->destroy(enumerator);
 
@@ -182,15 +155,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        private_tcg_pts_attr_req_funct_comp_evid_t *this, u_int32_t *offset)
 {
        bio_reader_t *reader;
-       u_int8_t flags, fam_and_qualifier, family = 0;
        status_t status = FAILED;
        funct_comp_evid_req_entry_t *entry = NULL;
-       u_int32_t sub_comp_depth, vendor_id, comp_name;
-       pts_qualifier_t qualifier;
+       u_int32_t sub_comp_depth, vendor_id, name;
+       u_int8_t flags, fam_and_qualifier, qualifier;
        
        if (this->value.len < PTS_REQ_FUNCT_COMP_EVID_SIZE)
        {
-               DBG1(DBG_TNC, "insufficient data for Request Functional Component Evidence");
+               DBG1(DBG_TNC, "insufficient data for Request Functional "
+                                         "Component Evidence");
                *offset = 0;
                return FAILED;
        }
@@ -202,64 +175,46 @@ METHOD(pa_tnc_attr_t, process, status_t,
        {
                if (!reader->read_uint8(reader, &flags))
                {
-                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional"
-                                                 " Component Evidence Flags");
+                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
+                                                 "Component Evidence Flags");
                        goto end;
                }
                if (!reader->read_uint24(reader, &sub_comp_depth))
                {
-                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional"
-                                                 " Component Evidence Sub Component Depth");
+                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
+                                                 "Component Evidence Sub Component Depth");
                        goto end;
                }
                if (!reader->read_uint24(reader, &vendor_id))
                {
-                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional"
-                                                 " Component Evidence Component Name Vendor ID");
+                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
+                                                 "Component Evidence Component Name Vendor ID");
                        goto end;
                }
                if (!reader->read_uint8(reader, &fam_and_qualifier))
                {
-                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional"
-                                                 " Component Evidence Family and Qualifier");
+                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
+                                                 "Component Evidence Family and Qualifier");
                        goto end;
                }
-               if (!reader->read_uint32(reader, &comp_name))
+               if (fam_and_qualifier & PTS_REQ_FUNCT_COMP_FAMILY_MASK)
                {
-                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional"
-                                                 " Component Evidence Component Functional Name");
+                       DBG1(DBG_TNC, "the Functional Name Encoding Family "
+                                                 "is not Binary Enumeration");
                        goto end;
                }
-
-               DBG1(DBG_TNC, "Fam and Qualifier: %d", fam_and_qualifier);
-
-               entry = malloc_thing(funct_comp_evid_req_entry_t);
-
-               if (((fam_and_qualifier >> 6) & 1) )
-               {
-                       family += 1;
-               }
-               if (((fam_and_qualifier >> 7) & 1) )
-               {
-                       family += 2;
-               }
-               
-               if (((fam_and_qualifier >> 5) & 1) )
-               {
-                       qualifier.kernel = TRUE;
-               }
-               if (((fam_and_qualifier >> 4) & 1) )
+               if (!reader->read_uint32(reader, &name))
                {
-                       qualifier.sub_component = TRUE;
+                       DBG1(DBG_TNC, "insufficient data for PTS Request Functional "
+                                                 "Component Evidence Component Functional Name");
+                       goto end;
                }
-               qualifier.type = (fam_and_qualifier & 0xFF);
-               
+               qualifier = fam_and_qualifier & !PTS_REQ_FUNCT_COMP_FAMILY_MASK;
+
+               entry = malloc_thing(funct_comp_evid_req_entry_t);
                entry->flags = flags;
                entry->sub_comp_depth = sub_comp_depth;
-               entry->vendor_id = vendor_id;
-               entry->family = family;
-               entry->qualifier = qualifier;
-               entry->name = comp_name;
+               entry->name = pts_comp_func_name_create(vendor_id, name, qualifier);
                
                this->requests->add(this->requests, entry);
        }
index 1f830cf..8d251bd 100644 (file)
@@ -24,7 +24,7 @@
 typedef struct tcg_pts_attr_req_funct_comp_evid_t tcg_pts_attr_req_funct_comp_evid_t;
 
 #include "tcg_attr.h"
-#include "pts/pts_funct_comp_name.h"
+#include "pts/components/pts_comp_func_name.h"
 #include "pts/pts_funct_comp_evid_req.h"
 #include "pa_tnc/pa_tnc_attr.h"
 
@@ -44,8 +44,7 @@ struct tcg_pts_attr_req_funct_comp_evid_t {
         *
         * @return                                      PTS Functional Component Evidence Requests
         */
-       pts_funct_comp_evid_req_t* (*get_requests)(
-                                                                       tcg_pts_attr_req_funct_comp_evid_t *this);
+       pts_funct_comp_evid_req_t* (*get_requests)(tcg_pts_attr_req_funct_comp_evid_t *this);
        
 };
 
@@ -54,8 +53,7 @@ struct tcg_pts_attr_req_funct_comp_evid_t {
  * 
  * @param requests     Linked list of PTS Functional Component Evidence Requests
  */
-pa_tnc_attr_t* tcg_pts_attr_req_funct_comp_evid_create(
-                                                                               pts_funct_comp_evid_req_t *requests);
+pa_tnc_attr_t* tcg_pts_attr_req_funct_comp_evid_create(pts_funct_comp_evid_req_t *requests);
 
 /**
  * Creates an tcg_pts_attr_req_funct_comp_evid_t object from received data
index e4969c1..755336d 100644 (file)
@@ -77,23 +77,10 @@ typedef struct private_tcg_pts_attr_simple_comp_evid_t private_tcg_pts_attr_simp
  *
  */
 
-/**
- * Qualifier for Functional Component
- * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification
- *
- *     
- *   0 1 2 3 4 5 
- *  +-+-+-+-+-+-+
- *  |K|S| Type  |
- *  +-+-+-+-+-+-+
- */
-
-
-
 #define PTS_SIMPLE_COMP_EVID_SIZE                                      40
 #define PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE     20
 #define PTS_SIMPLE_COMP_EVID_RESERVED                          0x00
-#define PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM                                0x00
+#define PTS_SIMPLE_COMP_EVID_FAMILY_MASK                       0xC0
 
 /**
  * Private data of an tcg_pts_attr_simple_comp_evid_t object.
@@ -139,26 +126,11 @@ struct private_tcg_pts_attr_simple_comp_evid_t {
         * Sub-component Depth
         */
        u_int32_t depth;
-       
-       /**
-        * Component Functional Name Vendor ID
-        */
-       u_int32_t comp_vendor_id;
-       
-       /**
-        * Functional Name Encoding Family
-        */
-       u_int8_t family;
-       
-       /**
-        * Functional Name Category Qualifier
-        */
-       pts_qualifier_t qualifier;
-       
+               
        /**
         * Component Functional Name
         */
-       pts_ita_funct_comp_name_t name;
+       pts_comp_func_name_t *name;
        
        /**
         * Measurement type
@@ -241,7 +213,7 @@ METHOD(pa_tnc_attr_t, build, void,
        private_tcg_pts_attr_simple_comp_evid_t *this)
 {
        bio_writer_t *writer;
-       u_int8_t flags = 0, qualifier = 0;
+       u_int8_t flags = 0;
        
        writer = bio_writer_create(PTS_SIMPLE_COMP_EVID_SIZE);
        /* Determine the flags to set*/
@@ -262,35 +234,11 @@ METHOD(pa_tnc_attr_t, build, void,
                flags += 96;
        }
 
-       writer->write_uint8(writer, flags);
-       writer->write_uint24 (writer, this->depth);
-       writer->write_uint24 (writer, this->comp_vendor_id);
-       
-       if (this->family != PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM)
-       {
-               DBG1(DBG_TNC, "Functional Name Encoding Family is not set to 00");
-       }
-       
-       qualifier += this->qualifier.type;
-       if (this->qualifier.kernel)
-       {
-               qualifier += 16;
-       }
-       if (this->qualifier.sub_component)
-       {
-               qualifier += 32;
-       }
-       
-       /* Unknown or Wildcard should not be used for Qualification*/
-       if (!qualifier || qualifier == 63)
-       {
-               DBG1(DBG_TNC, "Unknown or Wildcard should not be used for"
-                                 " Functional Name Qualifier");
-       }
-       
-       writer->write_uint8 (writer, qualifier);
-       writer->write_uint32(writer, this->name);
-       
+       writer->write_uint8 (writer, flags);
+       writer->write_uint24(writer, this->depth);
+       writer->write_uint24(writer, this->name->get_vendor_id(this->name));
+       writer->write_uint8 (writer, this->name->get_qualifier(this->name));
+       writer->write_uint32(writer, this->name->get_name(this->name));
        writer->write_uint8 (writer, (this->measurement_type << 7));
        writer->write_uint24(writer, this->extended_pcr);
        writer->write_uint16(writer, this->hash_algorithm);
@@ -325,12 +273,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
        private_tcg_pts_attr_simple_comp_evid_t *this, u_int32_t *offset)
 {
        bio_reader_t *reader;
-       u_int8_t flags;
-       u_int8_t fam_and_qualifier;
-       u_int8_t measurement_type;
+       u_int8_t flags, fam_and_qualifier, qualifier;
+       u_int8_t measurement_type, transformation;
        u_int16_t algorithm;
-       u_int8_t transformation;
-       u_int32_t measurement_len;
+       u_int32_t vendor_id, name, measurement_len;
        
        if (this->value.len < PTS_SIMPLE_COMP_EVID_SIZE)
        {
@@ -364,48 +310,22 @@ METHOD(pa_tnc_attr_t, process, status_t,
        }
        
        reader->read_uint24(reader, &this->depth);
-       reader->read_uint24(reader, &this->comp_vendor_id);
-       reader->read_uint8(reader, &fam_and_qualifier);
-       
-       if (((fam_and_qualifier >> 6) & 1) )
-       {
-               this->family += 1;
-       }
-       if (((fam_and_qualifier >> 7) & 1) )
-       {
-               this->family += 2;
-       }
-       
-       if (((fam_and_qualifier >> 5) & 1) )
-       {
-               this->qualifier.kernel = true;
-       }
-       if (((fam_and_qualifier >> 4) & 1) )
-       {
-               this->qualifier.sub_component = true;
-       }
-       this->qualifier.type = ( fam_and_qualifier & 0xF );
+       reader->read_uint24(reader, &vendor_id);
+       reader->read_uint8 (reader, &fam_and_qualifier);
+       reader->read_uint32(reader, &name);
+       reader->read_uint8 (reader, &measurement_type);
+       reader->read_uint24(reader, &this->extended_pcr);
+       reader->read_uint16(reader, &algorithm);
+       reader->read_uint8 (reader, &transformation);
+       reader->read_data  (reader, PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE,
+                                                               &this->measurement_time);
 
-       /* Unknown or Wildcard should not be used for Qualification*/
-       if (!(fam_and_qualifier & 0x3F) || (fam_and_qualifier & 0x3F) == 0x3F)
-       {
-               DBG1(DBG_TNC, "Unknown or Wildcard should not be used for"
-                                 " Functional Name Qualifier");
-       }
+       qualifier = fam_and_qualifier & (!PTS_SIMPLE_COMP_EVID_FAMILY_MASK);
        
-       reader->read_uint32(reader, &this->name);
-       reader->read_uint8(reader, &measurement_type);
+       this->name = pts_comp_func_name_create(vendor_id, name, qualifier);
        this->measurement_type = (measurement_type >> 7 ) & 1;
-       
-       reader->read_uint24(reader, &this->extended_pcr);
-       reader->read_uint16(reader, &algorithm);
        this->hash_algorithm = algorithm;
-       
-       reader->read_uint8(reader, &transformation);
        this->transformation = transformation;
-       
-       reader->read_data(reader, PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE,
-                         &this->measurement_time);
        this->measurement_time = chunk_clone(this->measurement_time);
 
        /*  Optional Policy URI field is included */
@@ -466,25 +386,7 @@ METHOD(tcg_pts_attr_simple_comp_evid_t, get_sub_component_depth, u_int32_t,
        return this->depth;
 }
 
-METHOD(tcg_pts_attr_simple_comp_evid_t, get_spec_comp_funct_name_vendor_id, u_int32_t,
-       private_tcg_pts_attr_simple_comp_evid_t *this)
-{
-       return this->comp_vendor_id;
-}
-
-METHOD(tcg_pts_attr_simple_comp_evid_t, get_family, u_int8_t,
-       private_tcg_pts_attr_simple_comp_evid_t *this)
-{
-       return this->family;
-}
-
-METHOD(tcg_pts_attr_simple_comp_evid_t, get_qualifier, pts_qualifier_t,
-       private_tcg_pts_attr_simple_comp_evid_t *this)
-{
-       return this->qualifier;
-}
-
-METHOD(tcg_pts_attr_simple_comp_evid_t, get_comp_funct_name, pts_ita_funct_comp_name_t,
+METHOD(tcg_pts_attr_simple_comp_evid_t, get_comp_func_name, pts_comp_func_name_t*,
        private_tcg_pts_attr_simple_comp_evid_t *this)
 {
        return this->name;
@@ -578,10 +480,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evi
                        .is_pcr_info_included = _is_pcr_info_included,
                        .get_flags= _get_flags,
                        .get_sub_component_depth = _get_sub_component_depth,
-                       .get_spec_comp_funct_name_vendor_id = _get_spec_comp_funct_name_vendor_id,
-                       .get_family = _get_family,
-                       .get_qualifier = _get_qualifier,
-                       .get_comp_funct_name = _get_comp_funct_name,
+                       .get_comp_func_name = _get_comp_func_name,
                        .get_measurement_type = _get_measurement_type,
                        .get_extended_pcr = _get_extended_pcr,
                        .get_hash_algorithm = _get_hash_algorithm,
@@ -598,9 +497,6 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evi
                .pcr_info_included = params.pcr_info_included,
                .flags = params.flags,
                .depth = params.depth,
-               .comp_vendor_id = params.vendor_id,
-               .family = PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM,
-               .qualifier = params.qualifier,
                .name = params.name,
                .extended_pcr = params.extended_pcr,
                .hash_algorithm = params.hash_algorithm,
@@ -638,10 +534,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data)
                        .is_pcr_info_included = _is_pcr_info_included,
                        .get_flags= _get_flags,
                        .get_sub_component_depth = _get_sub_component_depth,
-                       .get_spec_comp_funct_name_vendor_id = _get_spec_comp_funct_name_vendor_id,
-                       .get_family = _get_family,
-                       .get_qualifier = _get_qualifier,
-                       .get_comp_funct_name = _get_comp_funct_name,
+                       .get_comp_func_name = _get_comp_func_name,
                        .get_measurement_type = _get_measurement_type,
                        .get_extended_pcr = _get_extended_pcr,
                        .get_hash_algorithm = _get_hash_algorithm,
@@ -655,7 +548,6 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data)
                },
                .vendor_id = PEN_TCG,
                .type = TCG_PTS_SIMPLE_COMP_EVID,
-               .family = PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM,
                .value = chunk_clone(data),
        );
 
index ff846fc..b26f750 100644 (file)
@@ -28,7 +28,7 @@ typedef struct tcg_pts_attr_simple_comp_evid_params_t tcg_pts_attr_simple_comp_e
 
 #include "tcg_attr.h"
 #include "pts/pts_meas_algo.h"
-#include "pts/pts_funct_comp_name.h" 
+#include "pts/components/pts_comp_func_name.h" 
 #include "pa_tnc/pa_tnc_attr.h"
 
 /**
@@ -66,9 +66,7 @@ struct tcg_pts_attr_simple_comp_evid_params_t {
        bool pcr_info_included;
        pts_attr_simple_comp_evid_flag_t flags;
        u_int32_t depth;
-       u_int32_t vendor_id;
-       pts_qualifier_t qualifier;
-       pts_ita_funct_comp_name_t name;
+       pts_comp_func_name_t *name;
        u_int32_t extended_pcr;
        pts_meas_algorithms_t hash_algorithm;
        pts_pcr_transform_t transformation;
@@ -112,32 +110,11 @@ struct tcg_pts_attr_simple_comp_evid_t {
        u_int32_t (*get_sub_component_depth)(tcg_pts_attr_simple_comp_evid_t *this);
        
        /**
-        * Get Specific Component Functional Name Vendor ID
-        *
-        * @return                                      Component Functional Name Vendor ID
-        */
-       u_int32_t (*get_spec_comp_funct_name_vendor_id)(tcg_pts_attr_simple_comp_evid_t *this);
-       
-       /**
-        * Get Family
-        *
-        * @return                                      Functional Name Family
-        */
-       u_int8_t (*get_family)(tcg_pts_attr_simple_comp_evid_t *this);
-       
-       /**
-        * Get Qualifier
-        *
-        * @return                                      Functional Name Category Qualifier
-        */
-       pts_qualifier_t (*get_qualifier)(tcg_pts_attr_simple_comp_evid_t *this);
-       
-       /**
         * Get Special Component Functional Name
         *
         * @return                                      Component Functional Name
         */
-       pts_ita_funct_comp_name_t (*get_comp_funct_name)(tcg_pts_attr_simple_comp_evid_t *this);
+       pts_comp_func_name_t* (*get_comp_func_name)(tcg_pts_attr_simple_comp_evid_t *this);
        
        /**
         * Get Measurement Type