object oriented approach to pts functional components

This commit is contained in:
Andreas Steffen
2011-11-28 21:20:23 +01:00
parent c6beb16689
commit 051dfbd654
26 changed files with 1371 additions and 419 deletions
@@ -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"
);
@@ -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_ @}*/
@@ -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;
}
@@ -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_ @}*/
@@ -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;
}
@@ -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_ @}*/
@@ -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;
}
@@ -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_ @}*/
+63
View File
@@ -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_ @}*/
@@ -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;
}
@@ -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_ @}*/
@@ -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"
);
@@ -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_ @}*/
-1
View 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>
+3 -5
View 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;
};
/**
-128
View File
@@ -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_ @}*/