Write/Read flags field directly to/from variable
authorSansar Choinyambuu <schoinya@hsr.ch>
Wed, 21 Sep 2011 08:35:10 +0000 (10:35 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 13:34:20 +0000 (14:34 +0100)
src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c
src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c
src/libpts/tcg/tcg_pts_attr_simple_evid_final.c

index 18f151f..716ec34 100644 (file)
@@ -205,22 +205,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
        reader = bio_reader_create(this->value);
        
        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;
-       }
+       this->flags = flags;
 
        reader->read_uint24(reader, &this->depth);
        reader->read_uint24(reader, &this->comp_vendor_id);
index 84b3172..95a83c6 100644 (file)
@@ -236,31 +236,10 @@ METHOD(pa_tnc_attr_t, build, void,
        private_tcg_pts_attr_simple_comp_evid_t *this)
 {
        bio_writer_t *writer;
-       u_int8_t flags = 0;
        u_int8_t qualifier = 0;
        
        writer = bio_writer_create(PTS_SIMPLE_COMP_EVID_SIZE);
-       
-       /* Determine the flags to set*/
-       if (this->flags & PTS_SIMPLE_COMP_EVID_FLAG_PCR)
-       {
-               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_uint8(writer, this->flags);
        writer->write_uint24 (writer, this->depth);
        writer->write_uint24 (writer, this->comp_vendor_id);
        
@@ -336,28 +315,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
        reader = bio_reader_create(this->value);
        
        reader->read_uint8(reader, &flags);
-       
-       /* Determine the flags to set*/
-       if ((flags >> 7) & 1)
-       {
-                this->flags |= PTS_SIMPLE_COMP_EVID_FLAG_PCR;
-       }
-       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;
-       }
+       this->flags = flags;
        
        reader->read_uint24(reader, &this->depth);
        reader->read_uint24(reader, &this->comp_vendor_id);
index 6081cba..b8638e3 100644 (file)
@@ -137,29 +137,9 @@ 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);
-       
-       /* 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->flags & PTS_SIMPLE_EVID_FINAL_FLAG_EVID)
-       {
-               flags += 32;
-       }
-       
-       writer->write_uint8 (writer, flags);
+       writer->write_uint8 (writer, this->flags);
        writer->write_uint8 (writer, PTS_SIMPLE_EVID_FINAL_RESERVED);
        
        /* Optional fields */
@@ -203,31 +183,9 @@ METHOD(pa_tnc_attr_t, process, status_t,
        reader = bio_reader_create(this->value);
        
        reader->read_uint8(reader, &flags);
+       this->flags = flags;
        reader->read_uint8(reader, &reserved);
        
-       /* Determine the flags to set*/
-       if ((flags >> 5) & 1)
-       {
-               this->flags |= PTS_SIMPLE_EVID_FINAL_FLAG_EVID;
-       }
-       
-       if (!((flags >> 6) & PTS_SIMPLE_EVID_FINAL_FLAG_NO))
-       {
-               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;
-       }
-
        /*  Optional Composite Hash Algorithm and TPM PCR Composite field is included */
        if ((flags >> 6) & PTS_SIMPLE_EVID_FINAL_FLAG_NO)
        {