Replaced with boolean variable for PCR info included and Evidence Signature included flags
Write and Read flags to int first and set flags /Due to special definition/
This commit is contained in:
committed by
Andreas Steffen
parent
e8181d7077
commit
63b0c12f54
@@ -241,10 +241,28 @@ METHOD(pa_tnc_attr_t, build, void,
|
||||
private_tcg_pts_attr_simple_comp_evid_t *this)
|
||||
{
|
||||
bio_writer_t *writer;
|
||||
u_int8_t qualifier = 0;
|
||||
u_int8_t flags = 0, qualifier = 0;
|
||||
|
||||
writer = bio_writer_create(PTS_SIMPLE_COMP_EVID_SIZE);
|
||||
writer->write_uint8(writer, this->flags);
|
||||
/* Determine the flags to set*/
|
||||
if (this->pcr_info_included)
|
||||
{
|
||||
flags += 128;
|
||||
}
|
||||
if (this->flags == PTS_SIMPLE_COMP_EVID_FLAG_NO_VER)
|
||||
{
|
||||
flags += 32;
|
||||
}
|
||||
else if (this->flags == PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL)
|
||||
{
|
||||
flags += 64;
|
||||
}
|
||||
else if (this->flags == PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS)
|
||||
{
|
||||
flags += 96;
|
||||
}
|
||||
|
||||
writer->write_uint8(writer, flags);
|
||||
writer->write_uint24 (writer, this->depth);
|
||||
writer->write_uint24 (writer, this->comp_vendor_id);
|
||||
|
||||
@@ -323,7 +341,27 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
reader = bio_reader_create(this->value);
|
||||
|
||||
reader->read_uint8(reader, &flags);
|
||||
this->flags = flags;
|
||||
/* Determine the flags to set*/
|
||||
if ((flags >> 7) & 1)
|
||||
{
|
||||
this->pcr_info_included = TRUE;
|
||||
}
|
||||
if (!((flags >> 6) & 1) && !((flags >> 5) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID;
|
||||
}
|
||||
else if (!((flags >> 6) & 1) && ((flags >> 5) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_COMP_EVID_FLAG_NO_VER;
|
||||
}
|
||||
else if (((flags >> 6) & 1) && !((flags >> 5) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL;
|
||||
}
|
||||
else if (((flags >> 6) & 1) && ((flags >> 5) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS;
|
||||
}
|
||||
|
||||
reader->read_uint24(reader, &this->depth);
|
||||
reader->read_uint24(reader, &this->comp_vendor_id);
|
||||
@@ -557,6 +595,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evi
|
||||
},
|
||||
.vendor_id = PEN_TCG,
|
||||
.type = TCG_PTS_SIMPLE_COMP_EVID,
|
||||
.pcr_info_included = params.pcr_info_included,
|
||||
.flags = params.flags,
|
||||
.depth = params.depth,
|
||||
.comp_vendor_id = params.vendor_id,
|
||||
|
||||
@@ -142,9 +142,29 @@ METHOD(pa_tnc_attr_t, build, void,
|
||||
private_tcg_pts_attr_simple_evid_final_t *this)
|
||||
{
|
||||
bio_writer_t *writer;
|
||||
u_int8_t flags = 0;
|
||||
|
||||
writer = bio_writer_create(PTS_SIMPLE_EVID_FINAL_SIZE);
|
||||
writer->write_uint8 (writer, this->flags);
|
||||
|
||||
/* Determine the flags to set*/
|
||||
if (this->flags == PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO)
|
||||
{
|
||||
flags += 64;
|
||||
}
|
||||
else if (this->flags == PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO2)
|
||||
{
|
||||
flags += 128;
|
||||
}
|
||||
else if (this->flags == PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO2_CAP_VER)
|
||||
{
|
||||
flags += 192;
|
||||
}
|
||||
if (this->evid_sign_included)
|
||||
{
|
||||
flags += 32;
|
||||
}
|
||||
|
||||
writer->write_uint8 (writer, flags);
|
||||
writer->write_uint8 (writer, PTS_SIMPLE_EVID_FINAL_RESERVED);
|
||||
|
||||
/* Optional fields */
|
||||
@@ -177,7 +197,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
bio_reader_t *reader;
|
||||
u_int8_t flags;
|
||||
u_int8_t reserved;
|
||||
u_int16_t algorithm;
|
||||
//u_int16_t algorithm;
|
||||
|
||||
if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE)
|
||||
{
|
||||
@@ -188,16 +208,42 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
reader = bio_reader_create(this->value);
|
||||
|
||||
reader->read_uint8(reader, &flags);
|
||||
this->flags = flags;
|
||||
|
||||
/* Determine the flags to set*/
|
||||
if (!((flags >> 7) & 1) && !((flags >> 6) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_EVID_FINAL_FLAG_NO;
|
||||
}
|
||||
else if (!((flags >> 7) & 1) && ((flags >> 6) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO;
|
||||
}
|
||||
else if (((flags >> 7) & 1) && !((flags >> 6) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO2;
|
||||
}
|
||||
else if (((flags >> 7) & 1) && ((flags >> 6) & 1))
|
||||
{
|
||||
this->flags = PTS_SIMPLE_EVID_FINAL_FLAG_TPM_QUOTE_INFO2_CAP_VER;
|
||||
}
|
||||
if ((flags >> 5) & 1)
|
||||
{
|
||||
this->evid_sign_included = TRUE;
|
||||
}
|
||||
|
||||
reader->read_uint8(reader, &reserved);
|
||||
|
||||
/* Optional Composite Hash Algorithm and TPM PCR Composite field is included */
|
||||
if ((flags >> 6) & PTS_SIMPLE_EVID_FINAL_FLAG_NO)
|
||||
if (this->flags != PTS_SIMPLE_EVID_FINAL_FLAG_NO)
|
||||
{
|
||||
u_int32_t pcr_comp_len;
|
||||
u_int32_t tpm_quote_sign_len;
|
||||
reader->read_uint16(reader, &algorithm);
|
||||
this->comp_hash_algorithm = algorithm;
|
||||
|
||||
/** TODO: Ignoring Hashing algorithm field
|
||||
* There is no flag defined which indicates the precense of it
|
||||
* reader->read_uint16(reader, &algorithm);
|
||||
* this->comp_hash_algorithm = algorithm;
|
||||
*/
|
||||
reader->read_uint32(reader, &pcr_comp_len);
|
||||
reader->read_data(reader, pcr_comp_len, &this->pcr_comp);
|
||||
this->pcr_comp = chunk_clone(this->pcr_comp);
|
||||
|
||||
Reference in New Issue
Block a user