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_ @}*/