Replaced Tag File Path by Instance ID field
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 14 Jul 2014 18:38:11 +0000 (20:38 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 16 Jul 2014 13:57:15 +0000 (15:57 +0200)
This update reflects the latest changes in the TCG TNC
SWID Messages and Attributes for IF-M specification

src/libpts/plugins/imc_swid/imc_swid.c
src/libpts/swid/swid_tag.c
src/libpts/swid/swid_tag.h
src/libpts/swid/swid_tag_id.c
src/libpts/swid/swid_tag_id.h
src/libpts/tcg/swid/tcg_swid_attr_tag_id_inv.c
src/libpts/tcg/swid/tcg_swid_attr_tag_inv.c

index ef3a6a3..b8aa922 100644 (file)
@@ -188,7 +188,7 @@ static bool add_swid_inventory(imc_state_t *state, imc_msg_t *msg,
        {
                tcg_swid_attr_tag_inv_t *swid_attr;
                swid_tag_t *tag;
-               chunk_t encoding, tag_file_path;
+               chunk_t encoding, instance_id;
 
                /* At least one TCG Tag Inventory attribute is sent */
                attr_size = PA_TNC_ATTR_HEADER_SIZE + TCG_SWID_TAG_INV_MIN_SIZE;
@@ -197,9 +197,9 @@ static bool add_swid_inventory(imc_state_t *state, imc_msg_t *msg,
                enumerator = swid_inventory->create_enumerator(swid_inventory);
                while (enumerator->enumerate(enumerator, &tag))
                {
-                       tag_file_path = tag->get_tag_file_path(tag);
+                       instance_id = tag->get_instance_id(tag);
                        encoding = tag->get_encoding(tag);
-                       entry_size = 2 + tag_file_path.len + 4 + encoding.len;
+                       entry_size = 2 + instance_id.len + 4 + encoding.len;
 
                        /* Check for oversize tags that cannot be transported */
                        if (PA_TNC_ATTR_HEADER_SIZE + TCG_SWID_TAG_INV_MIN_SIZE +
@@ -241,7 +241,7 @@ static bool add_swid_inventory(imc_state_t *state, imc_msg_t *msg,
        {
                tcg_swid_attr_tag_id_inv_t *swid_id_attr;
                swid_tag_id_t *tag_id;
-               chunk_t tag_creator, unique_sw_id, tag_file_path;
+               chunk_t tag_creator, unique_sw_id, instance_id;
 
                /* At least one TCG Tag ID Inventory attribute is sent */
                attr_size = PA_TNC_ATTR_HEADER_SIZE + TCG_SWID_TAG_ID_INV_MIN_SIZE;
@@ -252,9 +252,9 @@ static bool add_swid_inventory(imc_state_t *state, imc_msg_t *msg,
                while (enumerator->enumerate(enumerator, &tag_id))
                {
                        tag_creator = tag_id->get_tag_creator(tag_id);
-                       unique_sw_id = tag_id->get_unique_sw_id(tag_id, &tag_file_path);
+                       unique_sw_id = tag_id->get_unique_sw_id(tag_id, &instance_id);
                        entry_size = 2 + tag_creator.len + 2 + unique_sw_id.len +
-                                                2 + tag_file_path.len;
+                                                2 + instance_id.len;
 
                        if (attr_size + entry_size > max_attr_size)
                        {
index c71d5d2..c77c757 100644 (file)
@@ -34,9 +34,9 @@ struct private_swid_tag_t {
        chunk_t encoding;
 
        /**
-        * Optional Tag File Path
+        * Optional Tag Identifier Instance ID
         */
-       chunk_t tag_file_path;
+       chunk_t instance_id;
 
        /**
         * Reference count
@@ -50,10 +50,10 @@ METHOD(swid_tag_t, get_encoding, chunk_t,
        return this->encoding;
 }
 
-METHOD(swid_tag_t, get_tag_file_path, chunk_t,
+METHOD(swid_tag_t, get_instance_id, chunk_t,
        private_swid_tag_t *this)
 {
-       return this->tag_file_path;
+       return this->instance_id;
 }
 
 METHOD(swid_tag_t, get_ref, swid_tag_t*,
@@ -69,7 +69,7 @@ METHOD(swid_tag_t, destroy, void,
        if (ref_put(&this->ref))
        {
                free(this->encoding.ptr);
-               free(this->tag_file_path.ptr);
+               free(this->instance_id.ptr);
                free(this);
        }
 }
@@ -77,14 +77,14 @@ METHOD(swid_tag_t, destroy, void,
 /**
  * See header
  */
-swid_tag_t *swid_tag_create(chunk_t encoding, chunk_t tag_file_path)
+swid_tag_t *swid_tag_create(chunk_t encoding, chunk_t instance_id)
 {
        private_swid_tag_t *this;
 
        INIT(this,
                .public = {
                        .get_encoding = _get_encoding,
-                       .get_tag_file_path = _get_tag_file_path,
+                       .get_instance_id = _get_instance_id,
                        .get_ref = _get_ref,
                        .destroy = _destroy,
                },
@@ -92,9 +92,9 @@ swid_tag_t *swid_tag_create(chunk_t encoding, chunk_t tag_file_path)
                .ref = 1,
        );
 
-       if (tag_file_path.len > 0)
+       if (instance_id.len > 0)
        {
-               this->tag_file_path = chunk_clone(tag_file_path);
+               this->instance_id = chunk_clone(instance_id);
        }
 
        return &this->public;
index e20c538..0e2eb49 100644 (file)
@@ -39,11 +39,11 @@ struct swid_tag_t {
        chunk_t (*get_encoding)(swid_tag_t *this);
 
        /**
-        * Get th Optional Tag File Path
+        * Get the optional Tag Identifier Instance ID
         *
-        * @return                              Optional Tag File Path
+        * @return                              Optional Tag Identifier Instance ID
         */
-       chunk_t (*get_tag_file_path)(swid_tag_t *this);
+       chunk_t (*get_instance_id)(swid_tag_t *this);
 
        /**
         * Get a new reference to the swid_tag object
@@ -63,8 +63,8 @@ struct swid_tag_t {
  * Creates a swid_tag_t object
  *
  * @param encoding                     XML encoding of SWID tag
- * @param tag_file_path                Tag File Path or empty chunk
+ * @param instance_id          Tag Identifier Instance ID or empty chunk
  */
-swid_tag_t* swid_tag_create(chunk_t encoding, chunk_t tag_file_path);
+swid_tag_t* swid_tag_create(chunk_t encoding, chunk_t instance_id);
 
 #endif /** SWID_TAG_H_ @}*/
index 8bede28..2dc6e31 100644 (file)
@@ -39,9 +39,9 @@ struct private_swid_tag_id_t {
        chunk_t unique_sw_id;
 
        /**
-        * Tag File Path
+        * Optional Tag Identifier Instance ID
         */
-       chunk_t tag_file_path;
+       chunk_t instance_id;
 
        /**
         * Reference count
@@ -56,11 +56,11 @@ METHOD(swid_tag_id_t, get_tag_creator, chunk_t,
 }
 
 METHOD(swid_tag_id_t, get_unique_sw_id, chunk_t,
-       private_swid_tag_id_t *this, chunk_t *tag_file_path)
+       private_swid_tag_id_t *this, chunk_t *instance_id)
 {
-       if (tag_file_path)
+       if (instance_id)
        {
-               *tag_file_path = this->tag_file_path;
+               *instance_id = this->instance_id;
        }
        return this->unique_sw_id;
 }
@@ -79,7 +79,7 @@ METHOD(swid_tag_id_t, destroy, void,
        {
                free(this->tag_creator.ptr);
                free(this->unique_sw_id.ptr);
-               free(this->tag_file_path.ptr);
+               free(this->instance_id.ptr);
                free(this);
        }
 }
@@ -88,7 +88,7 @@ METHOD(swid_tag_id_t, destroy, void,
  * See header
  */
 swid_tag_id_t *swid_tag_id_create(chunk_t tag_creator, chunk_t unique_sw_id,
-                                                                 chunk_t tag_file_path)
+                                                                 chunk_t instance_id)
 {
        private_swid_tag_id_t *this;
 
@@ -104,9 +104,9 @@ swid_tag_id_t *swid_tag_id_create(chunk_t tag_creator, chunk_t unique_sw_id,
                .ref = 1,
        );
 
-       if (tag_file_path.len > 0)
+       if (instance_id.len > 0)
        {
-               this->tag_file_path = chunk_clone(tag_file_path);
+               this->instance_id = chunk_clone(instance_id);
        }
 
        return &this->public;
index d2a783b..9761f2a 100644 (file)
@@ -41,10 +41,10 @@ struct swid_tag_id_t {
        /**
         * Get the Unique Software ID and optional Tag File Path
         *
-        * @param                               Optional Tag File Path
+        * @param instance_id   Optional Tag Identifier Instance ID
         * @return                              Unique Software ID
         */
-       chunk_t (*get_unique_sw_id)(swid_tag_id_t *this, chunk_t *tag_file_path);
+       chunk_t (*get_unique_sw_id)(swid_tag_id_t *this, chunk_t *instance_id);
 
        /**
         * Get a new reference to the swid_tag_id object
@@ -65,9 +65,9 @@ struct swid_tag_id_t {
  *
  * @param tag_creator          Tag Creator
  * @param unique_sw_id         Unique Software ID
- * @param tag_file_path                Tag File Path or empty chunk
+ * @param instance_id          Tag Identifier Instance ID or empty chunk
  */
 swid_tag_id_t* swid_tag_id_create(chunk_t tag_creator, chunk_t unique_sw_id,
-                                                                 chunk_t tag_file_path);
+                                                                 chunk_t instance_id);
 
 #endif /** SWID_TAG_ID_H_ @}*/
index 33aa16d..d0b92c8 100644 (file)
@@ -42,7 +42,7 @@ typedef struct private_tcg_swid_attr_tag_id_inv_t private_tcg_swid_attr_tag_id_i
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *  |    Unique Software ID Length  |Unique Software ID (var length)|
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |      Tag File Path Length     |  Tag File Path (var. length)  |
+ *  |       Instance ID Length      | Instance ID (variable length) |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
@@ -128,7 +128,7 @@ METHOD(pa_tnc_attr_t, build, void,
 {
        bio_writer_t *writer;
        swid_tag_id_t *tag_id;
-       chunk_t tag_creator, unique_sw_id, tag_file_path;
+       chunk_t tag_creator, unique_sw_id, instance_id;
        enumerator_t *enumerator;
 
        if (this->value.ptr)
@@ -147,10 +147,10 @@ METHOD(pa_tnc_attr_t, build, void,
        while (enumerator->enumerate(enumerator, &tag_id))
        {
                tag_creator = tag_id->get_tag_creator(tag_id);
-               unique_sw_id = tag_id->get_unique_sw_id(tag_id, &tag_file_path);
+               unique_sw_id = tag_id->get_unique_sw_id(tag_id, &instance_id);
                writer->write_data16(writer, tag_creator);
                writer->write_data16(writer, unique_sw_id);
-               writer->write_data16(writer, tag_file_path);
+               writer->write_data16(writer, instance_id);
        }
        enumerator->destroy(enumerator);
 
@@ -164,7 +164,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        uint32_t tag_id_count;
        uint8_t reserved;
-       chunk_t tag_creator, unique_sw_id, tag_file_path;
+       chunk_t tag_creator, unique_sw_id, instance_id;
        swid_tag_id_t *tag_id;
 
        if (this->value.len < TCG_SWID_TAG_ID_INV_MIN_SIZE)
@@ -198,14 +198,14 @@ METHOD(pa_tnc_attr_t, process, status_t,
                }
                *offset += 2 + unique_sw_id.len;
                
-               if (!reader->read_data16(reader, &tag_file_path))
+               if (!reader->read_data16(reader, &instance_id))
                {
-                       DBG1(DBG_TNC, "insufficient data for Tag File Path");
+                       DBG1(DBG_TNC, "insufficient data for Instance ID");
                        return FAILED;
                }
-               *offset += 2 + tag_file_path.len;
+               *offset += 2 + instance_id.len;
 
-               tag_id = swid_tag_id_create(tag_creator, unique_sw_id, tag_file_path);
+               tag_id = swid_tag_id_create(tag_creator, unique_sw_id, instance_id);
                this->inventory->add(this->inventory, tag_id);
        }
        reader->destroy(reader);
index fbb94c6..5864e5a 100644 (file)
@@ -38,7 +38,7 @@ typedef struct private_tcg_swid_attr_tag_inv_t private_tcg_swid_attr_tag_inv_t;
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *  |                           Last EID                            |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *  |    Tag File Path Length       |  Tag File Path (var length)   |
+ *  |      Instance ID Length       |   Instance ID (var. length)   |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *  |                          Tag Length                           |
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -145,7 +145,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator = this->inventory->create_enumerator(this->inventory);
        while (enumerator->enumerate(enumerator, &tag))
        {
-               writer->write_data16(writer, tag->get_tag_file_path(tag));
+               writer->write_data16(writer, tag->get_instance_id(tag));
                writer->write_data32(writer, tag->get_encoding(tag));
        }
        enumerator->destroy(enumerator);
@@ -160,7 +160,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        uint32_t tag_count;
        uint8_t reserved;
-       chunk_t tag_encoding, tag_file_path;
+       chunk_t tag_encoding, instance_id;
        swid_tag_t *tag;
 
        if (this->value.len < TCG_SWID_TAG_INV_MIN_SIZE)
@@ -180,12 +180,12 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        while (tag_count--)
        {
-               if (!reader->read_data16(reader, &tag_file_path))
+               if (!reader->read_data16(reader, &instance_id))
                {
-                       DBG1(DBG_TNC, "insufficient data for Tag File Path");
+                       DBG1(DBG_TNC, "insufficient data for Instance ID");
                        return FAILED;
                }
-               *offset += 2 + tag_file_path.len;
+               *offset += 2 + instance_id.len;
 
                if (!reader->read_data32(reader, &tag_encoding))
                {
@@ -194,7 +194,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
                }
                *offset += 4 + tag_encoding.len;
 
-               tag = swid_tag_create(tag_encoding, tag_file_path);
+               tag = swid_tag_create(tag_encoding, instance_id);
                this->inventory->add(this->inventory, tag);
        }
        reader->destroy(reader);