Functional Component Evidence Request object
authorSansar Choinyambuu <schoinya@hsr.ch>
Wed, 16 Nov 2011 15:42:47 +0000 (16:42 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 20:20:23 +0000 (21:20 +0100)
src/libpts/Makefile.am
src/libpts/pts/pts_funct_comp_evid_req.c [new file with mode: 0644]
src/libpts/pts/pts_funct_comp_evid_req.h [new file with mode: 0644]

index bf0cbf9..12bd2a7 100644 (file)
@@ -10,6 +10,7 @@ libpts_la_SOURCES = \
        pts/pts.h pts/pts.c \
        pts/pts_error.h pts/pts_error.c \
        pts/pts_proto_caps.h pts/pts_funct_comp_name.h \
+       pts/pts_funct_comp_evid_req.h pts/pts_funct_comp_evid_req.c \
        pts/pts_creds.h pts/pts_creds.c \
        pts/pts_database.h pts/pts_database.c \
        pts/pts_dh_group.h pts/pts_dh_group.c \
diff --git a/src/libpts/pts/pts_funct_comp_evid_req.c b/src/libpts/pts/pts_funct_comp_evid_req.c
new file mode 100644 (file)
index 0000000..47641fe
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+#include "pts_funct_comp_evid_req.h"
+
+#include <utils/linked_list.h>
+#include <debug.h>
+
+typedef struct private_pts_funct_comp_evid_req_t private_pts_funct_comp_evid_req_t;
+
+/**
+ * Private data of a private_pts_funct_comp_evid_req_t object.
+ *
+ */
+struct private_pts_funct_comp_evid_req_t {
+
+       /**
+        * Public pts_funct_comp_evid_req_t interface.
+        */
+       pts_funct_comp_evid_req_t public;
+
+       /**
+        * List of Functional Component Evidence Requests
+        */
+       linked_list_t *list;
+};
+
+METHOD(pts_funct_comp_evid_req_t, get_req_count, int,
+       private_pts_funct_comp_evid_req_t *this)
+{
+       return this->list->get_count(this->list);
+}
+
+METHOD(pts_funct_comp_evid_req_t, add, void,
+               private_pts_funct_comp_evid_req_t *this,
+               funct_comp_evid_req_entry_t *entry)
+{
+       this->list->insert_last(this->list, entry);
+}
+
+METHOD(pts_funct_comp_evid_req_t, create_enumerator, enumerator_t*,
+       private_pts_funct_comp_evid_req_t *this)
+{
+       return this->list->create_enumerator(this->list);
+}
+
+METHOD(pts_funct_comp_evid_req_t, destroy, void,
+       private_pts_funct_comp_evid_req_t *this)
+{
+       this->list->destroy(this->list);
+       free(this);
+}
+
+/**
+ * See header
+ */
+pts_funct_comp_evid_req_t *pts_funct_comp_evid_req_create()
+{
+       private_pts_funct_comp_evid_req_t *this;
+
+       INIT(this,
+               .public = {
+                       .get_req_count = _get_req_count,
+                       .add = _add,
+                       .create_enumerator = _create_enumerator,
+                       .destroy = _destroy,
+               },
+               .list = linked_list_create(),
+       );
+
+       return &this->public;
+}
+
diff --git a/src/libpts/pts/pts_funct_comp_evid_req.h b/src/libpts/pts/pts_funct_comp_evid_req.h
new file mode 100644 (file)
index 0000000..7e2dbd3
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * 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_evid_req pts_funct_comp_evid_req
+ * @{ @ingroup pts
+ */
+
+#ifndef PTS_FUNCT_COMP_EVID_REQ_H_
+#define PTS_FUNCT_COMP_EVID_REQ_H_
+
+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 <library.h>
+#include "pts_funct_comp_name.h"
+
+#define PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM                0x00
+
+/**
+ * PTS Request Functional Component Evidence Flags
+ */
+enum pts_attr_req_funct_comp_evid_flag_t {
+       /** Transitive Trust Chain flag */
+       PTS_REQ_FUNC_COMP_FLAG_TTC =                            (1<<7),
+       /** Verify Component flag */
+       PTS_REQ_FUNC_COMP_FLAG_VER =                             (1<<6),
+       /** Current Evidence flag */
+       PTS_REQ_FUNC_COMP_FLAG_CURR =                            (1<<5),
+       /** PCR Information flag */
+       PTS_REQ_FUNC_COMP_FLAG_PCR =                             (1<<4),
+};
+
+/**
+ * PTS Functional Component Evidence Request entry
+ */
+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;
+};
+
+/**
+ * Class storing PTS Functional Component Evidence Request
+ */
+struct pts_funct_comp_evid_req_t {
+
+       /**
+        * Get the number of requested components
+        *
+        * @return                              Number of requested components
+        */
+       int (*get_req_count)(pts_funct_comp_evid_req_t *this);
+
+       /**
+        * Add a PTS File Measurement
+        *
+        * @param entry                 PTS Functional Component Evidence Request entry         
+        */
+       void (*add)(pts_funct_comp_evid_req_t *this,
+                                                                       funct_comp_evid_req_entry_t *entry);
+
+       /**
+         * Create a PTS Functional Component Evidence Request enumerator
+         *
+         * @return                             Enumerator returning flags, sub-component depth and
+         *                                             functional component name 
+         */
+       enumerator_t* (*create_enumerator)(pts_funct_comp_evid_req_t *this);
+
+       /**
+        * Destroys a pts_funct_comp_evid_req_t object.
+        */
+       void (*destroy)(pts_funct_comp_evid_req_t *this);
+
+};
+
+/**
+ * Creates a pts_funct_comp_evid_req_t object
+ */
+pts_funct_comp_evid_req_t* pts_funct_comp_evid_req_create();
+
+#endif /** PTS_FUNCT_COMP_EVID_REQ_H_ @}*/