From 46fd48797df3c7067ddce20987b39b9bd63bc2cd Mon Sep 17 00:00:00 2001 From: Sansar Choinyambuu Date: Wed, 31 Aug 2011 15:03:21 +0200 Subject: [PATCH] Restore flag calculation --- .../tcg/tcg_pts_attr_req_funct_comp_evid.c | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/libimcv/tcg/tcg_pts_attr_req_funct_comp_evid.c b/src/libimcv/tcg/tcg_pts_attr_req_funct_comp_evid.c index 944df0cc2..a3ea55db4 100644 --- a/src/libimcv/tcg/tcg_pts_attr_req_funct_comp_evid.c +++ b/src/libimcv/tcg/tcg_pts_attr_req_funct_comp_evid.c @@ -160,12 +160,29 @@ METHOD(pa_tnc_attr_t, build, void, private_tcg_pts_attr_req_funct_comp_evid_t *this) { bio_writer_t *writer; + u_int8_t flags = 0; u_int8_t qualifier = 0; writer = bio_writer_create(PTS_REQ_FUNCT_COMP_EVID_SIZE); /* Determine the flags to set*/ - writer->write_uint8(writer, this->flags); + if (this->flags & PTS_REQ_FUNC_COMP_FLAG_PCR) + { + flags += 128; + } + if (this->flags & PTS_REQ_FUNC_COMP_FLAG_CURR) + { + flags += 64; + } + if (this->flags & PTS_REQ_FUNC_COMP_FLAG_VER) + { + flags += 32; + } + if (this->flags & PTS_REQ_FUNC_COMP_FLAG_TTC) + { + flags += 16; + } + writer->write_uint8(writer, flags); writer->write_uint24 (writer, this->depth); writer->write_uint24 (writer, this->comp_vendor_id); @@ -195,6 +212,7 @@ METHOD(pa_tnc_attr_t, process, status_t, private_tcg_pts_attr_req_funct_comp_evid_t *this, u_int32_t *offset) { bio_reader_t *reader; + u_int8_t flags; u_int8_t fam_and_qualifier; if (this->value.len < PTS_REQ_FUNCT_COMP_EVID_SIZE) @@ -205,7 +223,24 @@ METHOD(pa_tnc_attr_t, process, status_t, } reader = bio_reader_create(this->value); - reader->read_uint8(reader, &this->flags); + reader->read_uint8(reader, &flags); + if ((flags >> 4) & 1) + { + this->flags |= PTS_REQ_FUNC_COMP_FLAG_PCR; + } + if ((flags >> 5) & 1) + { + this->flags |= PTS_REQ_FUNC_COMP_FLAG_CURR; + } + if ((flags >> 6) & 1) + { + this->flags |= PTS_REQ_FUNC_COMP_FLAG_VER; + } + if ((flags >> 7) & 1) + { + this->flags |= PTS_REQ_FUNC_COMP_FLAG_TTC; + } + reader->read_uint24(reader, &this->depth); reader->read_uint24(reader, &this->comp_vendor_id); reader->read_uint8(reader, &fam_and_qualifier);