Split TCG SWID Request attribute into chunks if needed
This commit is contained in:
@@ -178,7 +178,7 @@ static bool add_swid_inventory(imc_state_t *state, imc_msg_t *msg,
|
||||
eid_epoch = swid_state->get_eid_epoch(swid_state);
|
||||
|
||||
/**
|
||||
* Compute the maximum TCG Tag [ID] Inventory attribute size
|
||||
* Compute the maximum TCG SWID Tag [ID] Inventory attribute size
|
||||
* leaving space for an additional ITA Angel attribute
|
||||
*/
|
||||
max_attr_size = state->get_max_msg_len(state) -
|
||||
|
||||
@@ -467,6 +467,7 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
char result_str[BUF_LEN], *error_str = "", *command;
|
||||
char *target, *separator;
|
||||
int tag_id_count, tag_count, i;
|
||||
size_t max_attr_size, attr_size, entry_size;
|
||||
chunk_t tag_creator, unique_sw_id;
|
||||
json_object *jrequest, *jresponse, *jvalue;
|
||||
tcg_swid_attr_req_t *cast_attr;
|
||||
@@ -535,9 +536,15 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
json_object_put(jresponse);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Compute the maximum TCG SWID Request attribute size */
|
||||
max_attr_size = state->get_max_msg_len(state) -
|
||||
PA_TNC_HEADER_SIZE;
|
||||
|
||||
/* Create the [first] TCG SWID Request attribute */
|
||||
attr_size = PA_TNC_ATTR_HEADER_SIZE + TCG_SWID_REQ_MIN_SIZE;
|
||||
attr = tcg_swid_attr_req_create(TCG_SWID_ATTR_REQ_FLAG_NONE,
|
||||
swid_state->get_request_id(swid_state), 0);
|
||||
cast_attr = (tcg_swid_attr_req_t*)attr;
|
||||
|
||||
tag_id_count = json_object_array_length(jresponse);
|
||||
DBG1(DBG_IMV, "%d SWID tag targets", tag_id_count);
|
||||
@@ -569,6 +576,19 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
tag_creator.len - 1);
|
||||
tag_id = swid_tag_id_create(tag_creator, unique_sw_id,
|
||||
chunk_empty);
|
||||
entry_size = 2 + tag_creator.len + 2 + unique_sw_id.len;
|
||||
|
||||
/* Have we reached the maximum attribute size? */
|
||||
if (attr_size + entry_size > max_attr_size)
|
||||
{
|
||||
out_msg->add_attribute(out_msg, attr);
|
||||
attr_size = PA_TNC_ATTR_HEADER_SIZE +
|
||||
TCG_SWID_REQ_MIN_SIZE;
|
||||
attr = tcg_swid_attr_req_create(
|
||||
TCG_SWID_ATTR_REQ_FLAG_NONE,
|
||||
swid_state->get_request_id(swid_state), 0);
|
||||
}
|
||||
cast_attr = (tcg_swid_attr_req_t*)attr;
|
||||
cast_attr->add_target(cast_attr, tag_id);
|
||||
}
|
||||
json_object_put(jresponse);
|
||||
|
||||
@@ -44,7 +44,6 @@ typedef struct private_tcg_swid_attr_req_t private_tcg_swid_attr_req_t;
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
#define SWID_REQ_SIZE 12
|
||||
#define SWID_REQ_RESERVED_MASK 0x03
|
||||
|
||||
/**
|
||||
@@ -135,7 +134,7 @@ METHOD(pa_tnc_attr_t, build, void,
|
||||
return;
|
||||
}
|
||||
|
||||
writer = bio_writer_create(SWID_REQ_SIZE);
|
||||
writer = bio_writer_create(TCG_SWID_REQ_MIN_SIZE);
|
||||
writer->write_uint8 (writer, this->flags);
|
||||
writer->write_uint24(writer, this->targets->get_count(this->targets));
|
||||
writer->write_uint32(writer, this->request_id);
|
||||
@@ -163,7 +162,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
chunk_t tag_creator, unique_sw_id;
|
||||
swid_tag_id_t *tag_id;
|
||||
|
||||
if (this->value.len < SWID_REQ_SIZE)
|
||||
if (this->value.len < TCG_SWID_REQ_MIN_SIZE)
|
||||
{
|
||||
DBG1(DBG_TNC, "insufficient data for SWID Request");
|
||||
*offset = 0;
|
||||
@@ -181,7 +180,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
*offset = 4;
|
||||
return FAILED;
|
||||
}
|
||||
*offset = SWID_REQ_SIZE;
|
||||
*offset = TCG_SWID_REQ_MIN_SIZE;
|
||||
|
||||
this->flags &= SWID_REQ_RESERVED_MASK;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Andreas Steffen
|
||||
* Copyright (C) 2013-2014 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef TCG_SWID_ATTR_REQ_H_
|
||||
#define TCG_SWID_ATTR_REQ_H_
|
||||
|
||||
#define TCG_SWID_REQ_MIN_SIZE 12
|
||||
|
||||
typedef struct tcg_swid_attr_req_t tcg_swid_attr_req_t;
|
||||
typedef enum tcg_swid_attr_req_flag_t tcg_swid_attr_req_flag_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user