diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-11-18 00:08:33 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-11-28 21:20:23 +0100 |
commit | 051dfbd654a2f4d5659d0a71b22d1abe474659fb (patch) | |
tree | 3a699b07af65330a3542ba9c80c20fa0bea46566 /src/libpts/tcg | |
parent | c6beb16689c37ce91b7fd32e97ca9675f88c317a (diff) | |
download | strongswan-051dfbd654a2f4d5659d0a71b22d1abe474659fb.tar.bz2 strongswan-051dfbd654a2f4d5659d0a71b22d1abe474659fb.tar.xz |
object oriented approach to pts functional components
Diffstat (limited to 'src/libpts/tcg')
-rw-r--r-- | src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c | 123 | ||||
-rw-r--r-- | src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h | 8 | ||||
-rw-r--r-- | src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c | 160 | ||||
-rw-r--r-- | src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h | 29 |
4 files changed, 71 insertions, 249 deletions
diff --git a/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c b/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c index 0d9796f59..28fa19b9c 100644 --- a/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c +++ b/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.c @@ -29,19 +29,19 @@ typedef struct private_tcg_pts_attr_req_funct_comp_evid_t private_tcg_pts_attr_r * 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Flags | Sub-component Depth (for Component #1) | + * | Flags | Sub-component Depth (for Component #1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name #1 | + * | Component Functional Name #1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name #1 | + * | Component Functional Name #1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | ........ | + * | ........ | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Flags | Sub-component Depth (for Component #N) | + * | Flags | Sub-component Depth (for Component #N) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name #N | + * | Component Functional Name #N | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name #N | + * | Component Functional Name #N | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ @@ -52,25 +52,14 @@ typedef struct private_tcg_pts_attr_req_funct_comp_evid_t private_tcg_pts_attr_r * 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name Vendor ID |Fam| Qualifier | + * | Component Functional Name Vendor ID |Fam| Qualifier | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Component Functional Name | + * | Component Functional Name | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * - */ - -/** - * Qualifier for Functional Component - * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification - * - * - * 0 1 2 3 4 5 - * +-+-+-+-+-+-+ - * |K|S| Type | - * +-+-+-+-+-+-+ */ - + #define PTS_REQ_FUNCT_COMP_EVID_SIZE 12 +#define PTS_REQ_FUNCT_COMP_FAMILY_MASK 0xC0 /** * Private data of an tcg_pts_attr_req_funct_comp_evid_t object. @@ -143,7 +132,6 @@ METHOD(pa_tnc_attr_t, build, void, { bio_writer_t *writer; enumerator_t *enumerator; - u_int8_t qualifier = 0; funct_comp_evid_req_entry_t *entry; writer = bio_writer_create(PTS_REQ_FUNCT_COMP_EVID_SIZE); @@ -151,26 +139,11 @@ METHOD(pa_tnc_attr_t, build, void, enumerator = this->requests->create_enumerator(this->requests); while (enumerator->enumerate(enumerator, &entry)) { - writer->write_uint8(writer, entry->flags); - writer->write_uint24 (writer, entry->sub_comp_depth); - writer->write_uint24 (writer, entry->vendor_id); - - if (entry->family != PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM) - { - DBG1(DBG_TNC, "Functional Name Encoding Family is not set to 00"); - } - - qualifier += entry->qualifier.type; - if (entry->qualifier.kernel) - { - qualifier += 16; - } - if (entry->qualifier.sub_component) - { - qualifier += 32; - } - writer->write_uint8 (writer, qualifier); - writer->write_uint32 (writer, entry->name); + writer->write_uint8 (writer, entry->flags); + writer->write_uint24(writer, entry->sub_comp_depth); + writer->write_uint24(writer, entry->name->get_vendor_id(entry->name)); + writer->write_uint8 (writer, entry->name->get_qualifier(entry->name)); + writer->write_uint32(writer, entry->name->get_name(entry->name)); } enumerator->destroy(enumerator); @@ -182,15 +155,15 @@ 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, fam_and_qualifier, family = 0; status_t status = FAILED; funct_comp_evid_req_entry_t *entry = NULL; - u_int32_t sub_comp_depth, vendor_id, comp_name; - pts_qualifier_t qualifier; + u_int32_t sub_comp_depth, vendor_id, name; + u_int8_t flags, fam_and_qualifier, qualifier; if (this->value.len < PTS_REQ_FUNCT_COMP_EVID_SIZE) { - DBG1(DBG_TNC, "insufficient data for Request Functional Component Evidence"); + DBG1(DBG_TNC, "insufficient data for Request Functional " + "Component Evidence"); *offset = 0; return FAILED; } @@ -202,64 +175,46 @@ METHOD(pa_tnc_attr_t, process, status_t, { if (!reader->read_uint8(reader, &flags)) { - DBG1(DBG_TNC, "insufficient data for PTS Request Functional" - " Component Evidence Flags"); + DBG1(DBG_TNC, "insufficient data for PTS Request Functional " + "Component Evidence Flags"); goto end; } if (!reader->read_uint24(reader, &sub_comp_depth)) { - DBG1(DBG_TNC, "insufficient data for PTS Request Functional" - " Component Evidence Sub Component Depth"); + DBG1(DBG_TNC, "insufficient data for PTS Request Functional " + "Component Evidence Sub Component Depth"); goto end; } if (!reader->read_uint24(reader, &vendor_id)) { - DBG1(DBG_TNC, "insufficient data for PTS Request Functional" - " Component Evidence Component Name Vendor ID"); + DBG1(DBG_TNC, "insufficient data for PTS Request Functional " + "Component Evidence Component Name Vendor ID"); goto end; } if (!reader->read_uint8(reader, &fam_and_qualifier)) { - DBG1(DBG_TNC, "insufficient data for PTS Request Functional" - " Component Evidence Family and Qualifier"); + DBG1(DBG_TNC, "insufficient data for PTS Request Functional " + "Component Evidence Family and Qualifier"); goto end; } - if (!reader->read_uint32(reader, &comp_name)) + if (fam_and_qualifier & PTS_REQ_FUNCT_COMP_FAMILY_MASK) { - DBG1(DBG_TNC, "insufficient data for PTS Request Functional" - " Component Evidence Component Functional Name"); + DBG1(DBG_TNC, "the Functional Name Encoding Family " + "is not Binary Enumeration"); goto end; } - - DBG1(DBG_TNC, "Fam and Qualifier: %d", fam_and_qualifier); - - entry = malloc_thing(funct_comp_evid_req_entry_t); - - if (((fam_and_qualifier >> 6) & 1) ) - { - family += 1; - } - if (((fam_and_qualifier >> 7) & 1) ) - { - family += 2; - } - - if (((fam_and_qualifier >> 5) & 1) ) - { - qualifier.kernel = TRUE; - } - if (((fam_and_qualifier >> 4) & 1) ) + if (!reader->read_uint32(reader, &name)) { - qualifier.sub_component = TRUE; + DBG1(DBG_TNC, "insufficient data for PTS Request Functional " + "Component Evidence Component Functional Name"); + goto end; } - qualifier.type = (fam_and_qualifier & 0xFF); - + qualifier = fam_and_qualifier & !PTS_REQ_FUNCT_COMP_FAMILY_MASK; + + entry = malloc_thing(funct_comp_evid_req_entry_t); entry->flags = flags; entry->sub_comp_depth = sub_comp_depth; - entry->vendor_id = vendor_id; - entry->family = family; - entry->qualifier = qualifier; - entry->name = comp_name; + entry->name = pts_comp_func_name_create(vendor_id, name, qualifier); this->requests->add(this->requests, entry); } diff --git a/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h b/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h index 1f830cf0f..8d251bd66 100644 --- a/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h +++ b/src/libpts/tcg/tcg_pts_attr_req_funct_comp_evid.h @@ -24,7 +24,7 @@ typedef struct tcg_pts_attr_req_funct_comp_evid_t tcg_pts_attr_req_funct_comp_evid_t; #include "tcg_attr.h" -#include "pts/pts_funct_comp_name.h" +#include "pts/components/pts_comp_func_name.h" #include "pts/pts_funct_comp_evid_req.h" #include "pa_tnc/pa_tnc_attr.h" @@ -44,8 +44,7 @@ struct tcg_pts_attr_req_funct_comp_evid_t { * * @return PTS Functional Component Evidence Requests */ - pts_funct_comp_evid_req_t* (*get_requests)( - tcg_pts_attr_req_funct_comp_evid_t *this); + pts_funct_comp_evid_req_t* (*get_requests)(tcg_pts_attr_req_funct_comp_evid_t *this); }; @@ -54,8 +53,7 @@ struct tcg_pts_attr_req_funct_comp_evid_t { * * @param requests Linked list of PTS Functional Component Evidence Requests */ -pa_tnc_attr_t* tcg_pts_attr_req_funct_comp_evid_create( - pts_funct_comp_evid_req_t *requests); +pa_tnc_attr_t* tcg_pts_attr_req_funct_comp_evid_create(pts_funct_comp_evid_req_t *requests); /** * Creates an tcg_pts_attr_req_funct_comp_evid_t object from received data diff --git a/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c b/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c index e4969c14c..755336d6e 100644 --- a/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c +++ b/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.c @@ -77,23 +77,10 @@ typedef struct private_tcg_pts_attr_simple_comp_evid_t private_tcg_pts_attr_simp * */ -/** - * Qualifier for Functional Component - * see section 5.2 of PTS Protocol: Binding to TNC IF-M Specification - * - * - * 0 1 2 3 4 5 - * +-+-+-+-+-+-+ - * |K|S| Type | - * +-+-+-+-+-+-+ - */ - - - #define PTS_SIMPLE_COMP_EVID_SIZE 40 #define PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE 20 #define PTS_SIMPLE_COMP_EVID_RESERVED 0x00 -#define PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM 0x00 +#define PTS_SIMPLE_COMP_EVID_FAMILY_MASK 0xC0 /** * Private data of an tcg_pts_attr_simple_comp_evid_t object. @@ -139,26 +126,11 @@ struct private_tcg_pts_attr_simple_comp_evid_t { * Sub-component Depth */ u_int32_t depth; - - /** - * Component Functional Name Vendor ID - */ - u_int32_t comp_vendor_id; - - /** - * Functional Name Encoding Family - */ - u_int8_t family; - - /** - * Functional Name Category Qualifier - */ - pts_qualifier_t qualifier; - + /** * Component Functional Name */ - pts_ita_funct_comp_name_t name; + pts_comp_func_name_t *name; /** * Measurement type @@ -241,7 +213,7 @@ 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, qualifier = 0; + u_int8_t flags = 0; writer = bio_writer_create(PTS_SIMPLE_COMP_EVID_SIZE); /* Determine the flags to set*/ @@ -262,35 +234,11 @@ METHOD(pa_tnc_attr_t, build, void, flags += 96; } - writer->write_uint8(writer, flags); - writer->write_uint24 (writer, this->depth); - writer->write_uint24 (writer, this->comp_vendor_id); - - if (this->family != PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM) - { - DBG1(DBG_TNC, "Functional Name Encoding Family is not set to 00"); - } - - qualifier += this->qualifier.type; - if (this->qualifier.kernel) - { - qualifier += 16; - } - if (this->qualifier.sub_component) - { - qualifier += 32; - } - - /* Unknown or Wildcard should not be used for Qualification*/ - if (!qualifier || qualifier == 63) - { - DBG1(DBG_TNC, "Unknown or Wildcard should not be used for" - " Functional Name Qualifier"); - } - - writer->write_uint8 (writer, qualifier); - writer->write_uint32(writer, this->name); - + writer->write_uint8 (writer, flags); + writer->write_uint24(writer, this->depth); + writer->write_uint24(writer, this->name->get_vendor_id(this->name)); + writer->write_uint8 (writer, this->name->get_qualifier(this->name)); + writer->write_uint32(writer, this->name->get_name(this->name)); writer->write_uint8 (writer, (this->measurement_type << 7)); writer->write_uint24(writer, this->extended_pcr); writer->write_uint16(writer, this->hash_algorithm); @@ -325,12 +273,10 @@ METHOD(pa_tnc_attr_t, process, status_t, private_tcg_pts_attr_simple_comp_evid_t *this, u_int32_t *offset) { bio_reader_t *reader; - u_int8_t flags; - u_int8_t fam_and_qualifier; - u_int8_t measurement_type; + u_int8_t flags, fam_and_qualifier, qualifier; + u_int8_t measurement_type, transformation; u_int16_t algorithm; - u_int8_t transformation; - u_int32_t measurement_len; + u_int32_t vendor_id, name, measurement_len; if (this->value.len < PTS_SIMPLE_COMP_EVID_SIZE) { @@ -364,48 +310,22 @@ METHOD(pa_tnc_attr_t, process, status_t, } 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 += 1; - } - if (((fam_and_qualifier >> 7) & 1) ) - { - this->family += 2; - } - - 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 ); + reader->read_uint24(reader, &vendor_id); + reader->read_uint8 (reader, &fam_and_qualifier); + reader->read_uint32(reader, &name); + reader->read_uint8 (reader, &measurement_type); + reader->read_uint24(reader, &this->extended_pcr); + reader->read_uint16(reader, &algorithm); + reader->read_uint8 (reader, &transformation); + reader->read_data (reader, PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE, + &this->measurement_time); - /* Unknown or Wildcard should not be used for Qualification*/ - if (!(fam_and_qualifier & 0x3F) || (fam_and_qualifier & 0x3F) == 0x3F) - { - DBG1(DBG_TNC, "Unknown or Wildcard should not be used for" - " Functional Name Qualifier"); - } + qualifier = fam_and_qualifier & (!PTS_SIMPLE_COMP_EVID_FAMILY_MASK); - reader->read_uint32(reader, &this->name); - reader->read_uint8(reader, &measurement_type); + this->name = pts_comp_func_name_create(vendor_id, name, qualifier); this->measurement_type = (measurement_type >> 7 ) & 1; - - reader->read_uint24(reader, &this->extended_pcr); - reader->read_uint16(reader, &algorithm); this->hash_algorithm = algorithm; - - reader->read_uint8(reader, &transformation); this->transformation = transformation; - - reader->read_data(reader, PTS_SIMPLE_COMP_EVID_MEASUREMENT_TIME_SIZE, - &this->measurement_time); this->measurement_time = chunk_clone(this->measurement_time); /* Optional Policy URI field is included */ @@ -466,25 +386,7 @@ METHOD(tcg_pts_attr_simple_comp_evid_t, get_sub_component_depth, u_int32_t, return this->depth; } -METHOD(tcg_pts_attr_simple_comp_evid_t, get_spec_comp_funct_name_vendor_id, u_int32_t, - private_tcg_pts_attr_simple_comp_evid_t *this) -{ - return this->comp_vendor_id; -} - -METHOD(tcg_pts_attr_simple_comp_evid_t, get_family, u_int8_t, - private_tcg_pts_attr_simple_comp_evid_t *this) -{ - return this->family; -} - -METHOD(tcg_pts_attr_simple_comp_evid_t, get_qualifier, pts_qualifier_t, - private_tcg_pts_attr_simple_comp_evid_t *this) -{ - return this->qualifier; -} - -METHOD(tcg_pts_attr_simple_comp_evid_t, get_comp_funct_name, pts_ita_funct_comp_name_t, +METHOD(tcg_pts_attr_simple_comp_evid_t, get_comp_func_name, pts_comp_func_name_t*, private_tcg_pts_attr_simple_comp_evid_t *this) { return this->name; @@ -578,10 +480,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evi .is_pcr_info_included = _is_pcr_info_included, .get_flags= _get_flags, .get_sub_component_depth = _get_sub_component_depth, - .get_spec_comp_funct_name_vendor_id = _get_spec_comp_funct_name_vendor_id, - .get_family = _get_family, - .get_qualifier = _get_qualifier, - .get_comp_funct_name = _get_comp_funct_name, + .get_comp_func_name = _get_comp_func_name, .get_measurement_type = _get_measurement_type, .get_extended_pcr = _get_extended_pcr, .get_hash_algorithm = _get_hash_algorithm, @@ -598,9 +497,6 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(tcg_pts_attr_simple_comp_evi .pcr_info_included = params.pcr_info_included, .flags = params.flags, .depth = params.depth, - .comp_vendor_id = params.vendor_id, - .family = PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM, - .qualifier = params.qualifier, .name = params.name, .extended_pcr = params.extended_pcr, .hash_algorithm = params.hash_algorithm, @@ -638,10 +534,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data) .is_pcr_info_included = _is_pcr_info_included, .get_flags= _get_flags, .get_sub_component_depth = _get_sub_component_depth, - .get_spec_comp_funct_name_vendor_id = _get_spec_comp_funct_name_vendor_id, - .get_family = _get_family, - .get_qualifier = _get_qualifier, - .get_comp_funct_name = _get_comp_funct_name, + .get_comp_func_name = _get_comp_func_name, .get_measurement_type = _get_measurement_type, .get_extended_pcr = _get_extended_pcr, .get_hash_algorithm = _get_hash_algorithm, @@ -655,7 +548,6 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data) }, .vendor_id = PEN_TCG, .type = TCG_PTS_SIMPLE_COMP_EVID, - .family = PTS_REQ_FUNCT_COMP_FAM_BIN_ENUM, .value = chunk_clone(data), ); diff --git a/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h b/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h index ff846fc8b..b26f750f1 100644 --- a/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h +++ b/src/libpts/tcg/tcg_pts_attr_simple_comp_evid.h @@ -28,7 +28,7 @@ typedef struct tcg_pts_attr_simple_comp_evid_params_t tcg_pts_attr_simple_comp_e #include "tcg_attr.h" #include "pts/pts_meas_algo.h" -#include "pts/pts_funct_comp_name.h" +#include "pts/components/pts_comp_func_name.h" #include "pa_tnc/pa_tnc_attr.h" /** @@ -66,9 +66,7 @@ struct tcg_pts_attr_simple_comp_evid_params_t { bool pcr_info_included; pts_attr_simple_comp_evid_flag_t flags; u_int32_t depth; - u_int32_t vendor_id; - pts_qualifier_t qualifier; - pts_ita_funct_comp_name_t name; + pts_comp_func_name_t *name; u_int32_t extended_pcr; pts_meas_algorithms_t hash_algorithm; pts_pcr_transform_t transformation; @@ -112,32 +110,11 @@ struct tcg_pts_attr_simple_comp_evid_t { u_int32_t (*get_sub_component_depth)(tcg_pts_attr_simple_comp_evid_t *this); /** - * Get Specific Component Functional Name Vendor ID - * - * @return Component Functional Name Vendor ID - */ - u_int32_t (*get_spec_comp_funct_name_vendor_id)(tcg_pts_attr_simple_comp_evid_t *this); - - /** - * Get Family - * - * @return Functional Name Family - */ - u_int8_t (*get_family)(tcg_pts_attr_simple_comp_evid_t *this); - - /** - * Get Qualifier - * - * @return Functional Name Category Qualifier - */ - pts_qualifier_t (*get_qualifier)(tcg_pts_attr_simple_comp_evid_t *this); - - /** * Get Special Component Functional Name * * @return Component Functional Name */ - pts_ita_funct_comp_name_t (*get_comp_funct_name)(tcg_pts_attr_simple_comp_evid_t *this); + pts_comp_func_name_t* (*get_comp_func_name)(tcg_pts_attr_simple_comp_evid_t *this); /** * Get Measurement Type |