Started implementing handling of DH Nonce attributes
This commit is contained in:
committed by
Andreas Steffen
parent
9a49d2e065
commit
0daee96b05
@@ -63,6 +63,11 @@ static imc_agent_t *imc_attestation;
|
||||
*/
|
||||
static pts_meas_algorithms_t supported_algorithms = 0;
|
||||
|
||||
/**
|
||||
* Supported PTS Diffie Hellman Groups
|
||||
*/
|
||||
static pts_dh_group_t supported_dh_groups = 0;
|
||||
|
||||
/**
|
||||
* see section 3.7.1 of TCG TNC IF-IMC Specification 1.2
|
||||
*/
|
||||
@@ -80,6 +85,10 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
if (!pts_probe_dh_groups(&supported_dh_groups))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
|
||||
imc_id, actual_version);
|
||||
if (!imc_attestation)
|
||||
@@ -276,27 +285,82 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
break;
|
||||
}
|
||||
case TCG_PTS_DH_NONCE_PARAMS_REQ:
|
||||
{
|
||||
tcg_pts_attr_dh_nonce_params_req_t *attr_cast;
|
||||
u_int8_t min_nonce_len;
|
||||
pts_dh_group_t offered_dh_groups, selected_dh_group;
|
||||
|
||||
attr_cast = (tcg_pts_attr_dh_nonce_params_req_t*)attr;
|
||||
min_nonce_len = attr_cast->get_min_nonce_len(attr_cast);
|
||||
offered_dh_groups = attr_cast->get_dh_groups(attr_cast);
|
||||
|
||||
if ((supported_dh_groups & PTS_DH_GROUP_IKE20) &&
|
||||
(offered_dh_groups & PTS_DH_GROUP_IKE20))
|
||||
{
|
||||
pts->set_dh_group(pts, PTS_DH_GROUP_IKE20);
|
||||
}
|
||||
else if ((supported_dh_groups & PTS_DH_GROUP_IKE19) &&
|
||||
(offered_dh_groups & PTS_DH_GROUP_IKE19))
|
||||
{
|
||||
pts->set_dh_group(pts, PTS_DH_GROUP_IKE19);
|
||||
}
|
||||
else if ((supported_dh_groups & PTS_DH_GROUP_IKE14) &&
|
||||
(offered_dh_groups & PTS_DH_GROUP_IKE14))
|
||||
{
|
||||
pts->set_dh_group(pts, PTS_DH_GROUP_IKE14);
|
||||
}
|
||||
else if ((supported_dh_groups & PTS_DH_GROUP_IKE5) &&
|
||||
(offered_dh_groups & PTS_DH_GROUP_IKE5))
|
||||
{
|
||||
pts->set_dh_group(pts, PTS_DH_GROUP_IKE5);
|
||||
}
|
||||
else if ((supported_dh_groups & PTS_DH_GROUP_IKE2) &&
|
||||
(offered_dh_groups & PTS_DH_GROUP_IKE2))
|
||||
{
|
||||
pts->set_dh_group(pts, PTS_DH_GROUP_IKE2);
|
||||
}
|
||||
else
|
||||
{
|
||||
attr_info = attr->get_value(attr);
|
||||
attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
|
||||
TCG_PTS_DH_GRPS_NOT_SUPPORTED, attr_info);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Send DH Nonce Parameters Response attribute */
|
||||
selected_dh_group = pts->get_dh_group(pts);
|
||||
/* TODO: Implement */
|
||||
|
||||
break;
|
||||
}
|
||||
case TCG_PTS_DH_NONCE_FINISH:
|
||||
{
|
||||
/* TODO: Implement */
|
||||
break;
|
||||
}
|
||||
case TCG_PTS_MEAS_ALGO:
|
||||
{
|
||||
tcg_pts_attr_meas_algo_t *attr_cast;
|
||||
pts_meas_algorithms_t selected_algorithm;
|
||||
|
||||
pts_meas_algorithms_t offered_algorithms, selected_algorithm;
|
||||
|
||||
attr_cast = (tcg_pts_attr_meas_algo_t*)attr;
|
||||
selected_algorithm = attr_cast->get_algorithms(attr_cast);
|
||||
offered_algorithms = attr_cast->get_algorithms(attr_cast);
|
||||
|
||||
if ((supported_algorithms & PTS_MEAS_ALGO_SHA384) &&
|
||||
(selected_algorithm & PTS_MEAS_ALGO_SHA384))
|
||||
(offered_algorithms & PTS_MEAS_ALGO_SHA384))
|
||||
{
|
||||
pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA384);
|
||||
}
|
||||
else if ((supported_algorithms & PTS_MEAS_ALGO_SHA256) &&
|
||||
(selected_algorithm & PTS_MEAS_ALGO_SHA256))
|
||||
(offered_algorithms & PTS_MEAS_ALGO_SHA256))
|
||||
{
|
||||
pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA256);
|
||||
}
|
||||
|
||||
else if ((supported_algorithms & PTS_MEAS_ALGO_SHA1) &&
|
||||
(selected_algorithm & PTS_MEAS_ALGO_SHA1))
|
||||
(offered_algorithms & PTS_MEAS_ALGO_SHA1))
|
||||
{
|
||||
pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA1);
|
||||
}
|
||||
@@ -587,8 +651,6 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
|
||||
break;
|
||||
}
|
||||
/* TODO: Not implemented yet */
|
||||
case TCG_PTS_DH_NONCE_PARAMS_REQ:
|
||||
case TCG_PTS_DH_NONCE_FINISH:
|
||||
case TCG_PTS_REQ_INTEG_MEAS_LOG:
|
||||
/* Attributes using XML */
|
||||
case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <pen/pen.h>
|
||||
#include <debug.h>
|
||||
#include <credentials/credential_manager.h>
|
||||
#include <utils/linked_list.h>
|
||||
|
||||
/* IMV definitions */
|
||||
|
||||
@@ -66,6 +67,11 @@ static imv_agent_t *imv_attestation;
|
||||
*/
|
||||
static pts_meas_algorithms_t supported_algorithms = 0;
|
||||
|
||||
/**
|
||||
* Supported PTS Diffie Hellman Groups
|
||||
*/
|
||||
static pts_dh_group_t supported_dh_groups = 0;
|
||||
|
||||
/**
|
||||
* PTS file measurement database
|
||||
*/
|
||||
@@ -89,7 +95,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
|
||||
TNC_Version max_version,
|
||||
TNC_Version *actual_version)
|
||||
{
|
||||
char *hash_alg, *uri, *cadir;
|
||||
char *hash_alg, *dh_group, *uri, *cadir;
|
||||
|
||||
if (imv_attestation)
|
||||
{
|
||||
@@ -100,6 +106,10 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
if (!pts_probe_dh_groups(&supported_dh_groups))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
imv_attestation = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
|
||||
imv_id, actual_version);
|
||||
if (!imv_attestation)
|
||||
@@ -137,6 +147,24 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
|
||||
supported_algorithms &= ~PTS_MEAS_ALGO_SHA256;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify supported PTS Diffie Hellman Groups
|
||||
*
|
||||
* ike2: PTS_DH_GROUP_IKE2
|
||||
* ike5: PTS_DH_GROUP_IKE2 | PTS_DH_GROUP_IKE5
|
||||
* ike14: PTS_DH_GROUP_IKE2 | PTS_DH_GROUP_IKE5 | PTS_DH_GROUP_IKE14
|
||||
* ike19: PTS_DH_GROUP_IKE2 | PTS_DH_GROUP_IKE5 | PTS_DH_GROUP_IKE14 | PTS_DH_GROUP_IKE19
|
||||
* ike20: PTS_DH_GROUP_IKE2 | PTS_DH_GROUP_IKE5 | PTS_DH_GROUP_IKE14 | PTS_DH_GROUP_IKE19 | PTS_DH_GROUP_IKE20
|
||||
*
|
||||
* we expect the PTS-IMC to select the strongest supported group
|
||||
*/
|
||||
dh_group = lib->settings->get_str(lib->settings,
|
||||
"libimcv.plugins.imv-attestation.dh_group", "ike19");
|
||||
if (!pts_update_supported_dh_groups(dh_group, &supported_dh_groups))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
/* create a PTS credential manager */
|
||||
pts_credmgr = credential_manager_create();
|
||||
|
||||
@@ -238,9 +266,37 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
||||
msg->add_attribute(msg, attr);
|
||||
|
||||
attestation_state->set_handshake_state(attestation_state,
|
||||
IMV_ATTESTATION_STATE_MEAS);
|
||||
IMV_ATTESTATION_STATE_DH_NONCE);
|
||||
break;
|
||||
}
|
||||
case IMV_ATTESTATION_STATE_DH_NONCE:
|
||||
{
|
||||
bool request_sent = FALSE;
|
||||
|
||||
/* Jump to Measurement state if IMC has no TPM */
|
||||
if(!(pts->get_proto_caps(pts) & PTS_PROTO_CAPS_T))
|
||||
{
|
||||
attestation_state->set_handshake_state(attestation_state,
|
||||
IMV_ATTESTATION_STATE_MEAS);
|
||||
}
|
||||
else if (!request_sent)
|
||||
{
|
||||
/* Send DH nonce parameters request attribute */
|
||||
attr = tcg_pts_attr_dh_nonce_params_req_create(0, supported_dh_groups);
|
||||
attr->set_noskip_flag(attr, TRUE);
|
||||
msg->add_attribute(msg, attr);
|
||||
request_sent = TRUE;
|
||||
}
|
||||
else if (request_sent)
|
||||
{
|
||||
/* Send DH nonce finish attribute */
|
||||
attestation_state->set_handshake_state(attestation_state,
|
||||
IMV_ATTESTATION_STATE_MEAS);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case IMV_ATTESTATION_STATE_MEAS:
|
||||
{
|
||||
@@ -255,7 +311,6 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
||||
IMV_ATTESTATION_STATE_COMP_EVID);
|
||||
|
||||
/* Does the PTS-IMC have TPM support? */
|
||||
if (pts->get_proto_caps(pts) & PTS_PROTO_CAPS_T)
|
||||
{
|
||||
/* Send Get TPM Version attribute */
|
||||
attr = tcg_pts_attr_get_tpm_version_info_create();
|
||||
@@ -336,10 +391,6 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
|
||||
|
||||
break;
|
||||
}
|
||||
case IMV_ATTESTATION_STATE_IML:
|
||||
DBG1(DBG_IMV, "Attestation IMV has nothing to send: \"%s\"",
|
||||
handshake_state);
|
||||
return TNC_RESULT_FATAL;
|
||||
default:
|
||||
DBG1(DBG_IMV, "Attestation IMV is in unknown state: \"%s\"",
|
||||
handshake_state);
|
||||
@@ -471,6 +522,11 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
||||
pts->set_proto_caps(pts, flags);
|
||||
break;
|
||||
}
|
||||
case TCG_PTS_DH_NONCE_PARAMS_RESP:
|
||||
{
|
||||
/* TODO: Implement */
|
||||
break;
|
||||
}
|
||||
case TCG_PTS_MEAS_ALGO_SELECTION:
|
||||
{
|
||||
tcg_pts_attr_meas_algo_t *attr_cast;
|
||||
@@ -620,7 +676,6 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
||||
}
|
||||
|
||||
/* TODO: Not implemented yet */
|
||||
case TCG_PTS_DH_NONCE_PARAMS_RESP:
|
||||
case TCG_PTS_INTEG_MEAS_LOG:
|
||||
/* Attributes using XML */
|
||||
case TCG_PTS_TEMPL_REF_MANI_SET_META:
|
||||
|
||||
@@ -34,9 +34,9 @@ typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t
|
||||
*/
|
||||
enum imv_attestation_handshake_state_t {
|
||||
IMV_ATTESTATION_STATE_INIT,
|
||||
IMV_ATTESTATION_STATE_DH_NONCE,
|
||||
IMV_ATTESTATION_STATE_MEAS,
|
||||
IMV_ATTESTATION_STATE_COMP_EVID,
|
||||
IMV_ATTESTATION_STATE_IML,
|
||||
IMV_ATTESTATION_STATE_END,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user