implemented os_info_t class
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
#include <ietf/ietf_attr_product_info.h>
|
||||
#include <ietf/ietf_attr_assess_result.h>
|
||||
#include <os_info/os_info.h>
|
||||
|
||||
#include <libpts.h>
|
||||
|
||||
@@ -44,6 +45,7 @@ static const char imc_name[] = "Attestation";
|
||||
#define IMC_SUBTYPE PA_SUBTYPE_TCG_PTS
|
||||
|
||||
static imc_agent_t *imc_attestation;
|
||||
static os_info_t *os;
|
||||
|
||||
/**
|
||||
* Supported PTS measurement algorithms
|
||||
@@ -80,6 +82,15 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
os = os_info_create();
|
||||
if (!os)
|
||||
{
|
||||
imc_attestation->destroy(imc_attestation);
|
||||
imc_attestation = NULL;
|
||||
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
libpts_init();
|
||||
|
||||
if (min_version > TNC_IFIMC_VERSION_1 || max_version < TNC_IFIMC_VERSION_1)
|
||||
@@ -135,10 +146,9 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
|
||||
TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
|
||||
TNC_ConnectionID connection_id)
|
||||
{
|
||||
imc_state_t *state;
|
||||
imc_attestation_state_t *attestation_state;
|
||||
pts_t *pts;
|
||||
char *platform_info;
|
||||
linked_list_t *attr_list;
|
||||
pa_tnc_attr_t *attr;
|
||||
chunk_t os_name, os_version;
|
||||
TNC_Result result = TNC_RESULT_SUCCESS;
|
||||
|
||||
if (!imc_attestation)
|
||||
@@ -147,27 +157,15 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMC state */
|
||||
if (!imc_attestation->get_state(imc_attestation, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
attestation_state = (imc_attestation_state_t*)state;
|
||||
pts = attestation_state->get_pts(attestation_state);
|
||||
|
||||
platform_info = pts->get_platform_info(pts);
|
||||
if (platform_info)
|
||||
{
|
||||
linked_list_t *attr_list;
|
||||
pa_tnc_attr_t *attr;
|
||||
|
||||
attr_list = linked_list_create();
|
||||
attr = ietf_attr_product_info_create(0, 0, platform_info);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
result = imc_attestation->send_message(imc_attestation, connection_id,
|
||||
FALSE, 0, TNC_IMVID_ANY, attr_list);
|
||||
attr_list->destroy(attr_list);
|
||||
}
|
||||
attr_list = linked_list_create();
|
||||
attr = ietf_attr_product_info_create(0, 0, os->get_name(os));
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
attr = ietf_attr_string_version_create(os->get_version(os),
|
||||
chunk_empty, chunk_empty);
|
||||
attr_list->insert_last(attr_list, attr);
|
||||
result = imc_attestation->send_message(imc_attestation, connection_id,
|
||||
FALSE, 0, TNC_IMVID_ANY, attr_list);
|
||||
attr_list->destroy(attr_list);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -348,6 +346,9 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id)
|
||||
imc_attestation->destroy(imc_attestation);
|
||||
imc_attestation = NULL;
|
||||
|
||||
os->destroy(os);
|
||||
os = NULL;
|
||||
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,6 @@ METHOD(imc_attestation_state_t, next_evidence, bool,
|
||||
imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
{
|
||||
private_imc_attestation_state_t *this;
|
||||
char *platform_info;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -240,13 +239,6 @@ imc_state_t *imc_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.components = linked_list_create(),
|
||||
.list = linked_list_create(),
|
||||
);
|
||||
|
||||
platform_info = lib->settings->get_str(lib->settings,
|
||||
"libimcv.plugins.imc-attestation.platform_info", NULL);
|
||||
if (platform_info)
|
||||
{
|
||||
this->pts->set_platform_info(this->pts, platform_info);
|
||||
}
|
||||
|
||||
return &this->public.interface;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
p="Ubuntu 12.04.1 LTS i686"
|
||||
p="Ubuntu 12.04 i686"
|
||||
|
||||
ipsec attest --add --product "$p" --sha1-ima --dir /sbin
|
||||
ipsec attest --add --product "$p" --sha1-ima --dir /usr/sbin
|
||||
|
||||
@@ -51,7 +51,7 @@ INSERT INTO products (
|
||||
INSERT INTO products (
|
||||
name
|
||||
) VALUES (
|
||||
'Ubuntu 12.04.1 LTS i686'
|
||||
'Ubuntu 12.04 i686'
|
||||
);
|
||||
|
||||
/* Files */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
#include <ietf/ietf_attr_product_info.h>
|
||||
#include <ietf/ietf_attr_string_version.h>
|
||||
|
||||
#include <libpts.h>
|
||||
|
||||
@@ -219,6 +220,8 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
imv_state_t *state;
|
||||
imv_attestation_state_t *attestation_state;
|
||||
pts_t *pts;
|
||||
chunk_t os_name = chunk_empty;
|
||||
chunk_t os_version = chunk_empty;
|
||||
enumerator_t *enumerator;
|
||||
TNC_Result result;
|
||||
|
||||
@@ -228,7 +231,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
return TNC_RESULT_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
/* get current IMV state */
|
||||
/* get current IMV state */
|
||||
if (!imv_attestation->get_state(imv_attestation, connection_id, &state))
|
||||
{
|
||||
return TNC_RESULT_FATAL;
|
||||
@@ -260,34 +263,47 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
|
||||
if (type.vendor_id == PEN_IETF)
|
||||
{
|
||||
if (type.type == IETF_ATTR_PA_TNC_ERROR)
|
||||
switch (type.type)
|
||||
{
|
||||
ietf_attr_pa_tnc_error_t *error_attr;
|
||||
pen_type_t error_code;
|
||||
chunk_t msg_info;
|
||||
|
||||
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
|
||||
error_code = error_attr->get_error_code(error_attr);
|
||||
|
||||
if (error_code.vendor_id == PEN_TCG)
|
||||
case IETF_ATTR_PA_TNC_ERROR:
|
||||
{
|
||||
msg_info = error_attr->get_msg_info(error_attr);
|
||||
ietf_attr_pa_tnc_error_t *error_attr;
|
||||
pen_type_t error_code;
|
||||
chunk_t msg_info;
|
||||
|
||||
DBG1(DBG_IMV, "received TCG-PTS error '%N'",
|
||||
pts_error_code_names, error_code.type);
|
||||
DBG1(DBG_IMV, "error information: %B", &msg_info);
|
||||
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
|
||||
error_code = error_attr->get_error_code(error_attr);
|
||||
|
||||
result = TNC_RESULT_FATAL;
|
||||
if (error_code.vendor_id == PEN_TCG)
|
||||
{
|
||||
msg_info = error_attr->get_msg_info(error_attr);
|
||||
|
||||
DBG1(DBG_IMV, "received TCG-PTS error '%N'",
|
||||
pts_error_code_names, error_code.type);
|
||||
DBG1(DBG_IMV, "error information: %B", &msg_info);
|
||||
|
||||
result = TNC_RESULT_FATAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (type.type == IETF_ATTR_PRODUCT_INFORMATION)
|
||||
{
|
||||
ietf_attr_product_info_t *attr_cast;
|
||||
char *platform_info;
|
||||
case IETF_ATTR_PRODUCT_INFORMATION:
|
||||
{
|
||||
ietf_attr_product_info_t *attr_cast;
|
||||
|
||||
attr_cast = (ietf_attr_product_info_t*)attr;
|
||||
platform_info = attr_cast->get_info(attr_cast, NULL, NULL);
|
||||
pts->set_platform_info(pts, platform_info);
|
||||
attr_cast = (ietf_attr_product_info_t*)attr;
|
||||
os_name = attr_cast->get_info(attr_cast, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
case IETF_ATTR_STRING_VERSION:
|
||||
{
|
||||
ietf_attr_string_version_t *attr_cast;
|
||||
|
||||
attr_cast = (ietf_attr_string_version_t*)attr;
|
||||
os_version = attr_cast->get_version(attr_cast, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (type.vendor_id == PEN_TCG)
|
||||
@@ -301,6 +317,11 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (os_name.len && os_version.len)
|
||||
{
|
||||
pts->set_platform_info(pts, os_name, os_version);
|
||||
}
|
||||
pa_tnc_msg->destroy(pa_tnc_msg);
|
||||
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
|
||||
@@ -436,7 +436,6 @@ METHOD(imv_attestation_state_t, components_finalized, bool,
|
||||
imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
{
|
||||
private_imv_attestation_state_t *this;
|
||||
char *platform_info;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -476,12 +475,5 @@ imv_state_t *imv_attestation_state_create(TNC_ConnectionID connection_id)
|
||||
.pts = pts_create(FALSE),
|
||||
);
|
||||
|
||||
platform_info = lib->settings->get_str(lib->settings,
|
||||
"libimcv.plugins.imv-attestation.platform_info", NULL);
|
||||
if (platform_info)
|
||||
{
|
||||
this->pts->set_platform_info(this->pts, platform_info);
|
||||
}
|
||||
|
||||
return &this->public.interface;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user