Use chunk_t.len instead of sizeof function
Bit 0 for the flag fields is the most significant field
This commit is contained in:
committed by
Andreas Steffen
parent
d975e4a755
commit
0105cc5c36
@@ -117,7 +117,7 @@ METHOD(pa_tnc_attr_t, build, void,
|
||||
|
||||
writer = bio_writer_create(PTS_AIK_SIZE);
|
||||
|
||||
if(this->naked_pub_aik) flags += 1;
|
||||
if(this->naked_pub_aik) flags += 128;
|
||||
writer->write_uint8 (writer, flags);
|
||||
writer->write_data(writer, this->aik);
|
||||
|
||||
@@ -140,9 +140,9 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
reader = bio_reader_create(this->value);
|
||||
|
||||
reader->read_uint8(reader, &flags);
|
||||
if(flags) this->naked_pub_aik = true;
|
||||
if((flags >> 7 ) & 1) this->naked_pub_aik = true;
|
||||
|
||||
reader->read_data (reader, sizeof(this->value) - 1, &this->aik);
|
||||
reader->read_data (reader, this->value.len - 1, &this->aik);
|
||||
this->aik = chunk_clone(this->aik);
|
||||
reader->destroy(reader);
|
||||
|
||||
|
||||
@@ -164,10 +164,11 @@ METHOD(pa_tnc_attr_t, build, void,
|
||||
writer = bio_writer_create(PTS_REQ_FUNCT_COMP_EVID_SIZE);
|
||||
|
||||
/* Determine the flags to set*/
|
||||
if(this->flags & PTS_REQ_FUNC_COMP_FLAG_TTC) flags += 1;
|
||||
if(this->flags & PTS_REQ_FUNC_COMP_FLAG_VER) flags += 2;
|
||||
if(this->flags & PTS_REQ_FUNC_COMP_FLAG_CURR) flags += 4;
|
||||
if(this->flags & PTS_REQ_FUNC_COMP_FLAG_PCR) flags += 8;
|
||||
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);
|
||||
@@ -205,17 +206,17 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
reader = bio_reader_create(this->value);
|
||||
|
||||
reader->read_uint8(reader, &flags);
|
||||
if((flags >> 0) & 1) this->flags |= PTS_REQ_FUNC_COMP_FLAG_TTC;
|
||||
if((flags >> 1) & 1) this->flags |= PTS_REQ_FUNC_COMP_FLAG_VER;
|
||||
if((flags >> 2) & 1) this->flags |= PTS_REQ_FUNC_COMP_FLAG_CURR;
|
||||
if((flags >> 3) & 1) this->flags |= PTS_REQ_FUNC_COMP_FLAG_PCR;
|
||||
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);
|
||||
|
||||
if(((fam_and_qualifier >> 6) & 1) ) this->family += 64;
|
||||
if(((fam_and_qualifier >> 7) & 1) ) this->family += 128;
|
||||
if(((fam_and_qualifier >> 6) & 1) ) this->family += 1;
|
||||
if(((fam_and_qualifier >> 7) & 1) ) this->family += 2;
|
||||
|
||||
/* TODO: Generate an IF-M error attribute indicating */
|
||||
/* TCG_PTS_INVALID_NAME_FAM */
|
||||
@@ -227,11 +228,9 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
if(((fam_and_qualifier >> 5) & 1) ) this->qualifier.kernel = true;
|
||||
if(((fam_and_qualifier >> 4) & 1) ) this->qualifier.sub_component = true;
|
||||
this->qualifier.type = ( fam_and_qualifier & 0xF );
|
||||
|
||||
/* TODO: Check the type is defined in pts_attr_req_funct_comp_type_t */
|
||||
|
||||
reader->read_uint32(reader, &this->name);
|
||||
|
||||
/* TODO: Check the name is defined in pts_attr_req_funct_comp_name_bin_enum_t */
|
||||
|
||||
reader->destroy(reader);
|
||||
@@ -308,7 +307,7 @@ pa_tnc_attr_t *tcg_pts_attr_req_funct_comp_evid_create(
|
||||
u_int32_t depth,
|
||||
u_int32_t vendor_id,
|
||||
tcg_pts_qualifier_t qualifier,
|
||||
name)
|
||||
pts_attr_req_funct_comp_name_bin_enum_t name)
|
||||
{
|
||||
private_tcg_pts_attr_req_funct_comp_evid_t *this;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
return FAILED;
|
||||
}
|
||||
reader = bio_reader_create(this->value);
|
||||
reader->read_data (reader, sizeof(this->value), &this->tpm_version_info);
|
||||
reader->read_data (reader, this->value.len, &this->tpm_version_info);
|
||||
this->tpm_version_info = chunk_clone(this->tpm_version_info);
|
||||
reader->destroy(reader);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user