implemented support if functional sub-components
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Sansar Choinyambuu
|
||||
* Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
|
||||
#include <libpts.h>
|
||||
#include <pts/pts.h>
|
||||
|
||||
#include <tcg/tcg_pts_attr_proto_caps.h>
|
||||
@@ -378,7 +377,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
"support sub component measurements");
|
||||
return FALSE;
|
||||
}
|
||||
comp = pts_components->create(pts_components, name, depth, NULL);
|
||||
comp = attestation_state->create_component(attestation_state,
|
||||
name, depth);
|
||||
if (!comp)
|
||||
{
|
||||
DBG2(DBG_IMC, " not registered: no evidence provided");
|
||||
@@ -388,7 +388,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
/* do the component evidence measurement[s] and cache them */
|
||||
do
|
||||
{
|
||||
status = comp->measure(comp, pts, &evid);
|
||||
status = comp->measure(comp, name->get_qualifier(name),
|
||||
pts, &evid);
|
||||
if (status == FAILED)
|
||||
{
|
||||
break;
|
||||
@@ -396,7 +397,6 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
attestation_state->add_evidence(attestation_state, evid);
|
||||
}
|
||||
while (status == NEED_MORE);
|
||||
comp->destroy(comp);
|
||||
}
|
||||
e->destroy(e);
|
||||
break;
|
||||
|
||||
@@ -15,10 +15,13 @@
|
||||
|
||||
#include "imc_attestation_state.h"
|
||||
|
||||
#include <libpts.h>
|
||||
|
||||
#include <utils/linked_list.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_imc_attestation_state_t private_imc_attestation_state_t;
|
||||
typedef struct func_comp_t func_comp_t;
|
||||
|
||||
/**
|
||||
* Private data of an imc_attestation_state_t object.
|
||||
@@ -61,7 +64,12 @@ struct private_imc_attestation_state_t {
|
||||
pts_t *pts;
|
||||
|
||||
/**
|
||||
* PA-TNC attribute cache list
|
||||
* List of Functional Components
|
||||
*/
|
||||
linked_list_t *components;
|
||||
|
||||
/**
|
||||
* Functional Component Evidence cache list
|
||||
*/
|
||||
linked_list_t *list;
|
||||
|
||||
@@ -110,12 +118,14 @@ METHOD(imc_state_t, change_state, void,
|
||||
this->state = new_state;
|
||||
}
|
||||
|
||||
|
||||
METHOD(imc_state_t, destroy, void,
|
||||
private_imc_attestation_state_t *this)
|
||||
{
|
||||
this->pts->destroy(this->pts);
|
||||
this->list->destroy_offset(this->list, offsetof(pts_comp_evidence_t, destroy));
|
||||
this->components->destroy_offset(this->components,
|
||||
offsetof(pts_component_t, destroy));
|
||||
this->list->destroy_offset(this->list,
|
||||
offsetof(pts_comp_evidence_t, destroy));
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -125,6 +135,38 @@ METHOD(imc_attestation_state_t, get_pts, pts_t*,
|
||||
return this->pts;
|
||||
}
|
||||
|
||||
METHOD(imc_attestation_state_t, create_component, pts_component_t*,
|
||||
private_imc_attestation_state_t *this, pts_comp_func_name_t *name,
|
||||
u_int32_t depth)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
pts_component_t *component;
|
||||
bool found = FALSE;
|
||||
|
||||
enumerator = this->components->create_enumerator(this->components);
|
||||
while (enumerator->enumerate(enumerator, &component))
|
||||
{
|
||||
if (name->equals(name, component->get_comp_func_name(component)))
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
component = pts_components->create(pts_components, name, depth, NULL);
|
||||
if (!component)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
this->components->insert_last(this->components, component);
|
||||
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
METHOD(imc_attestation_state_t, add_evidence, void,
|
||||
private_imc_attestation_state_t *this, pts_comp_evidence_t *evid)
|
||||
{
|
||||
@@ -158,12 +200,14 @@ imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_pts = _get_pts,
|
||||
.create_component = _create_component,
|
||||
.add_evidence = _add_evidence,
|
||||
.next_evidence = _next_evidence,
|
||||
},
|
||||
.connection_id = connection_id,
|
||||
.state = TNC_CONNECTION_STATE_CREATE,
|
||||
.pts = pts_create(TRUE),
|
||||
.components = linked_list_create(),
|
||||
.list = linked_list_create(),
|
||||
);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <imc/imc_state.h>
|
||||
#include <pts/pts.h>
|
||||
#include <pts/components/pts_component.h>
|
||||
#include <pts/components/pts_comp_evidence.h>
|
||||
#include <library.h>
|
||||
|
||||
@@ -46,6 +47,16 @@ struct imc_attestation_state_t {
|
||||
*/
|
||||
pts_t* (*get_pts)(imc_attestation_state_t *this);
|
||||
|
||||
/**
|
||||
* Create and add an entry to the list of Functional Components
|
||||
*
|
||||
* @param name Component Functional Name
|
||||
* @param depth Sub-component Depth
|
||||
* @return created functional component instance or NULL
|
||||
*/
|
||||
pts_component_t* (*create_component)(imc_attestation_state_t *this,
|
||||
pts_comp_func_name_t *name, u_int32_t depth);
|
||||
|
||||
/**
|
||||
* Add an entry to the Component Evidence cache list
|
||||
*
|
||||
|
||||
@@ -1599,17 +1599,17 @@ INSERT INTO components (
|
||||
INSERT INTO components (
|
||||
vendor_id, name, qualifier
|
||||
) VALUES (
|
||||
36906, 3, 33 /* ITA IMA */
|
||||
36906, 3, 33 /* ITA IMA - Trusted Platform */
|
||||
);
|
||||
|
||||
INSERT INTO components (
|
||||
vendor_id, name, qualifier
|
||||
) VALUES (
|
||||
36906, 3, 34 /* ITA IMA - Operating System */
|
||||
);
|
||||
|
||||
/* AIK Component */
|
||||
|
||||
INSERT INTO key_component (
|
||||
key, component, depth, seq_no
|
||||
) VALUES (
|
||||
2, 2, 0, 1
|
||||
);
|
||||
|
||||
INSERT INTO key_component (
|
||||
key, component, depth, seq_no
|
||||
) VALUES (
|
||||
@@ -1622,3 +1622,9 @@ INSERT INTO key_component (
|
||||
1, 2, 0, 2
|
||||
);
|
||||
|
||||
INSERT INTO key_component (
|
||||
key, component, depth, seq_no
|
||||
) VALUES (
|
||||
1, 4, 0, 3
|
||||
);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "imv_attestation_build.h"
|
||||
#include "imv_attestation_state.h"
|
||||
|
||||
#include <libpts.h>
|
||||
#include <tcg/tcg_pts_attr_proto_caps.h>
|
||||
#include <tcg/tcg_pts_attr_meas_algo.h>
|
||||
#include <tcg/tcg_pts_attr_dh_nonce_params_req.h>
|
||||
@@ -252,15 +251,15 @@ bool imv_attestation_build(linked_list_t *attr_list,
|
||||
comp_name = pts_comp_func_name_create(vid, name, qualifier);
|
||||
comp_name->log(comp_name, " ");
|
||||
|
||||
comp = pts_components->create(pts_components, comp_name,
|
||||
depth, pts_db);
|
||||
comp = attestation_state->create_component(attestation_state,
|
||||
comp_name, depth, pts_db);
|
||||
if (!comp)
|
||||
{
|
||||
DBG2(DBG_IMV, " not registered: removed from request");
|
||||
DBG2(DBG_IMV, " not registered or duplicate"
|
||||
" - removed from request");
|
||||
comp_name->destroy(comp_name);
|
||||
continue;
|
||||
}
|
||||
attestation_state->add_component(attestation_state, comp);
|
||||
if (first_component)
|
||||
{
|
||||
attr = tcg_pts_attr_req_func_comp_evid_create();
|
||||
|
||||
@@ -294,7 +294,8 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
DBG1(DBG_IMV, " no entry found for component evidence request");
|
||||
break;
|
||||
}
|
||||
if (comp->verify(comp, pts, evidence) != SUCCESS)
|
||||
if (comp->verify(comp, name->get_qualifier(name), pts,
|
||||
evidence) != SUCCESS)
|
||||
{
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
name->log(name, " measurement mismatch for ");
|
||||
|
||||
@@ -15,21 +15,15 @@
|
||||
|
||||
#include "imv_attestation_state.h"
|
||||
|
||||
#include <libpts.h>
|
||||
|
||||
#include <utils/lexparser.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct private_imv_attestation_state_t private_imv_attestation_state_t;
|
||||
typedef struct file_meas_request_t file_meas_request_t;
|
||||
|
||||
/**
|
||||
* PTS File/Directory Measurement request entry
|
||||
*/
|
||||
struct file_meas_request_t {
|
||||
u_int16_t id;
|
||||
int file_id;
|
||||
bool is_dir;
|
||||
};
|
||||
typedef struct func_comp_t func_comp_t;
|
||||
|
||||
/**
|
||||
* Private data of an imv_attestation_state_t object.
|
||||
@@ -108,6 +102,32 @@ struct private_imv_attestation_state_t {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* PTS File/Directory Measurement request entry
|
||||
*/
|
||||
struct file_meas_request_t {
|
||||
u_int16_t id;
|
||||
int file_id;
|
||||
bool is_dir;
|
||||
};
|
||||
|
||||
/**
|
||||
* PTS Functional Component entry
|
||||
*/
|
||||
struct func_comp_t {
|
||||
pts_component_t *comp;
|
||||
u_int8_t qualifier;
|
||||
};
|
||||
|
||||
/**
|
||||
* Frees a func_comp_t object
|
||||
*/
|
||||
static void free_func_comp(func_comp_t *this)
|
||||
{
|
||||
this->comp->destroy(this->comp);
|
||||
free(this);
|
||||
}
|
||||
|
||||
typedef struct entry_t entry_t;
|
||||
|
||||
/**
|
||||
@@ -237,8 +257,7 @@ METHOD(imv_state_t, destroy, void,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
this->file_meas_requests->destroy_function(this->file_meas_requests, free);
|
||||
this->components->destroy_offset(this->components,
|
||||
offsetof(pts_component_t, destroy));
|
||||
this->components->destroy_function(this->components, (void *)free_func_comp);
|
||||
this->pts->destroy(this->pts);
|
||||
free(this);
|
||||
}
|
||||
@@ -307,24 +326,69 @@ METHOD(imv_attestation_state_t, get_file_meas_request_count, int,
|
||||
return this->file_meas_requests->get_count(this->file_meas_requests);
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, add_component, void,
|
||||
private_imv_attestation_state_t *this, pts_component_t *entry)
|
||||
METHOD(imv_attestation_state_t, create_component, pts_component_t*,
|
||||
private_imv_attestation_state_t *this, pts_comp_func_name_t *name,
|
||||
u_int32_t depth, pts_database_t *pts_db)
|
||||
{
|
||||
this->components->insert_last(this->components, entry);
|
||||
enumerator_t *enumerator;
|
||||
func_comp_t *entry, *new_entry;
|
||||
pts_component_t *component;
|
||||
bool found = FALSE;
|
||||
|
||||
enumerator = this->components->create_enumerator(this->components);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (name->equals(name, entry->comp->get_comp_func_name(entry->comp)))
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (found)
|
||||
{
|
||||
if (name->get_qualifier(name) == entry->qualifier)
|
||||
{
|
||||
/* duplicate entry */
|
||||
return NULL;
|
||||
}
|
||||
new_entry = malloc_thing(func_comp_t);
|
||||
new_entry->qualifier = name->get_qualifier(name);
|
||||
new_entry->comp = entry->comp->get_ref(entry->comp);
|
||||
this->components->insert_last(this->components, new_entry);
|
||||
return entry->comp;
|
||||
}
|
||||
else
|
||||
{
|
||||
component = pts_components->create(pts_components, name, depth, pts_db);
|
||||
if (!component)
|
||||
{
|
||||
/* unsupported component */
|
||||
return NULL;
|
||||
}
|
||||
new_entry = malloc_thing(func_comp_t);
|
||||
new_entry->qualifier = name->get_qualifier(name);
|
||||
new_entry->comp = component;
|
||||
this->components->insert_last(this->components, new_entry);
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, get_component, pts_component_t*,
|
||||
private_imv_attestation_state_t *this, pts_comp_func_name_t *name)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
pts_component_t *entry, *found = NULL;
|
||||
func_comp_t *entry;
|
||||
pts_component_t *found = NULL;
|
||||
|
||||
enumerator = this->components->create_enumerator(this->components);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (name->equals(name, entry->get_comp_func_name(entry)))
|
||||
if (name->equals(name, entry->comp->get_comp_func_name(entry->comp)) &&
|
||||
name->get_qualifier(name) == entry->qualifier)
|
||||
{
|
||||
found = entry;
|
||||
found = entry->comp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -347,16 +411,16 @@ METHOD(imv_attestation_state_t, set_measurement_error, void,
|
||||
METHOD(imv_attestation_state_t, finalize_components, void,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
pts_component_t *entry;
|
||||
func_comp_t *entry;
|
||||
|
||||
while (this->components->remove_last(this->components,
|
||||
(void**)&entry) == SUCCESS)
|
||||
{
|
||||
if (!entry->finalize(entry))
|
||||
if (!entry->comp->finalize(entry->comp, entry->qualifier))
|
||||
{
|
||||
_set_measurement_error(this);
|
||||
}
|
||||
entry->destroy(entry);
|
||||
free_func_comp(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +459,7 @@ imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.add_file_meas_request = _add_file_meas_request,
|
||||
.check_off_file_meas_request = _check_off_file_meas_request,
|
||||
.get_file_meas_request_count = _get_file_meas_request_count,
|
||||
.add_component = _add_component,
|
||||
.create_component = _create_component,
|
||||
.get_component = _get_component,
|
||||
.finalize_components = _finalize_components,
|
||||
.components_finalized = _components_finalized,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <imv/imv_state.h>
|
||||
#include <pts/pts.h>
|
||||
#include <pts/pts_database.h>
|
||||
#include <pts/components/pts_component.h>
|
||||
#include <library.h>
|
||||
|
||||
@@ -105,11 +106,17 @@ struct imv_attestation_state_t {
|
||||
u_int16_t id, int *file_id, bool *is_dir);
|
||||
|
||||
/**
|
||||
* Add an entry to the list of Functional Components waiting for evidence
|
||||
* Create and add an entry to the list of Functional Components
|
||||
*
|
||||
* @param entry Functional Component
|
||||
* @param name Component Functional Name
|
||||
* @param depth Sub-component Depth
|
||||
* @param pts_db PTS measurement database
|
||||
* @return created functional component instance or NULL
|
||||
*/
|
||||
void (*add_component)(imv_attestation_state_t *this, pts_component_t *entry);
|
||||
pts_component_t* (*create_component)(imv_attestation_state_t *this,
|
||||
pts_comp_func_name_t *name,
|
||||
u_int32_t depth,
|
||||
pts_database_t *pts_db);
|
||||
|
||||
/**
|
||||
* Get a Functional Component with a given name
|
||||
|
||||
Reference in New Issue
Block a user