refactored PTS functional component measurements
This commit is contained in:
@@ -372,12 +372,6 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
attestation_state->get_file_meas_request_count(attestation_state));
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
}
|
||||
if (attestation_state->get_component_count(attestation_state))
|
||||
{
|
||||
DBG1(DBG_IMV, "failure due to %d components waiting for evidence",
|
||||
attestation_state->get_component_count(attestation_state));
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
}
|
||||
if (attestation_state->get_measurement_error(attestation_state))
|
||||
{
|
||||
state->set_recommendation(state,
|
||||
|
||||
@@ -276,34 +276,21 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
pts_comp_evidence_t *evidence;
|
||||
pts_component_t *comp;
|
||||
u_int32_t depth;
|
||||
status_t status;
|
||||
|
||||
attr_cast = (tcg_pts_attr_simple_comp_evid_t*)attr;
|
||||
evidence = attr_cast->get_comp_evidence(attr_cast);
|
||||
name = evidence->get_comp_func_name(evidence, &depth);
|
||||
|
||||
comp = attestation_state->check_off_component(attestation_state, name);
|
||||
comp = attestation_state->get_component(attestation_state, name);
|
||||
if (!comp)
|
||||
{
|
||||
DBG1(DBG_IMV, " no entry found for component evidence request");
|
||||
break;
|
||||
}
|
||||
status = comp->verify(comp, pts, evidence);
|
||||
|
||||
switch (status)
|
||||
if (comp->verify(comp, pts, evidence) != SUCCESS)
|
||||
{
|
||||
default:
|
||||
case FAILED:
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
comp->destroy(comp);
|
||||
break;
|
||||
case SUCCESS:
|
||||
name->log(name, " successfully measured ");
|
||||
comp->destroy(comp);
|
||||
break;
|
||||
case NEED_MORE:
|
||||
/* re-enter component into list */
|
||||
attestation_state->add_component(attestation_state, comp);
|
||||
attestation_state->set_measurement_error(attestation_state);
|
||||
name->log(name, " measurement mismatch for ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -353,8 +340,11 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
DBG2(DBG_IMV, "TPM Quote Info signature verification successful");
|
||||
free(quote_info.ptr);
|
||||
|
||||
/* Finalize any pending measurement registrations */
|
||||
attestation_state->check_off_registrations(attestation_state);
|
||||
/**
|
||||
* Finalize any pending measurement registrations and check
|
||||
* if all expected component measurements were received
|
||||
*/
|
||||
attestation_state->finalize_components(attestation_state);
|
||||
}
|
||||
|
||||
if (attr_cast->get_evid_sig(attr_cast, &evid_sig))
|
||||
|
||||
@@ -296,7 +296,7 @@ METHOD(imv_attestation_state_t, add_component, void,
|
||||
this->components->insert_last(this->components, entry);
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, check_off_component, pts_component_t*,
|
||||
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;
|
||||
@@ -308,7 +308,6 @@ METHOD(imv_attestation_state_t, check_off_component, pts_component_t*,
|
||||
if (name->equals(name, entry->get_comp_func_name(entry)))
|
||||
{
|
||||
found = entry;
|
||||
this->components->remove_at(this->components, enumerator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -316,30 +315,6 @@ METHOD(imv_attestation_state_t, check_off_component, pts_component_t*,
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, check_off_registrations, void,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
pts_component_t *entry;
|
||||
|
||||
enumerator = this->components->create_enumerator(this->components);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (entry->check_off_registrations(entry))
|
||||
{
|
||||
this->components->remove_at(this->components, enumerator);
|
||||
entry->destroy(entry);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, get_component_count, int,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
return this->components->get_count(this->components);
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, get_measurement_error, bool,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
@@ -352,6 +327,22 @@ METHOD(imv_attestation_state_t, set_measurement_error, void,
|
||||
this->measurement_error = TRUE;
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, finalize_components, void,
|
||||
private_imv_attestation_state_t *this)
|
||||
{
|
||||
pts_component_t *entry;
|
||||
|
||||
while (this->components->remove_last(this->components,
|
||||
(void**)&entry) == SUCCESS)
|
||||
{
|
||||
if (!entry->finalize(entry))
|
||||
{
|
||||
_set_measurement_error(this);
|
||||
}
|
||||
entry->destroy(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
@@ -380,9 +371,8 @@ imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.check_off_file_meas_request = _check_off_file_meas_request,
|
||||
.get_file_meas_request_count = _get_file_meas_request_count,
|
||||
.add_component = _add_component,
|
||||
.check_off_component = _check_off_component,
|
||||
.check_off_registrations = _check_off_registrations,
|
||||
.get_component_count = _get_component_count,
|
||||
.get_component = _get_component,
|
||||
.finalize_components = _finalize_components,
|
||||
.get_measurement_error = _get_measurement_error,
|
||||
.set_measurement_error = _set_measurement_error,
|
||||
},
|
||||
|
||||
@@ -112,25 +112,19 @@ struct imv_attestation_state_t {
|
||||
void (*add_component)(imv_attestation_state_t *this, pts_component_t *entry);
|
||||
|
||||
/**
|
||||
* Returns the number of Functional Component waiting for evidence
|
||||
*
|
||||
* @return Number of waiting Functional Components
|
||||
*/
|
||||
int (*get_component_count)(imv_attestation_state_t *this);
|
||||
|
||||
/**
|
||||
* Check for presence of Functional Component and remove and return it
|
||||
* Get a Functional Component with a given name
|
||||
*
|
||||
* @param name Name of the requested Functional Component
|
||||
* @return Functional Component if found, NULL otherwise
|
||||
*/
|
||||
pts_component_t* (*check_off_component)(imv_attestation_state_t *this,
|
||||
pts_comp_func_name_t *name);
|
||||
pts_component_t* (*get_component)(imv_attestation_state_t *this,
|
||||
pts_comp_func_name_t *name);
|
||||
|
||||
/**
|
||||
* Tell the Functional Components to finalize any measurement registrations
|
||||
* and to check if all expected measurements were received
|
||||
*/
|
||||
void (*check_off_registrations)(imv_attestation_state_t *this);
|
||||
void (*finalize_components)(imv_attestation_state_t *this);
|
||||
|
||||
/**
|
||||
* Indicates if a file measurement error occurred
|
||||
|
||||
Reference in New Issue
Block a user