follow strongswan coding rules

This commit is contained in:
Sansar Choinyambuu
2011-11-28 14:39:52 +01:00
committed by Andreas Steffen
parent 954be9f5e4
commit b8017b5eba
20 changed files with 152 additions and 94 deletions
@@ -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 * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.2
*/ */
TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id, TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id,
TNC_TNCC_BindFunctionPointer bind_function) TNC_TNCC_BindFunctionPointer bind_function)
{ {
if (!imc_attestation) 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 */ /* TODO: Implement checking of components with its sub-components */
if (sub_comp_depth != 0) if (sub_comp_depth != 0)
{ {
DBG1(DBG_IMC, "current version of Attestation IMC does not support" DBG1(DBG_IMC, "current version of Attestation IMC does not "
"sub component measurement deeper than zero. " "support sub component measurement deeper than "
"Measuring top level component only."); "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) if (comp_name_vendor_id != PEN_TCG)
{ {
DBG1(DBG_IMC, "current version of Attestation IMC supports" 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)) (qualifier.type & PTS_FUNC_COMP_TYPE_ALL))
{ {
DBG2(DBG_IMC, "wildcard was set for the qualifier of functional" 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 && else if (!qualifier.kernel && !qualifier.sub_component &&
(qualifier.type & PTS_FUNC_COMP_TYPE_UNKNOWN)) (qualifier.type & PTS_FUNC_COMP_TYPE_UNKNOWN))
{ {
DBG2(DBG_IMC, "unknown was set for the qualifier of functional" 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 else
{ {
@@ -358,7 +361,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
return FALSE; 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); hasher->destroy(hasher);
return FALSE; 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); measurement_time_t = time(NULL);
if (!measurement_time_t) 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 else
{ {
time_now = localtime(&measurement_time_t); time_now = localtime(&measurement_time_t);
if (asprintf(&utc_time, "%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ", if (asprintf(&utc_time,
time_now->tm_year + 1900, "%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2dZ",
time_now->tm_mon + 1, time_now->tm_year + 1900,
time_now->tm_mday, time_now->tm_mon + 1,
time_now->tm_hour, time_now->tm_mday,
time_now->tm_min, time_now->tm_hour,
time_now->tm_sec) < 0) time_now->tm_min,
time_now->tm_sec) < 0)
{ {
DBG1(DBG_IMC, "could not format local time to UTC"); DBG1(DBG_IMC, "could not format local time to UTC");
hasher->destroy(hasher); hasher->destroy(hasher);
return FALSE; return FALSE;
} }
params.measurement_time = chunk_create(utc_time, 20); 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); 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); hasher->destroy(hasher);
params.policy_uri = chunk_empty; params.policy_uri = chunk_empty;
if (!pts->read_pcr(pts, EXTEND_PCR, &params.pcr_before)) if (!pts->read_pcr(pts, EXTEND_PCR, &params.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; return FALSE;
} }
if (!pts->extend_pcr(pts, EXTEND_PCR, if (!pts->extend_pcr(pts, EXTEND_PCR,
params.measurement, &params.pcr_after)) params.measurement, &params.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; return FALSE;
} }
@@ -457,7 +467,8 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
} }
/* Quote */ /* Quote */
if (!pts->quote_tpm(pts, pcrs, num_of_evidences, &pcr_composite, &quote_signature)) if (!pts->quote_tpm(pts, pcrs, num_of_evidences,
&pcr_composite, &quote_signature))
{ {
DBG1(DBG_IMC, "error occured during TPM quote operation"); DBG1(DBG_IMC, "error occured during TPM quote operation");
DESTROY_IF(e); DESTROY_IF(e);
@@ -162,8 +162,8 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
case TNC_CONNECTION_STATE_DELETE: case TNC_CONNECTION_STATE_DELETE:
return imv_attestation->delete_state(imv_attestation, connection_id); return imv_attestation->delete_state(imv_attestation, connection_id);
case TNC_CONNECTION_STATE_HANDSHAKE: case TNC_CONNECTION_STATE_HANDSHAKE:
result = imv_attestation->change_state(imv_attestation, connection_id, result = imv_attestation->change_state(imv_attestation,
new_state, &state); connection_id, new_state, &state);
if (result != TNC_RESULT_SUCCESS) if (result != TNC_RESULT_SUCCESS)
{ {
return result; 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); DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
return TNC_RESULT_NOT_INITIALIZED; 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 * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.2
*/ */
TNC_Result TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id, TNC_Result TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id,
TNC_TNCS_BindFunctionPointer bind_function) TNC_TNCS_BindFunctionPointer bind_function)
{ {
if (!imv_attestation) if (!imv_attestation)
{ {
@@ -142,7 +142,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
DBG1(DBG_IMV, "platform is '%s'", platform_info); DBG1(DBG_IMV, "platform is '%s'", platform_info);
/* Send Request File Metadata attribute */ /* 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) if (!enumerator)
{ {
break; break;
@@ -152,7 +153,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
is_dir = (type != 0); is_dir = (type != 0);
DBG2(DBG_IMV, "metadata request for %s '%s'", DBG2(DBG_IMV, "metadata request for %s '%s'",
is_dir ? "directory" : "file", pathname); 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); attr->set_noskip_flag(attr, TRUE);
msg->add_attribute(msg, attr); msg->add_attribute(msg, attr);
} }
@@ -197,8 +199,8 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
name = PTS_FUNC_COMP_NAME_BIOS; name = PTS_FUNC_COMP_NAME_BIOS;
/* Send Request Functional Component Evidence attribute */ /* Send Request Functional Component Evidence attribute */
attr = tcg_pts_attr_req_funct_comp_evid_create(flags, sub_comp_depth, attr = tcg_pts_attr_req_funct_comp_evid_create(flags,
PEN_TCG, qualifier, name); sub_comp_depth, PEN_TCG, qualifier, name);
attr->set_noskip_flag(attr, TRUE); attr->set_noskip_flag(attr, TRUE);
msg->add_attribute(msg, attr); msg->add_attribute(msg, attr);
/* Send Generate Attestation Evidence attribute */ /* 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); selected_algorithm = attr_cast->get_algorithms(attr_cast);
if (!(selected_algorithm & supported_algorithms)) 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; return FALSE;
} }
pts->set_meas_algorithm(pts, selected_algorithm); 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); pcr_info_inclided = attr_cast->is_pcr_info_included(attr_cast);
flags = attr_cast->get_flags(attr_cast); flags = attr_cast->get_flags(attr_cast);
depth = attr_cast->get_sub_component_depth(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) if (depth != 0)
{ {
DBG1(DBG_IMV, "Current version of Attestation IMV does not support" DBG1(DBG_IMV, "Current version of Attestation IMV does not"
"sub component measurement deeper than zero"); " 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) if (comp_vendor_id != PEN_TCG)
{ {
DBG1(DBG_IMV, "Current version of Attestation IMV supports" 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); pcr_after = attr_cast->get_pcr_after_value(attr_cast);
measurement = attr_cast->get_comp_measurement(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 was extended with %B",
DBG4(DBG_IMV,"PCR: %d before value: %B", extended_pcr, &pcr_before); extended_pcr, &measurement);
DBG4(DBG_IMV,"PCR: %d after value: %B", extended_pcr, &pcr_after); 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 = malloc_thing(pcr_entry_t);
entry->pcr_number = extended_pcr; 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 */ /* Check calculated PCR composite structure matches with received */
if (pcr_comp.ptr && !chunk_equals(pcr_comp, pcr_composite)) 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(&pcr_composite);
chunk_clear(&quote_info); chunk_clear(&quote_info);
return FALSE; return FALSE;
@@ -327,13 +333,15 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
chunk_clear(&quote_info); chunk_clear(&quote_info);
if (tpm_quote_sign.ptr && 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(&quote_digest); chunk_clear(&quote_digest);
return FALSE; return FALSE;
} }
DBG2(DBG_IMV, "signature verification succeeded for TPM Quote Info"); DBG2(DBG_IMV, "signature verification succeeded for "
"TPM Quote Info");
chunk_clear(&quote_digest); chunk_clear(&quote_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"); file_count, (file_count == 1) ? "":"s");
e = metadata->create_enumerator(metadata); 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, "File name: %s",
DBG1(DBG_IMV, " type: %d", entry->type); entry->filename);
DBG1(DBG_IMV, " size: %d", entry->filesize); DBG1(DBG_IMV, " type: %d",
DBG1(DBG_IMV, " create time: %s", ctime(&entry->create_time)); entry->type);
DBG1(DBG_IMV, " last modified: %s", ctime(&entry->last_modify_time)); DBG1(DBG_IMV, " size: %d",
DBG1(DBG_IMV, " last accessed: %s", ctime(&entry->last_access_time)); entry->filesize);
DBG1(DBG_IMV, " owner id: %d", entry->owner_id); DBG1(DBG_IMV, " create time: %s",
DBG1(DBG_IMV, " group id: %d", entry->group_id); 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); e->destroy(e);
@@ -187,14 +187,15 @@ METHOD(imv_state_t, destroy, void,
free(this); free(this);
} }
METHOD(imv_attestation_state_t, get_handshake_state, imv_attestation_handshake_state_t, METHOD(imv_attestation_state_t, get_handshake_state,
private_imv_attestation_state_t *this) imv_attestation_handshake_state_t, private_imv_attestation_state_t *this)
{ {
return this->handshake_state; return this->handshake_state;
} }
METHOD(imv_attestation_state_t, set_handshake_state, void, 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; this->handshake_state = new_state;
} }
@@ -56,7 +56,8 @@ struct imv_attestation_state_t {
* *
* @return the handshake state of IMV * @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 * Set state of the handshake
+24 -14
View File
@@ -521,7 +521,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg); hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
if (!hasher) if (!hasher)
{ {
DBG1(DBG_PTS, " hasher %N not available", hash_algorithm_names, hash_alg); DBG1(DBG_PTS, "hasher %N not available", hash_algorithm_names, hash_alg);
return NULL; return NULL;
} }
@@ -595,7 +595,8 @@ static bool file_metadata(char *pathname, pts_file_metadata_t **entry)
if (stat(pathname, &st)) if (stat(pathname, &st))
{ {
DBG1(DBG_PTS, "Unable to obtain statistical information about %s", pathname); DBG1(DBG_PTS, "Unable to obtain statistical information about %s",
pathname);
return FALSE; return FALSE;
} }
@@ -714,7 +715,8 @@ METHOD(pts_t, read_pcr, bool,
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result); DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE; return FALSE;
} }
@@ -762,7 +764,8 @@ METHOD(pts_t, extend_pcr, bool,
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result); DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE; return FALSE;
} }
result = Tspi_Context_Connect(hContext, NULL); result = Tspi_Context_Connect(hContext, NULL);
@@ -820,7 +823,8 @@ METHOD(pts_t, quote_tpm, bool,
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result); DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE; return FALSE;
} }
result = Tspi_Context_Connect(hContext, NULL); result = Tspi_Context_Connect(hContext, NULL);
@@ -834,7 +838,7 @@ METHOD(pts_t, quote_tpm, bool,
goto err1; goto err1;
} }
/* Retrieve SRK from TPM and set the authentication data as well known secret*/ /* Retrieve SRK from TPM and set the authentication to well known secret*/
result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM, result = Tspi_Context_LoadKeyByUUID(hContext, TSS_PS_TYPE_SYSTEM,
SRK_UUID, &hSRK); SRK_UUID, &hSRK);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
@@ -862,7 +866,8 @@ METHOD(pts_t, quote_tpm, bool,
} }
/* Create PCR composite object */ /* Create PCR composite object */
result = Tspi_Context_CreateObject(hContext, TSS_OBJECT_TYPE_PCRS, 0, &hPcrComposite); result = Tspi_Context_CreateObject(hContext,
TSS_OBJECT_TYPE_PCRS, 0, &hPcrComposite);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
goto err2; goto err2;
@@ -981,7 +986,7 @@ METHOD(pts_t, add_pcr_entry, void,
/** /**
* 1. build a TCPA_PCR_COMPOSITE structure which contains (pcrCompositeBuf) * 1. build a TCPA_PCR_COMPOSITE structure which contains (pcrCompositeBuf)
* TCPA_PCR_SELECTION structure (bitmask length network order + length bytes bitmask) * TCPA_PCR_SELECTION structure (bitmask length + bitmask)
* UINT32 (network order) gives the number of bytes following (pcr entries * 20) * UINT32 (network order) gives the number of bytes following (pcr entries * 20)
* TCPA_PCRVALUE[] with the pcr values * TCPA_PCRVALUE[] with the pcr values
* *
@@ -1018,7 +1023,8 @@ METHOD(pts_t, get_quote_info, bool,
if (this->pcrs->get_count(this->pcrs) == 0) if (this->pcrs->get_count(this->pcrs) == 0)
{ {
DBG1(DBG_PTS, "PCR entries unavailable, unable to construct TPM Quote Info"); DBG1(DBG_PTS, "PCR entries unavailable, unable to construct "
"TPM Quote Info");
return FALSE; return FALSE;
} }
@@ -1114,14 +1120,16 @@ METHOD(pts_t, verify_quote_signature, bool,
} }
/** Implementation using strongswan -> not working */ /** Implementation using strongswan -> not working */
/*if (!aik_pub_key->verify(aik_pub_key, SIGN_RSA_EMSA_PKCS1_SHA1, data, signature)) /**if (!aik_pub_key->verify(aik_pub_key, SIGN_RSA_EMSA_PKCS1_SHA1,
data, signature))
{ {
DBG1(DBG_PTS, "signature verification failed for TPM Quote Info"); DBG1(DBG_PTS, "signature verification failed for TPM Quote Info");
goto cleanup; goto cleanup;
} }
*/ */
if (!aik_pub_key->get_encoding(aik_pub_key, PUBKEY_SPKI_ASN1_DER, &key_encoding)) if (!aik_pub_key->get_encoding(aik_pub_key,
PUBKEY_SPKI_ASN1_DER, &key_encoding))
{ {
DBG1(DBG_PTS, "failed to get encoding of AIK public key"); DBG1(DBG_PTS, "failed to get encoding of AIK public key");
goto cleanup; goto cleanup;
@@ -1131,7 +1139,7 @@ METHOD(pts_t, verify_quote_signature, bool,
pkey = d2i_PUBKEY(NULL, (const unsigned char**)&p, key_encoding.len); pkey = d2i_PUBKEY(NULL, (const unsigned char**)&p, key_encoding.len);
if (!pkey) if (!pkey)
{ {
DBG1(DBG_PTS, "failed to get EVP_PKEY object from AIK public key encoding"); DBG1(DBG_PTS, "failed to get EVP_PKEY object from AIK public key");
goto cleanup; goto cleanup;
} }
@@ -1142,7 +1150,8 @@ METHOD(pts_t, verify_quote_signature, bool,
goto cleanup; goto cleanup;
} }
if (RSA_verify(NID_sha1, data.ptr, data.len, signature.ptr, signature.len, rsa) != 1) if (RSA_verify(NID_sha1, data.ptr, data.len,
signature.ptr, signature.len, rsa) != 1)
{ {
DBG1(DBG_PTS, "signature verification failed for TPM Quote Info"); DBG1(DBG_PTS, "signature verification failed for TPM Quote Info");
goto cleanup; goto cleanup;
@@ -1306,7 +1315,8 @@ static bool has_tpm(private_pts_t *this)
result = Tspi_Context_Create(&hContext); result = Tspi_Context_Create(&hContext);
if (result != TSS_SUCCESS) if (result != TSS_SUCCESS)
{ {
DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x", result); DBG1(DBG_PTS, "TPM context could not be created: tss error 0x%x",
result);
return FALSE; return FALSE;
} }
result = Tspi_Context_Connect(hContext, NULL); result = Tspi_Context_Connect(hContext, NULL);
+10 -7
View File
@@ -148,7 +148,7 @@ struct pts_t {
void (*set_peer_public_value) (pts_t *this, chunk_t value, chunk_t nonce); void (*set_peer_public_value) (pts_t *this, chunk_t value, chunk_t nonce);
/** /**
* Calculates secret assessment value to be used for TPM Quote as ExternalData * Calculates assessment secret to be used for TPM Quote as ExternalData
* *
* @return TRUE unless both DH public values * @return TRUE unless both DH public values
* and nonces are set * and nonces are set
@@ -205,7 +205,7 @@ struct pts_t {
* @param error_code Output variable for PTS error code * @param error_code Output variable for PTS error code
* @return TRUE if path is valid or file/directory * @return TRUE if path is valid or file/directory
* doesn't exist or path is invalid * doesn't exist or path is invalid
* FALSE if local error occured within stat function * FALSE if local error occured within stat function
*/ */
bool (*is_path_valid)(pts_t *this, char *path, pts_error_code_t *error_code); bool (*is_path_valid)(pts_t *this, char *path, pts_error_code_t *error_code);
@@ -236,7 +236,8 @@ struct pts_t {
* @param is_directory TRUE if directory contents are requested * @param is_directory TRUE if directory contents are requested
* @return PTS File Metadata or NULL if FAILED * @return PTS File Metadata or NULL if FAILED
*/ */
pts_file_meta_t* (*get_metadata)(pts_t *this, char *pathname, bool is_directory); pts_file_meta_t* (*get_metadata)(pts_t *this, char *pathname,
bool is_directory);
/** /**
* Reads given PCR value and returns it * Reads given PCR value and returns it
@@ -257,7 +258,8 @@ struct pts_t {
* @param output Chunk to save PCR value after extension * @param output Chunk to save PCR value after extension
* @return FALSE in case of TSS error, TRUE otherwise * @return FALSE in case of TSS error, TRUE otherwise
*/ */
bool (*extend_pcr)(pts_t *this, u_int32_t pcr_num, chunk_t input, chunk_t *output); bool (*extend_pcr)(pts_t *this, u_int32_t pcr_num, chunk_t input,
chunk_t *output);
/** /**
* Quote over PCR's * Quote over PCR's
@@ -276,7 +278,7 @@ struct pts_t {
/** /**
* Add extended PCR with its corresponding value * Add extended PCR with its corresponding value
* *
* @return FALSE in case of any error or non-match, TRUE otherwise * @return FALSE in case of any error or non-match, TRUE otherwise
*/ */
void (*add_pcr_entry)(pts_t *this, pcr_entry_t *entry); void (*add_pcr_entry)(pts_t *this, pcr_entry_t *entry);
@@ -287,14 +289,15 @@ struct pts_t {
* @param quote_info Output variable to store TPM Quote Info * @param quote_info Output variable to store TPM Quote Info
* @return FALSE in case of any error, TRUE otherwise * @return FALSE in case of any error, TRUE otherwise
*/ */
bool (*get_quote_info)(pts_t *this, chunk_t *pcr_composite, chunk_t *quote_info); bool (*get_quote_info)(pts_t *this, chunk_t *pcr_composite,
chunk_t *quote_info);
/** /**
* Constructs and returns PCR Quote Digest structure expected from IMC * Constructs and returns PCR Quote Digest structure expected from IMC
* *
* @param data Calculated TPM Quote Digest * @param data Calculated TPM Quote Digest
* @param signature TPM Quote Signature received from IMC * @param signature TPM Quote Signature received from IMC
* @return FALSE in case signature is not verified, TRUE otherwise * @return FALSE in case signature is not verified, TRUE otherwise
*/ */
bool (*verify_quote_signature)(pts_t *this, chunk_t data, chunk_t signature); bool (*verify_quote_signature)(pts_t *this, chunk_t data, chunk_t signature);
+4 -2
View File
@@ -38,7 +38,8 @@ struct pts_database_t {
* @param product software product (os, vpn client, etc.) * @param product software product (os, vpn client, etc.)
* @return enumerator over all matching files/directories * @return enumerator over all matching files/directories
*/ */
enumerator_t* (*create_file_enumerator)(pts_database_t *this, char *product); enumerator_t* (*create_file_enumerator)(pts_database_t *this,
char *product);
/** /**
* Get files/directories to request metadata of * Get files/directories to request metadata of
@@ -46,7 +47,8 @@ struct pts_database_t {
* @param product software product (os, vpn client, etc.) * @param product software product (os, vpn client, etc.)
* @return enumerator over all matching files/directories * @return enumerator over all matching files/directories
*/ */
enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this, char *product); enumerator_t* (*create_file_meta_enumerator)(pts_database_t *this,
char *product);
/** /**
* Get stored measurement hash for single file or directory entries * Get stored measurement hash for single file or directory entries
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h> #include <bio/bio_reader.h>
#include <debug.h> #include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_finish_t private_tcg_pts_attr_dh_nonce_finish_t; typedef struct private_tcg_pts_attr_dh_nonce_finish_t
private_tcg_pts_attr_dh_nonce_finish_t;
/** /**
* PTS DH Nonce Finish * PTS DH Nonce Finish
@@ -191,9 +192,10 @@ METHOD(tcg_pts_attr_dh_nonce_finish_t, get_initiator_nonce, chunk_t,
/** /**
* Described in header. * Described in header.
*/ */
pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(pts_meas_algorithms_t hash_algo, pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(
chunk_t initiator_value, pts_meas_algorithms_t hash_algo,
chunk_t initiator_nonce) chunk_t initiator_value,
chunk_t initiator_nonce)
{ {
private_tcg_pts_attr_dh_nonce_finish_t *this; private_tcg_pts_attr_dh_nonce_finish_t *this;
@@ -74,9 +74,10 @@ struct tcg_pts_attr_dh_nonce_finish_t {
* @param initiator_value DH Initiator Public Value * @param initiator_value DH Initiator Public Value
* @param initiator_nonce DH Initiator Nonce * @param initiator_nonce DH Initiator Nonce
*/ */
pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(pts_meas_algorithms_t hash_algo, pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(
chunk_t initiator_value, pts_meas_algorithms_t hash_algo,
chunk_t initiator_nonce); chunk_t initiator_value,
chunk_t initiator_nonce);
/** /**
* Creates an tcg_pts_attr_dh_nonce_finish_t object from received data * Creates an tcg_pts_attr_dh_nonce_finish_t object from received data
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h> #include <bio/bio_reader.h>
#include <debug.h> #include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_params_req_t private_tcg_pts_attr_dh_nonce_params_req_t; typedef struct private_tcg_pts_attr_dh_nonce_params_req_t
private_tcg_pts_attr_dh_nonce_params_req_t;
/** /**
* PTS DH Nonce Parameters Request * PTS DH Nonce Parameters Request
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_ #ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
#define TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_ #define TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_
typedef struct tcg_pts_attr_dh_nonce_params_req_t tcg_pts_attr_dh_nonce_params_req_t; typedef struct tcg_pts_attr_dh_nonce_params_req_t
tcg_pts_attr_dh_nonce_params_req_t;
#include "tcg_attr.h" #include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h" #include "pa_tnc/pa_tnc_attr.h"
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h> #include <bio/bio_reader.h>
#include <debug.h> #include <debug.h>
typedef struct private_tcg_pts_attr_dh_nonce_params_resp_t private_tcg_pts_attr_dh_nonce_params_resp_t; typedef struct private_tcg_pts_attr_dh_nonce_params_resp_t
private_tcg_pts_attr_dh_nonce_params_resp_t;
/** /**
* PTS DH Nonce Parameters Response * PTS DH Nonce Parameters Response
@@ -187,8 +188,8 @@ METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_dh_group, pts_dh_group_t,
return this->dh_group; return this->dh_group;
} }
METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_hash_algo_set, pts_meas_algorithms_t, METHOD(tcg_pts_attr_dh_nonce_params_resp_t, get_hash_algo_set,
private_tcg_pts_attr_dh_nonce_params_resp_t *this) pts_meas_algorithms_t, private_tcg_pts_attr_dh_nonce_params_resp_t *this)
{ {
return this->hash_algo_set; return this->hash_algo_set;
} }
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_ #ifndef TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
#define TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_ #define TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_
typedef struct tcg_pts_attr_dh_nonce_params_resp_t tcg_pts_attr_dh_nonce_params_resp_t; typedef struct tcg_pts_attr_dh_nonce_params_resp_t
tcg_pts_attr_dh_nonce_params_resp_t;
#include "tcg_attr.h" #include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h" #include "pa_tnc/pa_tnc_attr.h"
@@ -50,7 +51,8 @@ struct tcg_pts_attr_dh_nonce_params_resp_t {
* *
* @return Hash algorithm set * @return Hash algorithm set
*/ */
pts_meas_algorithms_t (*get_hash_algo_set)(tcg_pts_attr_dh_nonce_params_resp_t *this); pts_meas_algorithms_t (*get_hash_algo_set)(
tcg_pts_attr_dh_nonce_params_resp_t *this);
/** /**
* Get DH Responder Nonce * Get DH Responder Nonce
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h> #include <bio/bio_reader.h>
#include <debug.h> #include <debug.h>
typedef struct private_tcg_pts_attr_gen_attest_evid_t private_tcg_pts_attr_gen_attest_evid_t; typedef struct private_tcg_pts_attr_gen_attest_evid_t
private_tcg_pts_attr_gen_attest_evid_t;
/** /**
* Generate Attestation Evidence * Generate Attestation Evidence
@@ -20,7 +20,8 @@
#include <bio/bio_reader.h> #include <bio/bio_reader.h>
#include <debug.h> #include <debug.h>
typedef struct private_tcg_pts_attr_get_tpm_version_info_t private_tcg_pts_attr_get_tpm_version_info_t; typedef struct private_tcg_pts_attr_get_tpm_version_info_t
private_tcg_pts_attr_get_tpm_version_info_t;
/** /**
* Get TPM Version Information * Get TPM Version Information
@@ -21,7 +21,8 @@
#ifndef TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_ #ifndef TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
#define TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_ #define TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_
typedef struct tcg_pts_attr_get_tpm_version_info_t tcg_pts_attr_get_tpm_version_info_t; typedef struct tcg_pts_attr_get_tpm_version_info_t
tcg_pts_attr_get_tpm_version_info_t;
#include "tcg_attr.h" #include "tcg_attr.h"
#include "pa_tnc/pa_tnc_attr.h" #include "pa_tnc/pa_tnc_attr.h"
@@ -197,7 +197,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
bio_reader_t *reader; bio_reader_t *reader;
u_int8_t flags; u_int8_t flags;
u_int8_t reserved; u_int8_t reserved;
//u_int16_t algorithm; /** u_int16_t algorithm;*/
if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE) if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE)
{ {