follow strongswan coding rules
This commit is contained in:
committed by
Andreas Steffen
parent
954be9f5e4
commit
b8017b5eba
@@ -323,7 +323,7 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id)
|
||||
* see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.2
|
||||
*/
|
||||
TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id,
|
||||
TNC_TNCC_BindFunctionPointer bind_function)
|
||||
TNC_TNCC_BindFunctionPointer bind_function)
|
||||
{
|
||||
if (!imc_attestation)
|
||||
{
|
||||
|
||||
@@ -262,12 +262,13 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
/* TODO: Implement checking of components with its sub-components */
|
||||
if (sub_comp_depth != 0)
|
||||
{
|
||||
DBG1(DBG_IMC, "current version of Attestation IMC does not support"
|
||||
"sub component measurement deeper than zero. "
|
||||
"Measuring top level component only.");
|
||||
DBG1(DBG_IMC, "current version of Attestation IMC does not "
|
||||
"support sub component measurement deeper than "
|
||||
"zero. Measuring top level component only.");
|
||||
}
|
||||
|
||||
comp_name_vendor_id = attr_cast->get_comp_funct_name_vendor_id(attr_cast);
|
||||
comp_name_vendor_id = attr_cast->get_comp_funct_name_vendor_id(
|
||||
attr_cast);
|
||||
if (comp_name_vendor_id != PEN_TCG)
|
||||
{
|
||||
DBG1(DBG_IMC, "current version of Attestation IMC supports"
|
||||
@@ -291,13 +292,15 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
(qualifier.type & PTS_FUNC_COMP_TYPE_ALL))
|
||||
{
|
||||
DBG2(DBG_IMC, "wildcard was set for the qualifier of functional"
|
||||
" component. Identifying the component with name binary enumeration");
|
||||
" component. Identifying the component with "
|
||||
"name binary enumeration");
|
||||
}
|
||||
else if (!qualifier.kernel && !qualifier.sub_component &&
|
||||
(qualifier.type & PTS_FUNC_COMP_TYPE_UNKNOWN))
|
||||
{
|
||||
DBG2(DBG_IMC, "unknown was set for the qualifier of functional"
|
||||
" component. Identifying the component with name binary enumeration");
|
||||
" component. Identifying the component with "
|
||||
"name binary enumeration");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -358,7 +361,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pts->hash_file(pts, hasher, "/etc/tnc_config", hash_output))
|
||||
if (!pts->hash_file(pts, hasher, "/etc/tnc_config",
|
||||
hash_output))
|
||||
{
|
||||
hasher->destroy(hasher);
|
||||
return FALSE;
|
||||
@@ -367,43 +371,49 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
measurement_time_t = time(NULL);
|
||||
if (!measurement_time_t)
|
||||
{
|
||||
params.measurement_time = chunk_create("0000-00-00T00:00:00Z", 20);
|
||||
params.measurement_time = chunk_create(
|
||||
"0000-00-00T00:00:00Z", 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
time_now = localtime(&measurement_time_t);
|
||||
if (asprintf(&utc_time, "%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ",
|
||||
time_now->tm_year + 1900,
|
||||
time_now->tm_mon + 1,
|
||||
time_now->tm_mday,
|
||||
time_now->tm_hour,
|
||||
time_now->tm_min,
|
||||
time_now->tm_sec) < 0)
|
||||
if (asprintf(&utc_time,
|
||||
"%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ",
|
||||
time_now->tm_year + 1900,
|
||||
time_now->tm_mon + 1,
|
||||
time_now->tm_mday,
|
||||
time_now->tm_hour,
|
||||
time_now->tm_min,
|
||||
time_now->tm_sec) < 0)
|
||||
{
|
||||
DBG1(DBG_IMC, "could not format local time to UTC");
|
||||
hasher->destroy(hasher);
|
||||
return FALSE;
|
||||
}
|
||||
params.measurement_time = chunk_create(utc_time, 20);
|
||||
params.measurement_time = chunk_clone(params.measurement_time);
|
||||
params.measurement_time = chunk_clone(
|
||||
params.measurement_time);
|
||||
free(utc_time);
|
||||
|
||||
}
|
||||
|
||||
params.measurement = chunk_create(hash_output, hasher->get_hash_size(hasher));
|
||||
params.measurement = chunk_create(hash_output,
|
||||
hasher->get_hash_size(hasher));
|
||||
hasher->destroy(hasher);
|
||||
|
||||
params.policy_uri = chunk_empty;
|
||||
if (!pts->read_pcr(pts, EXTEND_PCR, ¶ms.pcr_before))
|
||||
{
|
||||
DBG1(DBG_IMC, "error occured while reading PCR: %d", EXTEND_PCR);
|
||||
DBG1(DBG_IMC, "error occured while reading PCR: %d",
|
||||
EXTEND_PCR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pts->extend_pcr(pts, EXTEND_PCR,
|
||||
params.measurement, ¶ms.pcr_after))
|
||||
{
|
||||
DBG1(DBG_IMC, "error occured while extending PCR: %d", EXTEND_PCR);
|
||||
DBG1(DBG_IMC, "error occured while extending PCR: %d",
|
||||
EXTEND_PCR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -457,7 +467,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
}
|
||||
|
||||
/* Quote */
|
||||
if (!pts->quote_tpm(pts, pcrs, num_of_evidences, &pcr_composite, "e_signature))
|
||||
if (!pts->quote_tpm(pts, pcrs, num_of_evidences,
|
||||
&pcr_composite, "e_signature))
|
||||
{
|
||||
DBG1(DBG_IMC, "error occured during TPM quote operation");
|
||||
DESTROY_IF(e);
|
||||
|
||||
@@ -162,8 +162,8 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
|
||||
case TNC_CONNECTION_STATE_DELETE:
|
||||
return imv_attestation->delete_state(imv_attestation, connection_id);
|
||||
case TNC_CONNECTION_STATE_HANDSHAKE:
|
||||
result = imv_attestation->change_state(imv_attestation, connection_id,
|
||||
new_state, &state);
|
||||
result = imv_attestation->change_state(imv_attestation,
|
||||
connection_id, new_state, &state);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
@@ -396,7 +396,8 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
|
||||
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
return imv_attestation->provide_recommendation(imv_attestation, connection_id);
|
||||
return imv_attestation->provide_recommendation(imv_attestation,
|
||||
connection_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,7 +460,7 @@ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id)
|
||||
* see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.2
|
||||
*/
|
||||
TNC_Result TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id,
|
||||
TNC_TNCS_BindFunctionPointer bind_function)
|
||||
TNC_TNCS_BindFunctionPointer bind_function)
|
||||
{
|
||||
if (!imv_attestation)
|
||||
{
|
||||
|
||||
@@ -142,7 +142,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
|
||||
DBG1(DBG_IMV, "platform is '%s'", platform_info);
|
||||
|
||||
/* Send Request File Metadata attribute */
|
||||
enumerator = pts_db->create_file_meta_enumerator(pts_db, platform_info);
|
||||
enumerator = pts_db->create_file_meta_enumerator(pts_db,
|
||||
platform_info);
|
||||
if (!enumerator)
|
||||
{
|
||||
break;
|
||||
@@ -152,7 +153,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
|
||||
is_dir = (type != 0);
|
||||
DBG2(DBG_IMV, "metadata request for %s '%s'",
|
||||
is_dir ? "directory" : "file", pathname);
|
||||
attr = tcg_pts_attr_req_file_meta_create(is_dir, delimiter, pathname);
|
||||
attr = tcg_pts_attr_req_file_meta_create(is_dir, delimiter,
|
||||
pathname);
|
||||
attr->set_noskip_flag(attr, TRUE);
|
||||
msg->add_attribute(msg, attr);
|
||||
}
|
||||
@@ -197,8 +199,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
|
||||
name = PTS_FUNC_COMP_NAME_BIOS;
|
||||
|
||||
/* Send Request Functional Component Evidence attribute */
|
||||
attr = tcg_pts_attr_req_funct_comp_evid_create(flags, sub_comp_depth,
|
||||
PEN_TCG, qualifier, name);
|
||||
attr = tcg_pts_attr_req_funct_comp_evid_create(flags,
|
||||
sub_comp_depth, PEN_TCG, qualifier, name);
|
||||
attr->set_noskip_flag(attr, TRUE);
|
||||
msg->add_attribute(msg, attr);
|
||||
/* Send Generate Attestation Evidence attribute */
|
||||
|
||||
@@ -65,7 +65,8 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
selected_algorithm = attr_cast->get_algorithms(attr_cast);
|
||||
if (!(selected_algorithm & supported_algorithms))
|
||||
{
|
||||
DBG1(DBG_IMV, "PTS-IMC selected unsupported measurement algorithm");
|
||||
DBG1(DBG_IMV, "PTS-IMC selected unsupported"
|
||||
" measurement algorithm");
|
||||
return FALSE;
|
||||
}
|
||||
pts->set_meas_algorithm(pts, selected_algorithm);
|
||||
@@ -194,13 +195,14 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
pcr_info_inclided = attr_cast->is_pcr_info_included(attr_cast);
|
||||
flags = attr_cast->get_flags(attr_cast);
|
||||
depth = attr_cast->get_sub_component_depth(attr_cast);
|
||||
/* TODO: Implement checking of components with its sub-components */
|
||||
/* TODO: Implement check of components with its sub-components */
|
||||
if (depth != 0)
|
||||
{
|
||||
DBG1(DBG_IMV, "Current version of Attestation IMV does not support"
|
||||
"sub component measurement deeper than zero");
|
||||
DBG1(DBG_IMV, "Current version of Attestation IMV does not"
|
||||
" support sub component measurement deeper than zero");
|
||||
}
|
||||
comp_vendor_id = attr_cast->get_spec_comp_funct_name_vendor_id(attr_cast);
|
||||
comp_vendor_id = attr_cast->get_spec_comp_funct_name_vendor_id(
|
||||
attr_cast);
|
||||
if (comp_vendor_id != PEN_TCG)
|
||||
{
|
||||
DBG1(DBG_IMV, "Current version of Attestation IMV supports"
|
||||
@@ -253,9 +255,12 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
pcr_after = attr_cast->get_pcr_after_value(attr_cast);
|
||||
measurement = attr_cast->get_comp_measurement(attr_cast);
|
||||
|
||||
DBG4(DBG_IMV,"PCR: %d was extended with %B", extended_pcr, &measurement);
|
||||
DBG4(DBG_IMV,"PCR: %d before value: %B", extended_pcr, &pcr_before);
|
||||
DBG4(DBG_IMV,"PCR: %d after value: %B", extended_pcr, &pcr_after);
|
||||
DBG4(DBG_IMV,"PCR: %d was extended with %B",
|
||||
extended_pcr, &measurement);
|
||||
DBG4(DBG_IMV,"PCR: %d before value: %B",
|
||||
extended_pcr, &pcr_before);
|
||||
DBG4(DBG_IMV,"PCR: %d after value: %B",
|
||||
extended_pcr, &pcr_after);
|
||||
|
||||
entry = malloc_thing(pcr_entry_t);
|
||||
entry->pcr_number = extended_pcr;
|
||||
@@ -312,7 +317,8 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
/* Check calculated PCR composite structure matches with received */
|
||||
if (pcr_comp.ptr && !chunk_equals(pcr_comp, pcr_composite))
|
||||
{
|
||||
DBG1(DBG_IMV, "received PCR Compsosite didn't match with constructed");
|
||||
DBG1(DBG_IMV, "received PCR Compsosite didn't match"
|
||||
" with constructed");
|
||||
chunk_clear(&pcr_composite);
|
||||
chunk_clear("e_info);
|
||||
return FALSE;
|
||||
@@ -327,13 +333,15 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
chunk_clear("e_info);
|
||||
|
||||
if (tpm_quote_sign.ptr &&
|
||||
!pts->verify_quote_signature(pts, quote_digest, tpm_quote_sign))
|
||||
!pts->verify_quote_signature(pts, quote_digest,
|
||||
tpm_quote_sign))
|
||||
{
|
||||
chunk_clear("e_digest);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DBG2(DBG_IMV, "signature verification succeeded for TPM Quote Info");
|
||||
DBG2(DBG_IMV, "signature verification succeeded for "
|
||||
"TPM Quote Info");
|
||||
chunk_clear("e_digest);
|
||||
}
|
||||
|
||||
@@ -406,16 +414,24 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
|
||||
file_count, (file_count == 1) ? "":"s");
|
||||
|
||||
e = metadata->create_enumerator(metadata);
|
||||
while(e->enumerate(e, &entry))
|
||||
while (e->enumerate(e, &entry))
|
||||
{
|
||||
DBG1(DBG_IMV, "File name: %s", entry->filename);
|
||||
DBG1(DBG_IMV, " type: %d", entry->type);
|
||||
DBG1(DBG_IMV, " size: %d", entry->filesize);
|
||||
DBG1(DBG_IMV, " create time: %s", ctime(&entry->create_time));
|
||||
DBG1(DBG_IMV, " last modified: %s", ctime(&entry->last_modify_time));
|
||||
DBG1(DBG_IMV, " last accessed: %s", ctime(&entry->last_access_time));
|
||||
DBG1(DBG_IMV, " owner id: %d", entry->owner_id);
|
||||
DBG1(DBG_IMV, " group id: %d", entry->group_id);
|
||||
DBG1(DBG_IMV, "File name: %s",
|
||||
entry->filename);
|
||||
DBG1(DBG_IMV, " type: %d",
|
||||
entry->type);
|
||||
DBG1(DBG_IMV, " size: %d",
|
||||
entry->filesize);
|
||||
DBG1(DBG_IMV, " create time: %s",
|
||||
ctime(&entry->create_time));
|
||||
DBG1(DBG_IMV, " last modified: %s",
|
||||
ctime(&entry->last_modify_time));
|
||||
DBG1(DBG_IMV, " last accessed: %s",
|
||||
ctime(&entry->last_access_time));
|
||||
DBG1(DBG_IMV, " owner id: %d",
|
||||
entry->owner_id);
|
||||
DBG1(DBG_IMV, " group id: %d",
|
||||
entry->group_id);
|
||||
}
|
||||
e->destroy(e);
|
||||
|
||||
|
||||
@@ -187,14 +187,15 @@ METHOD(imv_state_t, destroy, void,
|
||||
free(this);
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, get_handshake_state, imv_attestation_handshake_state_t,
|
||||
private_imv_attestation_state_t *this)
|
||||
METHOD(imv_attestation_state_t, get_handshake_state,
|
||||
imv_attestation_handshake_state_t, private_imv_attestation_state_t *this)
|
||||
{
|
||||
return this->handshake_state;
|
||||
}
|
||||
|
||||
METHOD(imv_attestation_state_t, set_handshake_state, void,
|
||||
private_imv_attestation_state_t *this, imv_attestation_handshake_state_t new_state)
|
||||
private_imv_attestation_state_t *this,
|
||||
imv_attestation_handshake_state_t new_state)
|
||||
{
|
||||
this->handshake_state = new_state;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ struct imv_attestation_state_t {
|
||||
*
|
||||
* @return the handshake state of IMV
|
||||
*/
|
||||
imv_attestation_handshake_state_t (*get_handshake_state)(imv_attestation_state_t *this);
|
||||
imv_attestation_handshake_state_t (*get_handshake_state)(
|
||||
imv_attestation_state_t *this);
|
||||
|
||||
/**
|
||||
* Set state of the handshake
|
||||
|
||||
Reference in New Issue
Block a user