From 89f7bf2276b43c12b27584efd7ce3456d05b95a4 Mon Sep 17 00:00:00 2001 From: Sansar Choinyambuu Date: Fri, 12 Aug 2011 10:54:01 +0200 Subject: [PATCH] Changed the type of hash algorithm to the enum variable Replaced the values of flag enum variables --- .../tcg/tcg_pts_attr_simple_comp_evid.c | 18 ++++++++++-------- .../tcg/tcg_pts_attr_simple_comp_evid.h | 16 ++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.c b/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.c index 47be03997..555efc16d 100644 --- a/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.c +++ b/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.c @@ -126,7 +126,7 @@ struct private_tcg_pts_attr_simple_comp_evid_t { bool noskip_flag; /** - * Set of flags for Request Functional Component + * Set of flags for Simple Component Evidence */ pts_attr_simple_comp_evid_flag_t flags; @@ -168,7 +168,7 @@ struct private_tcg_pts_attr_simple_comp_evid_t { /** * Hash Algorithm */ - u_int16_t hash_algorithm; + pts_attr_meas_algorithms_t hash_algorithm; /** * Transformation type for PCR @@ -285,13 +285,14 @@ METHOD(pa_tnc_attr_t, build, void, writer->write_data (writer, this->measurement_time); /* Optional fields */ - if(this->policy_uri.ptr) + if(this->policy_uri.ptr && this->policy_uri.len > 0) { writer->write_uint16 (writer, this->policy_uri.len); writer->write_data (writer, this->policy_uri); } if(this->pcr_before.ptr && this->pcr_after.ptr && - this->pcr_before.len == this->pcr_after.len) + this->pcr_before.len == this->pcr_after.len && + this->pcr_before.len > 0 && this->pcr_after.len > 0) { writer->write_uint16 (writer, this->pcr_before.len); writer->write_data (writer, this->pcr_before); @@ -493,14 +494,14 @@ METHOD(tcg_pts_attr_simple_comp_evid_t, set_extended_pcr, void, this->extended_pcr = extended_pcr; } -METHOD(tcg_pts_attr_simple_comp_evid_t, get_hash_algorithm, u_int16_t, +METHOD(tcg_pts_attr_simple_comp_evid_t, get_hash_algorithm, pts_attr_meas_algorithms_t, private_tcg_pts_attr_simple_comp_evid_t *this) { return this->hash_algorithm; } METHOD(tcg_pts_attr_simple_comp_evid_t, set_hash_algorithm, void, - private_tcg_pts_attr_simple_comp_evid_t *this, u_int16_t hash_algorithm) + private_tcg_pts_attr_simple_comp_evid_t *this, pts_attr_meas_algorithms_t hash_algorithm) { this->hash_algorithm = hash_algorithm; } @@ -569,7 +570,8 @@ METHOD(tcg_pts_attr_simple_comp_evid_t, get_pcr_len, u_int16_t, private_tcg_pts_attr_simple_comp_evid_t *this) { if(this->pcr_before.ptr && this->pcr_after.ptr && - this->pcr_before.len == this->pcr_after.len) + this->pcr_before.len == this->pcr_after.len && + this->pcr_before.len > 0 && this->pcr_after.len > 0) return this->pcr_before.len; else return 0; } @@ -596,7 +598,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create( tcg_pts_qualifier_t qualifier, pts_attr_req_funct_comp_name_bin_enum_t name, u_int32_t extended_pcr, - u_int16_t hash_algorithm, + pts_attr_meas_algorithms_t hash_algorithm, pts_attr_simple_comp_evid_pcr_transform_t transformation, chunk_t measurement_time, chunk_t policy_uri, diff --git a/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.h b/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.h index e78f03d64..f6c79c0f5 100644 --- a/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.h +++ b/src/libimcv/tcg/tcg_pts_attr_simple_comp_evid.h @@ -38,15 +38,15 @@ typedef enum pts_attr_simple_comp_evid_pcr_transform_t pts_attr_simple_comp_evid */ enum pts_attr_simple_comp_evid_flag_t { /** PCR information fields inlcuded */ - PTS_SIMPLE_COMP_EVID_FLAG_PCR = (1<<0), + PTS_SIMPLE_COMP_EVID_FLAG_PCR = 0, /** No Validation was attempted */ - PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID = (1<<1), + PTS_SIMPLE_COMP_EVID_FLAG_NO_VALID = 1, /** Attempted validation, unable to verify */ - PTS_SIMPLE_COMP_EVID_FLAG_NO_VER = (1<<2), + PTS_SIMPLE_COMP_EVID_FLAG_NO_VER = 2, /** Attempted validation, verification failed */ - PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL = (1<<3), + PTS_SIMPLE_COMP_EVID_FLAG_VER_FAIL = 3, /** Attempted validation, verification passed */ - PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS = (1<<4), + PTS_SIMPLE_COMP_EVID_FLAG_VER_PASS = 4, }; /** @@ -168,7 +168,7 @@ struct tcg_pts_attr_simple_comp_evid_t { * * @return Hash Algorithm */ - u_int16_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this); + pts_attr_meas_algorithms_t (*get_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this); /** * Set Hash Algorithm @@ -176,7 +176,7 @@ struct tcg_pts_attr_simple_comp_evid_t { * @param hash_algorithm Hash Algorithm */ void (*set_hash_algorithm)(tcg_pts_attr_simple_comp_evid_t *this, - u_int16_t hash_algorithm); + pts_attr_meas_algorithms_t hash_algorithm); /** * Get PCR Transformation @@ -300,7 +300,7 @@ pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(pts_attr_simple_comp_evid_fl tcg_pts_qualifier_t qualifier, pts_attr_req_funct_comp_name_bin_enum_t name, u_int32_t extended_pcr, - u_int16_t hash_algorithm, + pts_attr_meas_algorithms_t hash_algorithm, pts_attr_simple_comp_evid_pcr_transform_t transformation, chunk_t measurement_time, chunk_t policy_uri,