refactored PCR functionality
This commit is contained in:
@@ -406,39 +406,25 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
{
|
||||
pts_simple_evid_final_flag_t flags;
|
||||
pts_meas_algorithms_t composite_algorithm = 0;
|
||||
pts_comp_evidence_t *evidence;
|
||||
pts_comp_evidence_t *evid;
|
||||
chunk_t pcr_composite, quote_signature;
|
||||
u_int32_t i, evid_count, extended_pcr;
|
||||
u_int32_t *pcrs;
|
||||
bool use_quote2;
|
||||
|
||||
/* Send buffered Simple Component Evidences */
|
||||
evid_count = attestation_state->get_evid_count(attestation_state);
|
||||
pcrs = (u_int32_t*)malloc(sizeof(u_int32_t)*evid_count);
|
||||
|
||||
for (i = 0; i < evid_count; i++)
|
||||
while (attestation_state->next_evidence(attestation_state, &evid))
|
||||
{
|
||||
evidence = attestation_state->next_evidence(attestation_state);
|
||||
extended_pcr = evidence->get_extended_pcr(evidence);
|
||||
|
||||
/**
|
||||
* Add extended PCR number to PCR list to quote
|
||||
* Duplicated PCR numbers have no influence
|
||||
*/
|
||||
pcrs[i] = extended_pcr;
|
||||
pts->select_pcr(pts, evid->get_extended_pcr(evid));
|
||||
|
||||
/* Send Simple Component Evidence */
|
||||
attr = tcg_pts_attr_simple_comp_evid_create(evidence);
|
||||
attr = tcg_pts_attr_simple_comp_evid_create(evid);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
}
|
||||
|
||||
use_quote2 = (lib->settings->get_int(lib->settings,
|
||||
"libimcv.plugins.imc-attestation.quote_version", 1) == 1) ?
|
||||
FALSE : TRUE;
|
||||
use_quote2 = lib->settings->get_bool(lib->settings,
|
||||
"libimcv.plugins.imc-attestation.use_quote2", TRUE);
|
||||
|
||||
/* Quote */
|
||||
if (!pts->quote_tpm(pts, use_quote2, pcrs, evid_count,
|
||||
&pcr_composite, "e_signature))
|
||||
if (!pts->quote_tpm(pts, use_quote2, &pcr_composite, "e_signature))
|
||||
{
|
||||
DBG1(DBG_IMC, "error occured during TPM quote operation");
|
||||
return FALSE;
|
||||
|
||||
@@ -85,26 +85,12 @@ METHOD(imc_attestation_state_t, add_evidence, void,
|
||||
this->list->insert_last(this->list, evidence);
|
||||
}
|
||||
|
||||
METHOD(imc_attestation_state_t, get_evid_count, int,
|
||||
private_imc_attestation_state_t *this)
|
||||
METHOD(imc_attestation_state_t, next_evidence, bool,
|
||||
private_imc_attestation_state_t *this, pts_comp_evidence_t **evid)
|
||||
{
|
||||
return this->list->get_count(this->list);
|
||||
return this->list->remove_first(this->list, (void**)evid) == SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(imc_attestation_state_t, next_evidence, pts_comp_evidence_t*,
|
||||
private_imc_attestation_state_t *this)
|
||||
{
|
||||
pts_comp_evidence_t *evidence;
|
||||
|
||||
if (this->list->remove_first(this->list, (void**)&evidence) == SUCCESS)
|
||||
{
|
||||
return evidence;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
@@ -122,7 +108,6 @@ imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
},
|
||||
.get_pts = _get_pts,
|
||||
.add_evidence = _add_evidence,
|
||||
.get_evid_count = _get_evid_count,
|
||||
.next_evidence = _next_evidence,
|
||||
},
|
||||
.connection_id = connection_id,
|
||||
|
||||
@@ -53,19 +53,13 @@ struct imc_attestation_state_t {
|
||||
*/
|
||||
void (*add_evidence)(imc_attestation_state_t *this, pts_comp_evidence_t *entry);
|
||||
|
||||
/**
|
||||
* Get the number of entries in the Component Evidence list
|
||||
*
|
||||
* @return number of Component Evidence entries
|
||||
*/
|
||||
int (*get_evid_count)(imc_attestation_state_t *this);
|
||||
|
||||
/**
|
||||
* Removes next Component Evidence entry from list and returns it
|
||||
*
|
||||
* @return Next Component Evidence entry
|
||||
* @param evid Next Component Evidence entry
|
||||
* @return TRUE if next entry is available
|
||||
*/
|
||||
pts_comp_evidence_t* (*next_evidence)(imc_attestation_state_t *this);
|
||||
bool (*next_evidence)(imc_attestation_state_t *this, pts_comp_evidence_t** evid);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
chunk_t tpm_quote_sign;
|
||||
chunk_t evid_sign;
|
||||
bool evid_signature_included = FALSE, use_quote2 = FALSE,
|
||||
ver_info_included = FALSE;
|
||||
ver_info_included = FALSE;
|
||||
chunk_t pcr_composite, quote_info;
|
||||
|
||||
attr_cast = (tcg_pts_attr_simple_evid_final_t*)attr;
|
||||
@@ -348,11 +348,10 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check calculated PCR composite matches with received */
|
||||
if (!chunk_equals(pcr_comp, pcr_composite))
|
||||
{
|
||||
DBG1(DBG_IMV, "received PCR Compsosite didn't match"
|
||||
" with constructed");
|
||||
DBG1(DBG_IMV, "received PCR Composite didn't match "
|
||||
"with constructed");
|
||||
chunk_clear(&pcr_composite);
|
||||
chunk_clear("e_info);
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user