Read AIK certificate/ AIK public key from file

This commit is contained in:
Sansar Choinyambuu
2011-09-08 12:08:16 +02:00
committed by Andreas Steffen
parent 05a1b347b2
commit 9816a29822
4 changed files with 101 additions and 376 deletions
@@ -288,17 +288,30 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
case TCG_PTS_GET_AIK:
{
chunk_t aik;
certificate_t *aik_cert;
public_key_t *aik_key;
bool is_naked_key;
if (!pts->get_aik(pts, &aik, &is_naked_key))
if (!pts->get_aik(pts, &aik_cert, &aik_key, &is_naked_key))
{
DBG1(DBG_IMC, "Obtaining AIK Certificate failed");
break;
}
/* Send AIK attribute */
attr = tcg_pts_attr_aik_create(is_naked_key, aik);
if(!is_naked_key && aik_cert)
{
attr = tcg_pts_attr_aik_create(is_naked_key, chunk_from_thing(aik_cert));
}
else if(is_naked_key && aik_key)
{
attr = tcg_pts_attr_aik_create(is_naked_key, chunk_from_thing(aik_key));
}
else
{
DBG1(DBG_IMC, "Neither AIK Certificate nor AIK public was provided");
break;
}
attr_list->insert_last(attr_list, attr);
break;
}
@@ -421,8 +421,26 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
attr_cast = (tcg_pts_attr_aik_t*)attr;
aik = attr_cast->get_aik(attr_cast);
is_naked_key = attr_cast->get_naked_flag(attr_cast);
pts->set_aik(pts, aik, is_naked_key);
if(!is_naked_key)
{
certificate_t *aik_cert;
aik_cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_PEM, aik,
BUILD_END);
pts->set_aik_cert(pts, aik_cert);
}
else
{
public_key_t *aik_key;
aik_key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
BUILD_BLOB_PEM, aik,
BUILD_END);
pts->set_aik_key(pts, aik_key);
}
attestation_state->set_handshake_state(attestation_state,
IMV_ATTESTATION_STATE_END);
break;