Added total length parameter in PA-TNC attribute constructor
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 26 Sep 2014 11:24:33 +0000 (13:24 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 5 Oct 2014 10:55:38 +0000 (12:55 +0200)
91 files changed:
src/libimcv/ietf/ietf_attr.c
src/libimcv/ietf/ietf_attr.h
src/libimcv/ietf/ietf_attr_assess_result.c
src/libimcv/ietf/ietf_attr_assess_result.h
src/libimcv/ietf/ietf_attr_attr_request.c
src/libimcv/ietf/ietf_attr_attr_request.h
src/libimcv/ietf/ietf_attr_default_pwd_enabled.c
src/libimcv/ietf/ietf_attr_default_pwd_enabled.h
src/libimcv/ietf/ietf_attr_fwd_enabled.c
src/libimcv/ietf/ietf_attr_fwd_enabled.h
src/libimcv/ietf/ietf_attr_installed_packages.c
src/libimcv/ietf/ietf_attr_installed_packages.h
src/libimcv/ietf/ietf_attr_numeric_version.c
src/libimcv/ietf/ietf_attr_numeric_version.h
src/libimcv/ietf/ietf_attr_op_status.c
src/libimcv/ietf/ietf_attr_op_status.h
src/libimcv/ietf/ietf_attr_pa_tnc_error.c
src/libimcv/ietf/ietf_attr_pa_tnc_error.h
src/libimcv/ietf/ietf_attr_port_filter.c
src/libimcv/ietf/ietf_attr_port_filter.h
src/libimcv/ietf/ietf_attr_product_info.c
src/libimcv/ietf/ietf_attr_product_info.h
src/libimcv/ietf/ietf_attr_remediation_instr.c
src/libimcv/ietf/ietf_attr_remediation_instr.h
src/libimcv/ietf/ietf_attr_string_version.c
src/libimcv/ietf/ietf_attr_string_version.h
src/libimcv/ita/ita_attr.c
src/libimcv/ita/ita_attr.h
src/libimcv/ita/ita_attr_angel.c
src/libimcv/ita/ita_attr_angel.h
src/libimcv/ita/ita_attr_command.c
src/libimcv/ita/ita_attr_command.h
src/libimcv/ita/ita_attr_device_id.c
src/libimcv/ita/ita_attr_device_id.h
src/libimcv/ita/ita_attr_dummy.c
src/libimcv/ita/ita_attr_dummy.h
src/libimcv/ita/ita_attr_get_settings.c
src/libimcv/ita/ita_attr_get_settings.h
src/libimcv/ita/ita_attr_settings.c
src/libimcv/ita/ita_attr_settings.h
src/libimcv/pa_tnc/pa_tnc_attr_manager.c
src/libimcv/pa_tnc/pa_tnc_attr_manager.h
src/libimcv/plugins/imv_attestation/build-database.sh
src/libimcv/tcg/pts/tcg_pts_attr_aik.c
src/libimcv/tcg/pts/tcg_pts_attr_aik.h
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_finish.c
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_finish.h
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_params_req.c
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_params_req.h
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_params_resp.c
src/libimcv/tcg/pts/tcg_pts_attr_dh_nonce_params_resp.h
src/libimcv/tcg/pts/tcg_pts_attr_file_meas.c
src/libimcv/tcg/pts/tcg_pts_attr_file_meas.h
src/libimcv/tcg/pts/tcg_pts_attr_gen_attest_evid.c
src/libimcv/tcg/pts/tcg_pts_attr_gen_attest_evid.h
src/libimcv/tcg/pts/tcg_pts_attr_get_aik.c
src/libimcv/tcg/pts/tcg_pts_attr_get_aik.h
src/libimcv/tcg/pts/tcg_pts_attr_get_tpm_version_info.c
src/libimcv/tcg/pts/tcg_pts_attr_get_tpm_version_info.h
src/libimcv/tcg/pts/tcg_pts_attr_meas_algo.c
src/libimcv/tcg/pts/tcg_pts_attr_meas_algo.h
src/libimcv/tcg/pts/tcg_pts_attr_proto_caps.c
src/libimcv/tcg/pts/tcg_pts_attr_proto_caps.h
src/libimcv/tcg/pts/tcg_pts_attr_req_file_meas.c
src/libimcv/tcg/pts/tcg_pts_attr_req_file_meas.h
src/libimcv/tcg/pts/tcg_pts_attr_req_file_meta.c
src/libimcv/tcg/pts/tcg_pts_attr_req_file_meta.h
src/libimcv/tcg/pts/tcg_pts_attr_req_func_comp_evid.c
src/libimcv/tcg/pts/tcg_pts_attr_req_func_comp_evid.h
src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c
src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.h
src/libimcv/tcg/pts/tcg_pts_attr_simple_evid_final.c
src/libimcv/tcg/pts/tcg_pts_attr_simple_evid_final.h
src/libimcv/tcg/pts/tcg_pts_attr_tpm_version_info.c
src/libimcv/tcg/pts/tcg_pts_attr_tpm_version_info.h
src/libimcv/tcg/pts/tcg_pts_attr_unix_file_meta.c
src/libimcv/tcg/pts/tcg_pts_attr_unix_file_meta.h
src/libimcv/tcg/seg/tcg_seg_attr_max_size.c
src/libimcv/tcg/seg/tcg_seg_attr_max_size.h
src/libimcv/tcg/seg/tcg_seg_attr_next_seg.c
src/libimcv/tcg/seg/tcg_seg_attr_next_seg.h
src/libimcv/tcg/seg/tcg_seg_attr_seg_env.c
src/libimcv/tcg/seg/tcg_seg_attr_seg_env.h
src/libimcv/tcg/swid/tcg_swid_attr_req.c
src/libimcv/tcg/swid/tcg_swid_attr_req.h
src/libimcv/tcg/swid/tcg_swid_attr_tag_id_inv.c
src/libimcv/tcg/swid/tcg_swid_attr_tag_id_inv.h
src/libimcv/tcg/swid/tcg_swid_attr_tag_inv.c
src/libimcv/tcg/swid/tcg_swid_attr_tag_inv.h
src/libimcv/tcg/tcg_attr.c
src/libimcv/tcg/tcg_attr.h

index 2f38198..67269af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -47,34 +47,35 @@ ENUM(ietf_attr_names, IETF_ATTR_TESTING, IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED,
 /**
  * See header
  */
-pa_tnc_attr_t* ietf_attr_create_from_data(u_int32_t type, chunk_t value)
+pa_tnc_attr_t* ietf_attr_create_from_data(u_int32_t type, size_t length,
+                                                                                 chunk_t value)
 {
        switch (type)
        {
                case IETF_ATTR_ATTRIBUTE_REQUEST:
-                       return ietf_attr_attr_request_create_from_data(value);
+                       return ietf_attr_attr_request_create_from_data(length, value);
                case IETF_ATTR_PRODUCT_INFORMATION:
-                       return ietf_attr_product_info_create_from_data(value);
+                       return ietf_attr_product_info_create_from_data(length, value);
                case IETF_ATTR_NUMERIC_VERSION:
-                       return ietf_attr_numeric_version_create_from_data(value);
+                       return ietf_attr_numeric_version_create_from_data(length, value);
                case IETF_ATTR_STRING_VERSION:
-                       return ietf_attr_string_version_create_from_data(value);
+                       return ietf_attr_string_version_create_from_data(length, value);
                case IETF_ATTR_OPERATIONAL_STATUS:
-                       return ietf_attr_op_status_create_from_data(value);
+                       return ietf_attr_op_status_create_from_data(length, value);
                case IETF_ATTR_PORT_FILTER:
-                       return ietf_attr_port_filter_create_from_data(value);
+                       return ietf_attr_port_filter_create_from_data(length, value);
                case IETF_ATTR_INSTALLED_PACKAGES:
-                       return ietf_attr_installed_packages_create_from_data(value);
+                       return ietf_attr_installed_packages_create_from_data(length, value);
                case IETF_ATTR_PA_TNC_ERROR:
-                       return ietf_attr_pa_tnc_error_create_from_data(value);
+                       return ietf_attr_pa_tnc_error_create_from_data(length, value);
                case IETF_ATTR_ASSESSMENT_RESULT:
-                       return ietf_attr_assess_result_create_from_data(value);
+                       return ietf_attr_assess_result_create_from_data(length, value);
                case IETF_ATTR_REMEDIATION_INSTRUCTIONS:
-                       return ietf_attr_remediation_instr_create_from_data(value);
+                       return ietf_attr_remediation_instr_create_from_data(length, value);
                case IETF_ATTR_FORWARDING_ENABLED:
-                       return ietf_attr_fwd_enabled_create_from_data(value);
+                       return ietf_attr_fwd_enabled_create_from_data(length, value);
                case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
-                       return ietf_attr_default_pwd_enabled_create_from_data(value);
+                       return ietf_attr_default_pwd_enabled_create_from_data(length, value);
                case IETF_ATTR_TESTING:
                case IETF_ATTR_RESERVED:
                default:
index d22175d..169ed78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -56,8 +56,10 @@ extern enum_name_t *ietf_attr_names;
  * Create an IETF PA-TNC attribute from data
  *
  * @param type                         attribute type
- * @param value                                attribute value
+ * @param length                       attribute length
+ * @param value                                attribute value or segment
  */
-pa_tnc_attr_t* ietf_attr_create_from_data(u_int32_t type, chunk_t value);
+pa_tnc_attr_t* ietf_attr_create_from_data(u_int32_t type, size_t length,
+                                                                                 chunk_t value);
 
 #endif /** IETF_ATTR_H_ @}*/
index 55226e3..f3b24f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -50,7 +50,12 @@ struct private_ietf_attr_assess_result_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -107,6 +112,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer = bio_writer_create(ASSESS_RESULT_SIZE);
        writer->write_uint32(writer, this->result);
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -115,10 +121,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
 {
        bio_reader_t *reader;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < ASSESS_RESULT_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF assessment result");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -183,7 +194,8 @@ pa_tnc_attr_t *ietf_attr_assess_result_create(u_int32_t result)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_assess_result_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_assess_result_create_from_data(size_t length,
+                                                                                                               chunk_t data)
 {
        private_ietf_attr_assess_result_t *this;
 
@@ -202,6 +214,7 @@ pa_tnc_attr_t *ietf_attr_assess_result_create_from_data(chunk_t data)
                        .get_result = _get_result,
                },
                .type = { PEN_IETF, IETF_ATTR_ASSESSMENT_RESULT },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index e94b57b..b1a5166 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -56,8 +56,10 @@ pa_tnc_attr_t* ietf_attr_assess_result_create(u_int32_t result);
 /**
  * Creates an ietf_attr_assess_result_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_assess_result_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_assess_result_create_from_data(size_t length,
+                                                                                                               chunk_t value);
 
 #endif /** IETF_ATTR_ASSESS_RESULT_H_ @}*/
index 3b4fd26..e1047aa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -59,7 +59,12 @@ struct private_ietf_attr_attr_request_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -126,6 +131,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -150,11 +156,17 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int8_t reserved;
        int count;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
+
        count = this->value.len / ATTR_REQUEST_ENTRY_SIZE;
        if (this->value.len != ATTR_REQUEST_ENTRY_SIZE * count)
        {
                DBG1(DBG_TNC, "incorrect attribute length for IETF attribute request");
-               *offset = 0;
                return FAILED;
        }
 
@@ -246,7 +258,8 @@ pa_tnc_attr_t *ietf_attr_attr_request_create(pen_t vendor_id, u_int32_t type)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_attr_request_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_attr_request_create_from_data(size_t length,
+                                                                                                          chunk_t data)
 {
        private_ietf_attr_attr_request_t *this;
 
@@ -266,6 +279,7 @@ pa_tnc_attr_t *ietf_attr_attr_request_create_from_data(chunk_t data)
                        .create_enumerator = _create_enumerator,
                },
                .type = { PEN_IETF, IETF_ATTR_ATTRIBUTE_REQUEST },
+               .length = length,
                .value = chunk_clone(data),
                .list = linked_list_create(),
                .ref = 1,
index fc9e086..47b0386 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -62,10 +62,10 @@ struct ietf_attr_attr_request_t {
 pa_tnc_attr_t* ietf_attr_attr_request_create(pen_t vendor_id, u_int32_t type);
 
 /**
- * Creates an ietf_attr_attr_request_t object from received data
- *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_attr_request_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_attr_request_create_from_data(size_t length,
+                                                                                                          chunk_t value);
 
 #endif /** IETF_ATTR_ATTR_REQUEST_H_ @}*/
index 2c6b3d5..11a502a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -50,7 +50,12 @@ struct private_ietf_attr_default_pwd_enabled_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -107,6 +112,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32(writer, this->status);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -118,6 +124,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len != DEFAULT_PWD_ENABLED_SIZE)
        {
                DBG1(DBG_TNC, "incorrect size for IETF factory default password "
@@ -194,7 +204,8 @@ pa_tnc_attr_t *ietf_attr_default_pwd_enabled_create(bool status)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_default_pwd_enabled_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_default_pwd_enabled_create_from_data(size_t length,
+                                                                                                                         chunk_t data)
 {
        private_ietf_attr_default_pwd_enabled_t *this;
 
@@ -213,6 +224,7 @@ pa_tnc_attr_t *ietf_attr_default_pwd_enabled_create_from_data(chunk_t data)
                        .get_status = _get_status,
                },
                .type = { PEN_IETF, IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 6fe1a02..3999590 100644 (file)
@@ -56,8 +56,10 @@ pa_tnc_attr_t* ietf_attr_default_pwd_enabled_create(bool status);
 /**
  * Creates an ietf_attr_default_pwd_enabled_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_default_pwd_enabled_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_default_pwd_enabled_create_from_data(size_t length,
+                                                                                                                         chunk_t value);
 
 #endif /** IETF_ATTR_PWD_ENABLED_H_ @}*/
index a906b22..18c19ae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -50,7 +50,12 @@ struct private_ietf_attr_fwd_enabled_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -107,6 +112,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32(writer, this->fwd_status);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -118,6 +124,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len != FORWARDING_ENABLED_SIZE)
        {
                DBG1(DBG_TNC, "incorrect size for IETF forwarding enabled attribute");
@@ -193,7 +203,8 @@ pa_tnc_attr_t *ietf_attr_fwd_enabled_create(os_fwd_status_t fwd_status)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_fwd_enabled_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_fwd_enabled_create_from_data(size_t length,
+                                                                                                         chunk_t data)
 {
        private_ietf_attr_fwd_enabled_t *this;
 
@@ -212,6 +223,7 @@ pa_tnc_attr_t *ietf_attr_fwd_enabled_create_from_data(chunk_t data)
                        .get_status = _get_status,
                },
                .type = { PEN_IETF, IETF_ATTR_FORWARDING_ENABLED },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 4171438..c4b6c15 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-14 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -57,8 +57,10 @@ pa_tnc_attr_t* ietf_attr_fwd_enabled_create(os_fwd_status_t fwd_status);
 /**
  * Creates an ietf_attr_fwd_enabled_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_fwd_enabled_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_fwd_enabled_create_from_data(size_t length,
+                                                                                                         chunk_t value);
 
 #endif /** IETF_ATTR_FWD_ENABLED_H_ @}*/
index f33f643..2f37e4f 100644 (file)
@@ -57,7 +57,12 @@ struct private_ietf_attr_installed_packages_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -143,6 +148,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -158,6 +164,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < IETF_INSTALLED_PACKAGES_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF installed packages");
@@ -300,9 +310,11 @@ pa_tnc_attr_t *ietf_attr_installed_packages_create(void)
 }
 
 /**
- * Described in header.
+ * Described in header.                .length = length,
+
  */
-pa_tnc_attr_t *ietf_attr_installed_packages_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_installed_packages_create_from_data(size_t length,
+                                                                                                                        chunk_t data)
 {
        private_ietf_attr_installed_packages_t *this;
 
@@ -322,6 +334,7 @@ pa_tnc_attr_t *ietf_attr_installed_packages_create_from_data(chunk_t data)
                        .create_enumerator = _create_enumerator,
                },
                .type = {PEN_IETF, IETF_ATTR_INSTALLED_PACKAGES },
+               .length = length,
                .value = chunk_clone(data),
                .packages = linked_list_create(),
                .ref = 1,
index e19d0f4..28fba38 100644 (file)
@@ -67,8 +67,10 @@ pa_tnc_attr_t* ietf_attr_installed_packages_create(void);
 /**
  * Creates an ietf_attr_installed_packages_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_installed_packages_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_installed_packages_create_from_data(size_t length,
+                                                                                                                        chunk_t value);
 
 #endif /** IETF_ATTR_INSTALLED_PACKAGES_H_ @}*/
index 7392564..3e87887 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -56,7 +56,12 @@ struct private_ietf_attr_numeric_version_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -138,6 +143,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint16(writer, this->service_pack_minor);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -146,10 +152,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
 {
        bio_reader_t *reader;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < NUMERIC_VERSION_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF numeric version");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -253,7 +264,8 @@ pa_tnc_attr_t *ietf_attr_numeric_version_create(u_int32_t major, u_int32_t minor
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_numeric_version_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_numeric_version_create_from_data(size_t length,
+                                                                                                                 chunk_t data)
 {
        private_ietf_attr_numeric_version_t *this;
 
@@ -274,6 +286,7 @@ pa_tnc_attr_t *ietf_attr_numeric_version_create_from_data(chunk_t data)
                        .get_service_pack = _get_service_pack,
                },
                .type = { PEN_IETF, IETF_ATTR_NUMERIC_VERSION },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index bbda6b8..34393c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-14 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -77,8 +77,10 @@ pa_tnc_attr_t* ietf_attr_numeric_version_create(u_int32_t major, u_int32_t minor
 /**
  * Creates an ietf_attr_numeric_version_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_numeric_version_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_numeric_version_create_from_data(size_t length,
+                                                                                                                 chunk_t value);
 
 #endif /** IETF_ATTR_NUMERIC_VERSION_H_ @}*/
index 2353068..e788ff6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -76,7 +76,12 @@ struct private_ietf_attr_op_status_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -154,6 +159,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data  (writer, chunk_create(last_use, 20));
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -167,6 +173,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len != OP_STATUS_SIZE)
        {
                DBG1(DBG_TNC, "incorrect size for IETF operational status");
@@ -284,7 +294,7 @@ pa_tnc_attr_t *ietf_attr_op_status_create(u_int8_t status, u_int8_t result,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_op_status_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_op_status_create_from_data(size_t length, chunk_t data)
 {
        private_ietf_attr_op_status_t *this;
 
index b70fab6..f19185f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-14 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -100,8 +100,10 @@ pa_tnc_attr_t* ietf_attr_op_status_create(u_int8_t status, u_int8_t result,
 /**
  * Creates an ietf_attr_op_status_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_op_status_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_op_status_create_from_data(size_t length,
+                                                                                                       chunk_t value);
 
 #endif /** IETF_ATTR_OP_STATUS_H_ @}*/
index f299df2..9c7ef48 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -113,7 +113,12 @@ struct private_ietf_attr_pa_tnc_error_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -214,6 +219,7 @@ METHOD(pa_tnc_attr_t, build, void,
                }
        }
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -224,10 +230,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        uint8_t reserved;
        uint32_t vendor_id, type;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PA_ERROR_HEADER_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PA-TNC error header");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -417,11 +428,13 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_from_data(size_t length,
+                                                                                                          chunk_t data)
 {
        private_ietf_attr_pa_tnc_error_t *this;
 
        this = create_generic();
+       this->length = length;
        this->value = chunk_clone(data);
 
        return &this->public.pa_tnc_attribute;
index 47588d5..b1df194 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -120,8 +120,10 @@ pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
 /**
  * Creates an ietf_attr_pa_tnc_error_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_from_data(size_t length,
+                                                                                                          chunk_t value);
 
 #endif /** IETF_ATTR_PA_TNC_ERROR_H_ @}*/
index 1d516a5..2b026d7 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2014 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -63,7 +64,12 @@ struct private_ietf_attr_port_filter_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -131,6 +137,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -141,11 +148,16 @@ METHOD(pa_tnc_attr_t, process, status_t,
        port_entry_t *entry;
        u_int8_t blocked;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len % PORT_FILTER_ENTRY_SIZE)
        {
                DBG1(DBG_TNC, "ietf port filter attribute value is not a multiple of %d",
                         PORT_FILTER_ENTRY_SIZE);
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -248,7 +260,8 @@ pa_tnc_attr_t *ietf_attr_port_filter_create(void)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_port_filter_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_port_filter_create_from_data(size_t length,
+                                                                                                         chunk_t data)
 {
        private_ietf_attr_port_filter_t *this;
 
@@ -268,6 +281,7 @@ pa_tnc_attr_t *ietf_attr_port_filter_create_from_data(chunk_t data)
                        .create_port_enumerator = _create_port_enumerator,
                },
                .type = {PEN_IETF, IETF_ATTR_PORT_FILTER },
+               .length = length,
                .value = chunk_clone(data),
                .ports = linked_list_create(),
                .ref = 1,
index 93b696e..d383b19 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -67,8 +67,10 @@ pa_tnc_attr_t* ietf_attr_port_filter_create(void);
 /**
  * Creates an ietf_attr_port_filter_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_port_filter_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_port_filter_create_from_data(size_t length,
+                                                                                                         chunk_t value);
 
 #endif /** IETF_ATTR_PORT_FILTER_H_ @}*/
index a107c27..f1ff1c8 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2014 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -51,7 +52,12 @@ struct private_ietf_attr_product_info_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -120,6 +126,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data  (writer, this->product_name);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -129,10 +136,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        chunk_t product_name;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PRODUCT_INFO_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF product information");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -220,7 +232,8 @@ pa_tnc_attr_t *ietf_attr_product_info_create(pen_t vendor_id, u_int16_t id,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_product_info_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_product_info_create_from_data(size_t length,
+                                                                                                          chunk_t data)
 {
        private_ietf_attr_product_info_t *this;
 
@@ -239,6 +252,7 @@ pa_tnc_attr_t *ietf_attr_product_info_create_from_data(chunk_t data)
                        .get_info = _get_info,
                },
                .type = { PEN_IETF, IETF_ATTR_PRODUCT_INFORMATION },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index d0b2d2a..5151b58 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -60,8 +60,10 @@ pa_tnc_attr_t* ietf_attr_product_info_create(pen_t vendor_id, u_int16_t id,
 /**
  * Creates an ietf_attr_product_info_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_product_info_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_product_info_create_from_data(size_t length,
+                                                                                                          chunk_t value);
 
 #endif /** IETF_ATTR_PRODUCT_INFO_H_ @}*/
index 5d85e5d..0f5fba7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -79,7 +79,12 @@ struct private_ietf_attr_remediation_instr_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -155,6 +160,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data  (writer, this->parameters);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -168,6 +174,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < REMEDIATION_INSTR_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF remediation instructions");
@@ -328,7 +338,8 @@ pa_tnc_attr_t *ietf_attr_remediation_instr_create_from_string(chunk_t string,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_remediation_instr_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_remediation_instr_create_from_data(size_t length,
+                                                                                                                       chunk_t data)
 {
        private_ietf_attr_remediation_instr_t *this;
 
@@ -350,6 +361,7 @@ pa_tnc_attr_t *ietf_attr_remediation_instr_create_from_data(chunk_t data)
                        .get_string = _get_string,
                },
                .type = { PEN_IETF, IETF_ATTR_REMEDIATION_INSTRUCTIONS },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 5c7c889..bc03e99 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -102,8 +102,10 @@ pa_tnc_attr_t* ietf_attr_remediation_instr_create_from_string(chunk_t string,
 /**
  * Creates an ietf_attr_remediation_instr_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_remediation_instr_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_remediation_instr_create_from_data(size_t length,
+                                                                                                                       chunk_t value);
 
 #endif /** IETF_ATTR_REMEDIATION_INSTR_H_ @}*/
index 68adde6..5bd17c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,7 +54,12 @@ struct private_ietf_attr_string_version_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -124,6 +129,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data8(writer, this->config);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -137,6 +143,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
 
        *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < STRING_VERSION_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for IETF string version");
@@ -272,7 +282,8 @@ pa_tnc_attr_t *ietf_attr_string_version_create(chunk_t version, chunk_t build,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ietf_attr_string_version_create_from_data(chunk_t data)
+pa_tnc_attr_t *ietf_attr_string_version_create_from_data(size_t length,
+                                                                                                                chunk_t data)
 {
        private_ietf_attr_string_version_t *this;
 
@@ -291,6 +302,7 @@ pa_tnc_attr_t *ietf_attr_string_version_create_from_data(chunk_t data)
                        .get_version = _get_version,
                },
                .type = { PEN_IETF, IETF_ATTR_STRING_VERSION },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 9ccc1f0..432ed4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -60,8 +60,10 @@ pa_tnc_attr_t* ietf_attr_string_version_create(chunk_t version, chunk_t build,
 /**
  * Creates an ietf_attr_string_version_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ietf_attr_string_version_create_from_data(chunk_t value);
+pa_tnc_attr_t* ietf_attr_string_version_create_from_data(size_t length,
+                                                                                                                chunk_t value);
 
 #endif /** IETF_ATTR_STRING_VERSION_H_ @}*/
index f395671..9d7706d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -35,24 +35,25 @@ ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_DEVICE_ID,
 /**
  * See header
  */
-pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, chunk_t value)
+pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, size_t length,
+                                                                                chunk_t value)
 {
        switch (type)
        {
                case ITA_ATTR_COMMAND:
-                       return ita_attr_command_create_from_data(value);
+                       return ita_attr_command_create_from_data(length, value);
                case ITA_ATTR_DUMMY:
-                       return ita_attr_dummy_create_from_data(value);
+                       return ita_attr_dummy_create_from_data(length, value);
                case ITA_ATTR_GET_SETTINGS:
-                       return ita_attr_get_settings_create_from_data(value);
+                       return ita_attr_get_settings_create_from_data(length, value);
                case ITA_ATTR_SETTINGS:
-                       return ita_attr_settings_create_from_data(value);
+                       return ita_attr_settings_create_from_data(length, value);
                case ITA_ATTR_START_ANGEL:
-                       return ita_attr_angel_create_from_data(TRUE, value);
+                       return ita_attr_angel_create_from_data(TRUE);
                case ITA_ATTR_STOP_ANGEL:
-                       return ita_attr_angel_create_from_data(FALSE, value);
+                       return ita_attr_angel_create_from_data(FALSE);
                case ITA_ATTR_DEVICE_ID:
-                       return ita_attr_device_id_create_from_data(value);
+                       return ita_attr_device_id_create_from_data(length, value);
                default:
                        return NULL;
        }
index ac5d8ab..7378a1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -50,8 +50,10 @@ extern enum_name_t *ita_attr_names;
  * Create a ITA PA-TNC attribute from data
  *
  * @param type                         attribute type
- * @param value                                attribute value
+ * @param length                       attribute length
+ * @param value                                attribute value or segment
  */
-pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, chunk_t value);
+pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, size_t length,
+                                                                                chunk_t value);
 
 #endif /** ITA_ATTR_H_ @}*/
index 0e9cff0..ccedc1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -132,7 +132,7 @@ pa_tnc_attr_t *ita_attr_angel_create(bool start)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start, chunk_t data)
+pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start)
 {
        private_ita_attr_angel_t *this;
 
index d42e711..8cd979b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -49,8 +49,7 @@ pa_tnc_attr_t* ita_attr_angel_create(bool start);
  * Creates an ita_attr_angel_t object from received data
  *
  * @param start                                TRUE for Start, FALSE for Stop Angel attribute
- * @param value                                binary value blob
  */
-pa_tnc_attr_t* ita_attr_angel_create_from_data(bool start, chunk_t value);
+pa_tnc_attr_t* ita_attr_angel_create_from_data(bool start);
 
 #endif /** ITA_ATTR_ANGEL_H_ @}*/
index 08a9efa..679f2c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -40,7 +40,12 @@ struct private_ita_attr_command_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -92,11 +97,18 @@ METHOD(pa_tnc_attr_t, build, void,
                return;
        }
        this->value = chunk_clone(chunk_from_str(this->command));
+       this->length = this->value.len;
 }
 
 METHOD(pa_tnc_attr_t, process, status_t,
        private_ita_attr_command_t *this, u_int32_t *offset)
 {
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        this->command = strndup(this->value.ptr, this->value.len);
 
        return SUCCESS;
@@ -158,7 +170,7 @@ pa_tnc_attr_t *ita_attr_command_create(char *command)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_command_create_from_data(size_t length, chunk_t data)
 {
        private_ita_attr_command_t *this;
 
@@ -177,6 +189,7 @@ pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
                        .get_command = _get_command,
                },
                .type = {PEN_ITA, ITA_ATTR_COMMAND },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 3926c38..dd4701e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,8 +54,9 @@ pa_tnc_attr_t* ita_attr_command_create(char *command);
 /**
  * Creates an ita_attr_command_t object from received data
  *
- * @param value                                binary value blob
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ita_attr_command_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_command_create_from_data(size_t length, chunk_t value);
 
 #endif /** ITA_ATTR_COMMAND_H_ @}*/
index 36907eb..885feeb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Andreas Steffen
+ * Copyright (C) 2013-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -38,7 +38,12 @@ struct private_ita_attr_device_id_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -86,6 +91,12 @@ METHOD(pa_tnc_attr_t, build, void,
 METHOD(pa_tnc_attr_t, process, status_t,
        private_ita_attr_device_id_t *this, u_int32_t *offset)
 {
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        return SUCCESS;
 }
 
@@ -109,7 +120,7 @@ METHOD(pa_tnc_attr_t, destroy, void,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
+pa_tnc_attr_t *ita_attr_device_id_create_from_data(size_t length, chunk_t value)
 {
        private_ita_attr_device_id_t *this;
 
@@ -127,6 +138,7 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
                        },
                },
                .type = { PEN_ITA, ITA_ATTR_DEVICE_ID },
+               .length = length,
                .value = chunk_clone(value),
                .ref = 1,
        );
@@ -139,6 +151,6 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
  */
 pa_tnc_attr_t *ita_attr_device_id_create(chunk_t value)
 {
-       return ita_attr_device_id_create_from_data(value);
+       return ita_attr_device_id_create_from_data(value.len, value);
 }
 
index ffacdba..94bb778 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Andreas Steffen
+ * Copyright (C) 2013-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -48,8 +48,9 @@ pa_tnc_attr_t* ita_attr_device_id_create(chunk_t value);
 /**
  * Creates an ita_attr_device_id_t object from received data
  *
- * @param value                                binary value blob
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ita_attr_device_id_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_device_id_create_from_data(size_t length, chunk_t value);
 
 #endif /** ITA_ATTR_DEVICE_ID_H_ @}*/
index 6497d46..890dfcb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -38,7 +38,12 @@ struct private_ita_attr_dummy_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -89,15 +94,19 @@ METHOD(pa_tnc_attr_t, build, void,
        {
                return;
        }
-       this->value = chunk_alloc(this->size);
+       this->value = chunk_alloc(this->length);
        memset(this->value.ptr, 0xdd, this->value.len);
 }
 
 METHOD(pa_tnc_attr_t, process, status_t,
        private_ita_attr_dummy_t *this, u_int32_t *offset)
 {
-       this->size = this->value.len;
+       *offset = 0;
 
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        return SUCCESS;
 }
 
@@ -121,13 +130,13 @@ METHOD(pa_tnc_attr_t, destroy, void,
 METHOD(ita_attr_dummy_t, get_size, int,
        private_ita_attr_dummy_t *this)
 {
-       return this->size;
+       return this->length;
 }
 
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_dummy_create(int size)
+pa_tnc_attr_t *ita_attr_dummy_create(size_t size)
 {
        private_ita_attr_dummy_t *this;
 
@@ -146,7 +155,7 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
                        .get_size = _get_size,
                },
                .type = { PEN_ITA, ITA_ATTR_DUMMY },
-               .size = size,
+               .length = size,
                .ref = 1,
        );
 
@@ -156,7 +165,7 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_dummy_create_from_data(size_t length, chunk_t data)
 {
        private_ita_attr_dummy_t *this;
 
@@ -175,6 +184,7 @@ pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
                        .get_size = _get_size,
                },
                .type = { PEN_ITA, ITA_ATTR_DUMMY },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 1f85ece..717862e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -49,13 +49,14 @@ struct ita_attr_dummy_t {
  *
  * @param size                         size of dummy attribute value
  */
-pa_tnc_attr_t* ita_attr_dummy_create(int size);
+pa_tnc_attr_t* ita_attr_dummy_create(size_t size);
 
 /**
  * Creates an ita_attr_dummy_t object from received data
  *
- * @param value                                binary value blob
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ita_attr_dummy_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_dummy_create_from_data(size_t length, chunk_t value);
 
 #endif /** ITA_ATTR_DUMMY_H_ @}*/
index d0bc31d..b9a4ab2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -64,7 +64,12 @@ struct private_ita_attr_get_settings_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -130,6 +135,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -141,10 +147,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        chunk_t name;
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < ITA_GET_SETTINGS_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for ITA Get Settings attribute");
-               *offset = 0;
                return FAILED;
        }
 
@@ -238,7 +249,8 @@ pa_tnc_attr_t *ita_attr_get_settings_create(char *name)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_get_settings_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_get_settings_create_from_data(size_t length,
+                                                                                                         chunk_t data)
 {
        private_ita_attr_get_settings_t *this;
 
@@ -258,6 +270,7 @@ pa_tnc_attr_t *ita_attr_get_settings_create_from_data(chunk_t data)
                        .create_enumerator = _create_enumerator,
                },
                .type = { PEN_ITA, ITA_ATTR_GET_SETTINGS },
+               .length = length,
                .value = chunk_clone(data),
                .list = linked_list_create(),
                .ref = 1,
index 975fd0d..2eb43f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -61,8 +61,10 @@ pa_tnc_attr_t* ita_attr_get_settings_create(char *name);
 /**
  * Creates an ita_attr_get_settings_t object from received data
  *
- * @param value                                binary value blob
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ita_attr_get_settings_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_get_settings_create_from_data(size_t length,
+                                                                                                         chunk_t value);
 
 #endif /** ITA_ATTR_GET_SETTINGS_H_ @}*/
index 0d2967e..8f72056 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -91,7 +91,12 @@ struct private_ita_attr_settings_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -159,6 +164,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -171,10 +177,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        entry_t *entry;
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < ITA_SETTINGS_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for ITA Settings attribute");
-               *offset = 0;
                return FAILED;
        }
 
@@ -296,7 +307,7 @@ pa_tnc_attr_t *ita_attr_settings_create(void)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *ita_attr_settings_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_settings_create_from_data(size_t length, chunk_t data)
 {
        private_ita_attr_settings_t *this;
 
@@ -316,6 +327,7 @@ pa_tnc_attr_t *ita_attr_settings_create_from_data(chunk_t data)
                        .create_enumerator = _create_enumerator,
                },
                .type = { PEN_ITA, ITA_ATTR_SETTINGS },
+               .length = length,
                .value = chunk_clone(data),
                .list = linked_list_create(),
                .ref = 1,
index eb7eeda..87eb87f 100644 (file)
@@ -60,8 +60,9 @@ pa_tnc_attr_t* ita_attr_settings_create(void);
 /**
  * Creates an ita_attr_settings_t object from received data
  *
- * @param value                                binary value blob
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* ita_attr_settings_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_settings_create_from_data(size_t length, chunk_t value);
 
 #endif /** ITA_ATTR_SETTINGS_H_ @}*/
index 7fae9a9..71f294d 100644 (file)
@@ -176,8 +176,9 @@ METHOD(pa_tnc_attr_manager_t, create, pa_tnc_attr_t*,
                                                msg_info, *offset + PA_TNC_ATTR_INFO_SIZE);
                return NULL;
        }
+       length -= PA_TNC_ATTR_HEADER_SIZE;
 
-       if (!reader->read_data(reader, length - PA_TNC_ATTR_HEADER_SIZE, &value))
+       if (!reader->read_data(reader, length, &value))
        {
                DBG1(DBG_TNC, "insufficient bytes for PA-TNC attribute value");
                *error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
@@ -207,7 +208,7 @@ METHOD(pa_tnc_attr_manager_t, create, pa_tnc_attr_t*,
                {
                        if (entry->attr_create)
                        {
-                               attr = entry->attr_create(type, value);
+                               attr = entry->attr_create(type, length, value);
                        }
                        break;
                }
index 0709c5b..c38face 100644 (file)
@@ -28,7 +28,8 @@ typedef struct pa_tnc_attr_manager_t pa_tnc_attr_manager_t;
 #include <library.h>
 #include <bio/bio_reader.h>
 
-typedef pa_tnc_attr_t* (*pa_tnc_attr_create_t)(u_int32_t type, chunk_t value);
+typedef pa_tnc_attr_t* (*pa_tnc_attr_create_t)(u_int32_t type, size_t length,
+                                                                                          chunk_t value);
 
 /**
  * Manages PA-TNC attributes for arbitrary PENs
index 980de47..080417b 100755 (executable)
@@ -2,7 +2,7 @@
 
 p="Ubuntu 14.04 x86_64"
 a="x86_64-linux-gnu"
-k="3.13.0-34-generic"
+k="3.13.0-36-generic"
 
 for hash in sha1 sha256
 do
index 17a8db5..ad1ad7e 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,7 +55,12 @@ struct private_tcg_pts_attr_aik_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -124,6 +130,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint8(writer, flags);
        writer->write_data (writer, aik_blob);
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
        free(aik_blob.ptr);
 }
@@ -136,10 +143,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        certificate_type_t type;
        chunk_t aik_blob;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_AIK_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Attestation Identity Key");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -218,7 +230,7 @@ pa_tnc_attr_t *tcg_pts_attr_aik_create(certificate_t *aik)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_aik_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_aik_create_from_data(size_t length, chunk_t data)
 {
        private_tcg_pts_attr_aik_t *this;
 
@@ -237,6 +249,7 @@ pa_tnc_attr_t *tcg_pts_attr_aik_create_from_data(chunk_t data)
                        .get_aik = _get_aik,
                },
                .type = { PEN_TCG, TCG_PTS_AIK },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 0962432..b524ff3 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -58,8 +59,9 @@ pa_tnc_attr_t* tcg_pts_attr_aik_create(certificate_t *aik);
 /**
  * Creates an tcg_pts_attr_aik_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_aik_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_aik_create_from_data(size_t length, chunk_t value);
 
 #endif /** TCG_PTS_ATTR_AIK_H_ @}*/
index 6119b49..8a09720 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -58,7 +59,12 @@ struct private_tcg_pts_attr_dh_nonce_finish_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -129,6 +135,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data  (writer, this->initiator_nonce);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -139,10 +146,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int8_t reserved, nonce_len;
        u_int16_t hash_algo;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_DH_NONCE_FINISH_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Finish");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -236,7 +248,8 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create(
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value)
+pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create_from_data(size_t length,
+                                                                                                                        chunk_t value)
 {
        private_tcg_pts_attr_dh_nonce_finish_t *this;
 
@@ -257,6 +270,7 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value)
                        .get_initiator_value = _get_initiator_value,
                },
                .type = { PEN_TCG, TCG_PTS_DH_NONCE_FINISH },
+               .length = length,
                .value = chunk_clone(value),
                .ref = 1,
        );
index efe6fd1..78b5025 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -82,8 +83,10 @@ pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create(
 /**
  * Creates an tcg_pts_attr_dh_nonce_finish_t object from received data
  *
- * @param value                                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_dh_nonce_finish_create_from_data(size_t length,
+                                                                                                                        chunk_t value);
 
 #endif /** TCG_PTS_ATTR_DH_NONCE_FINISH_H_ @}*/
index 7761b97..6ad3157 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,7 +55,12 @@ struct private_tcg_pts_attr_dh_nonce_params_req_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -118,6 +124,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint16(writer, this->dh_groups);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -128,10 +135,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int8_t reserved;
        u_int16_t dh_groups;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_DH_NONCE_PARAMS_REQ_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Parameters Request");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -208,7 +220,8 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create(u_int8_t min_nonce_len,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create_from_data(chunk_t value)
+pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create_from_data(size_t length,
+                                                                                                                                chunk_t value)
 {
        private_tcg_pts_attr_dh_nonce_params_req_t *this;
 
@@ -228,6 +241,7 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_req_create_from_data(chunk_t value)
                        .get_dh_groups = _get_dh_groups,
                },
                .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_REQ },
+               .length = length,
                .value = chunk_clone(value),
                .ref = 1,
        );
index 024648a..4396bf6 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -65,8 +66,10 @@ pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_req_create(u_int8_t min_nonce_len,
 /**
  * Creates an tcg_pts_attr_dh_nonce_params_req_t object from received data
  *
- * @param value                                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_req_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_req_create_from_data(size_t length,
+                                                                                                                                chunk_t value);
 
 #endif /** TCG_PTS_ATTR_DH_NONCE_PARAMS_REQ_H_ @}*/
index eb0d0e5..9dfc81f 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -60,7 +61,12 @@ struct private_tcg_pts_attr_dh_nonce_params_resp_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -137,6 +143,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data  (writer, this->responder_value);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -148,10 +155,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int8_t nonce_len;
        u_int16_t dh_group, hash_algo_set;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_DH_NONCE_PARAMS_RESP_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS DH Nonce Parameters Response");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -254,7 +266,8 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value)
+pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create_from_data(size_t length,
+                                                                                                                                 chunk_t value)
 {
        private_tcg_pts_attr_dh_nonce_params_resp_t *this;
 
@@ -276,6 +289,7 @@ pa_tnc_attr_t *tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value)
                        .get_responder_value = _get_responder_value,
                },
                .type = { PEN_TCG, TCG_PTS_DH_NONCE_PARAMS_RESP },
+               .length = length,
                .value = chunk_clone(value),
                .ref = 1,
        );
index 72046d2..b548a81 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -86,8 +87,10 @@ pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create(pts_dh_group_t dh_group,
 /**
  * Creates an tcg_pts_attr_dh_nonce_params_resp_t object from received data
  *
- * @param value                                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_dh_nonce_params_resp_create_from_data(size_t length,
+                                                                                                                                 chunk_t value);
 
 #endif /** TCG_PTS_ATTR_DH_NONCE_PARAMS_RESP_H_ @}*/
index b9095f5..723f8f5 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -69,7 +70,12 @@ struct private_tcg_pts_attr_file_meas_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -155,6 +161,7 @@ METHOD(pa_tnc_attr_t, build, void,
        }
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -169,10 +176,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        char buf[BUF_LEN];
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_FILE_MEAS_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS file measurement header");
-               *offset = 0;
                return FAILED;
        }
 
@@ -268,7 +280,8 @@ pa_tnc_attr_t *tcg_pts_attr_file_meas_create(pts_file_meas_t *measurements)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_file_meas_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_file_meas_create_from_data(size_t length,
+                                                                                                          chunk_t data)
 {
        private_tcg_pts_attr_file_meas_t *this;
 
@@ -287,6 +300,7 @@ pa_tnc_attr_t *tcg_pts_attr_file_meas_create_from_data(chunk_t data)
                        .get_measurements = _get_measurements,
                },
                .type = { PEN_TCG, TCG_PTS_FILE_MEAS },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 4f155f0..d399fec 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -58,8 +59,10 @@ pa_tnc_attr_t* tcg_pts_attr_file_meas_create(pts_file_meas_t *measurements);
 /**
  * Creates an tcg_pts_attr_file_meas_t object from received data
  *
- * @param value                                        unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_file_meas_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_file_meas_create_from_data(size_t length,
+                                                                                                          chunk_t value);
 
 #endif /** TCG_PTS_ATTR_FILE_MEAS_H_ @}*/
index f263747..d724819 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -55,7 +56,12 @@ struct private_tcg_pts_attr_gen_attest_evid_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -107,6 +113,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32 (writer, PTS_GEN_ATTEST_EVID_RESERVED);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -116,10 +123,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        u_int32_t reserved;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_GEN_ATTEST_EVID_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Generate Attestation Evidence");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -177,7 +189,8 @@ pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create()
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create_from_data(size_t length,
+                                                                                                                        chunk_t data)
 {
        private_tcg_pts_attr_gen_attest_evid_t *this;
 
@@ -195,6 +208,7 @@ pa_tnc_attr_t *tcg_pts_attr_gen_attest_evid_create_from_data(chunk_t data)
                        },
                },
                .type = { PEN_TCG, TCG_PTS_GEN_ATTEST_EVID },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 38909b0..971abd2 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -46,8 +47,10 @@ pa_tnc_attr_t* tcg_pts_attr_gen_attest_evid_create();
 /**
  * Creates an tcg_pts_attr_gen_attest_evid_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_gen_attest_evid_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_gen_attest_evid_create_from_data(size_t length,
+                                                                                                                        chunk_t value);
 
 #endif /** TCG_PTS_ATTR_GEN_ATTEST_EVID_H_ @}*/
index cf944d2..ed98197 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -52,7 +53,12 @@ struct private_tcg_pts_attr_get_aik_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -104,6 +110,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32 (writer, PTS_GET_AIK_RESERVED);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -113,10 +120,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        u_int32_t reserved;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_GET_AIK_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Get AIK");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -174,7 +186,8 @@ pa_tnc_attr_t *tcg_pts_attr_get_aik_create()
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_get_aik_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_get_aik_create_from_data(size_t length,
+                                                                                                        chunk_t data)
 {
        private_tcg_pts_attr_get_aik_t *this;
 
@@ -192,6 +205,7 @@ pa_tnc_attr_t *tcg_pts_attr_get_aik_create_from_data(chunk_t data)
                        },
                },
                .type = { PEN_TCG, TCG_PTS_GET_AIK },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 120100e..923fd03 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -46,8 +47,10 @@ pa_tnc_attr_t* tcg_pts_attr_get_aik_create();
 /**
  * Creates an tcg_pts_attr_get_aik_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_get_aik_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_get_aik_create_from_data(size_t length,
+                                                                                                        chunk_t value);
 
 #endif /** TCG_PTS_ATTR_GET_AIK_H_ @}*/
index 647c426..c922f2f 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -55,7 +56,12 @@ struct private_tcg_pts_attr_get_tpm_version_info_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -107,6 +113,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32 (writer, PTS_GET_TPM_VER_INFO_RESERVED);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -116,10 +123,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        u_int32_t reserved;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_GET_TPM_VER_INFO_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Get TPM Version Information");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -177,7 +189,8 @@ pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create()
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create_from_data(size_t length,
+                                                                                                                                 chunk_t data)
 {
        private_tcg_pts_attr_get_tpm_version_info_t *this;
 
@@ -195,6 +208,7 @@ pa_tnc_attr_t *tcg_pts_attr_get_tpm_version_info_create_from_data(chunk_t data)
                        },
                },
                .type = { PEN_TCG, TCG_PTS_GET_TPM_VERSION_INFO },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 711a1d5..19fb5a4 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -47,8 +48,10 @@ pa_tnc_attr_t* tcg_pts_attr_get_tpm_version_info_create();
 /**
  * Creates an tcg_pts_attr_get_tpm_version_info_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_get_tpm_version_info_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_get_tpm_version_info_create_from_data(size_t length,
+                                                                                                                                 chunk_t value);
 
 #endif /** TCG_PTS_ATTR_GET_TPM_VERSION_INFO_H_ @}*/
index a4dac90..4445079 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -53,7 +54,12 @@ struct private_tcg_pts_attr_meas_algo_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -110,6 +116,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint16(writer, PTS_MEAS_ALGO_RESERVED);
        writer->write_uint16(writer, this->algorithms);
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -119,10 +126,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        u_int16_t reserved, algorithms;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_MEAS_ALGO_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS Measurement Algorithm");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -192,7 +204,8 @@ pa_tnc_attr_t *tcg_pts_attr_meas_algo_create(pts_meas_algorithms_t algorithms,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(chunk_t data,
+pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(size_t length,
+                                                                                                          chunk_t data,
                                                                                                           bool selection)
 {
        private_tcg_pts_attr_meas_algo_t *this;
@@ -213,6 +226,7 @@ pa_tnc_attr_t *tcg_pts_attr_meas_algo_create_from_data(chunk_t data,
                },
                .type = { PEN_TCG,
                                  selection ? TCG_PTS_MEAS_ALGO_SELECTION : TCG_PTS_MEAS_ALGO },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 88d1be0..bc15a9b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -59,10 +60,12 @@ pa_tnc_attr_t* tcg_pts_attr_meas_algo_create(pts_meas_algorithms_t algorithms,
 /**
  * Creates an tcg_pts_attr_meas_algo_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  * @param selection                    TRUE if a selection
  */
-pa_tnc_attr_t* tcg_pts_attr_meas_algo_create_from_data(chunk_t value,
+pa_tnc_attr_t* tcg_pts_attr_meas_algo_create_from_data(size_t length,
+                                                                                                          chunk_t value,
                                                                                                           bool selection);
 
 #endif /** TCG_PTS_ATTR_MEAS_ALGO_H_ @}*/
index 6473ea8..501e24d 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -52,8 +53,14 @@ struct private_tcg_pts_attr_proto_caps_t {
         */
        pen_type_t type;
 
+
+       /**
+        * Length of attribute value
+        */
+       size_t length;
+
        /**
-        * Attribute value
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -111,6 +118,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint16(writer, this->flags);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -120,10 +128,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        u_int16_t reserved, flags;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_PROTO_CAPS_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS Protocol Capabilities");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -192,7 +205,8 @@ pa_tnc_attr_t *tcg_pts_attr_proto_caps_create(pts_proto_caps_flag_t flags,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_proto_caps_create_from_data(chunk_t data,
+pa_tnc_attr_t *tcg_pts_attr_proto_caps_create_from_data(size_t length,
+                                                                                                               chunk_t data,
                                                                                                                bool request)
 {
        private_tcg_pts_attr_proto_caps_t *this;
@@ -213,6 +227,7 @@ pa_tnc_attr_t *tcg_pts_attr_proto_caps_create_from_data(chunk_t data,
                },
                .type = { PEN_TCG,
                                  request ? TCG_PTS_REQ_PROTO_CAPS : TCG_PTS_PROTO_CAPS },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index c2478da..11ed228 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -58,10 +59,12 @@ pa_tnc_attr_t* tcg_pts_attr_proto_caps_create(pts_proto_caps_flag_t flags,
 /**
  * Creates an tcg_pts_attr_proto_caps_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  * @param request                      TRUE for a PTS protocol capabilities request
  */
-pa_tnc_attr_t* tcg_pts_attr_proto_caps_create_from_data(chunk_t value,
+pa_tnc_attr_t* tcg_pts_attr_proto_caps_create_from_data(size_t length,
+                                                                                                               chunk_t value,
                                                                                                                bool request);
 
 #endif /** TCG_PTS_ATTR_PROTO_CAPS_H_ @}*/
index c5a2f4b..c4d192c 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -62,7 +63,12 @@ struct private_tcg_pts_attr_req_file_meas_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -145,6 +151,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32(writer, this->delimiter);
        writer->write_data  (writer, pathname);
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -156,10 +163,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int8_t reserved;
        chunk_t pathname;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_REQ_FILE_MEAS_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Request File Measurement");
-               *offset = 0;
                return FAILED;
        }
 
@@ -262,7 +274,8 @@ pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create(bool directory_flag,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create_from_data(size_t length,
+                                                                                                                  chunk_t data)
 {
        private_tcg_pts_attr_req_file_meas_t *this;
 
@@ -284,6 +297,7 @@ pa_tnc_attr_t *tcg_pts_attr_req_file_meas_create_from_data(chunk_t data)
                        .get_pathname = _get_pathname,
                },
                .type = { PEN_TCG, TCG_PTS_REQ_FILE_MEAS },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 135c088..20a54df 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -83,8 +84,10 @@ pa_tnc_attr_t* tcg_pts_attr_req_file_meas_create(bool directory_flag,
 /**
  * Creates an tcg_pts_attr_req_file_meas_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meas_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_req_file_meas_create_from_data(size_t length,
+                                                                                                                  chunk_t value);
 
 #endif /** TCG_PTS_ATTR_REQ_FILE_MEAS_H_ @}*/
index 8d703af..dffce9a 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -60,7 +61,12 @@ struct private_tcg_pts_attr_req_file_meta_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -138,6 +144,7 @@ METHOD(pa_tnc_attr_t, build, void,
 
        writer->write_data  (writer, pathname);
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -149,11 +156,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int16_t reserved;
        chunk_t pathname;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_REQ_FILE_META_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Request File Metadata");
-               *offset = 0;
-               return FAILED;
        }
 
        reader = bio_reader_create(this->value);
@@ -246,7 +257,8 @@ pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create(bool directory_flag,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create_from_data(size_t length,
+                                                                                                                  chunk_t data)
 {
        private_tcg_pts_attr_req_file_meta_t *this;
 
@@ -267,6 +279,7 @@ pa_tnc_attr_t *tcg_pts_attr_req_file_meta_create_from_data(chunk_t data)
                        .get_pathname = _get_pathname,
                },
                .type = { PEN_TCG, TCG_PTS_REQ_FILE_META },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 9aa1b93..c2f1cca 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -74,8 +75,10 @@ pa_tnc_attr_t* tcg_pts_attr_req_file_meta_create(bool directory_flag,
 /**
  * Creates an tcg_pts_attr_req_file_meta_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_req_file_meta_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_req_file_meta_create_from_data(size_t length,
+                                                                                                                  chunk_t value);
 
 #endif /** TCG_PTS_ATTR_REQ_FILE_META_H_ @}*/
index e10845b..6069488 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -78,7 +79,12 @@ struct private_tcg_pts_attr_req_func_comp_evid_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -184,6 +190,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -196,11 +203,16 @@ METHOD(pa_tnc_attr_t, process, status_t,
        status_t status = FAILED;
        entry_t *entry = NULL;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_REQ_FUNC_COMP_EVID_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Request Functional "
                                          "Component Evidence");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -337,7 +349,8 @@ pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create(void)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create_from_data(size_t length,
+                                                                                                                               chunk_t data)
 {
        private_tcg_pts_attr_req_func_comp_evid_t *this;
 
@@ -358,6 +371,7 @@ pa_tnc_attr_t *tcg_pts_attr_req_func_comp_evid_create_from_data(chunk_t data)
                        .create_enumerator = _create_enumerator,
                },
                .type = { PEN_TCG, TCG_PTS_REQ_FUNC_COMP_EVID },
+               .length = length,
                .list = linked_list_create(),
                .value = chunk_clone(data),
                .ref = 1,
index 2c0b8a9..2f8657e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -73,8 +74,10 @@ pa_tnc_attr_t* tcg_pts_attr_req_func_comp_evid_create(void);
 /**
  * Creates a tcg_pts_attr_req_func_comp_evid_t object from received data
  *
- * @param value                                Unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_req_func_comp_evid_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_req_func_comp_evid_create_from_data(size_t length,
+                                                                                                                               chunk_t value);
 
 #endif /** TCG_PTS_ATTR_REQ_FUNC_COMP_EVID_H_ @}*/
index 40f380a..189fb0f 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -105,7 +106,12 @@ struct private_tcg_pts_attr_simple_comp_evid_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -243,6 +249,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data(writer, measurement);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -307,11 +314,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bool has_pcr_info = FALSE, has_validation = FALSE;
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_SIMPLE_COMP_EVID_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Simple Component Evidence");
-               *offset = 0;
-               return FAILED;
        }
        reader = bio_reader_create(this->value);
 
@@ -484,7 +495,8 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create(pts_comp_evidence_t *evid)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(size_t length,
+                                                                                                                         chunk_t data)
 {
        private_tcg_pts_attr_simple_comp_evid_t *this;
 
@@ -503,6 +515,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t data)
                        .get_comp_evidence = _get_comp_evidence,
                },
                .type = { PEN_TCG, TCG_PTS_SIMPLE_COMP_EVID },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 628fad6..c08adb8 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -57,8 +58,10 @@ pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create(pts_comp_evidence_t *evid);
 /**
  * Creates an tcg_pts_attr_simple_comp_evid_t object from received data
  *
- * @param value                                        Unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_simple_comp_evid_create_from_data(size_t length,
+                                                                                                                         chunk_t value);
 
 #endif /** TCG_PTS_ATTR_SIMPLE_COMP_EVID_H_ @}*/
index baadd94..119d342 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -63,7 +64,12 @@ struct private_tcg_pts_attr_simple_evid_final_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -195,6 +201,7 @@ METHOD(pa_tnc_attr_t, build, void,
        }
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -207,10 +214,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        u_int32_t pcr_comp_len, tpm_quote_sig_len, evid_sig_len;
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_SIMPLE_EVID_FINAL_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for Simple Evidence Final");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -354,7 +366,8 @@ pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create(u_int8_t flags,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create_from_data(size_t length,
+                                                                                                                          chunk_t data)
 {
        private_tcg_pts_attr_simple_evid_final_t *this;
 
@@ -375,6 +388,7 @@ pa_tnc_attr_t *tcg_pts_attr_simple_evid_final_create_from_data(chunk_t data)
                        .set_evid_sig = _set_evid_sig,
                },
                .type = { PEN_TCG, TCG_PTS_SIMPLE_EVID_FINAL },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 1fac2e1..8343b5b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -86,8 +87,10 @@ pa_tnc_attr_t* tcg_pts_attr_simple_evid_final_create(
 /**
  * Creates an tcg_pts_attr_simple_evid_final_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_simple_evid_final_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_simple_evid_final_create_from_data(size_t length,
+                                                                                                                          chunk_t value);
 
 #endif /** TCG_PTS_ATTR_SIMPLE_EVID_FINAL_H_ @}*/
index b776cb6..5fa4db0 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,7 +55,12 @@ struct private_tcg_pts_attr_tpm_version_info_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -111,6 +117,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_data(writer, this->tpm_version_info);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -119,10 +126,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
 {
        bio_reader_t *reader;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_TPM_VER_INFO_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for TPM Version Information");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -198,7 +210,8 @@ pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create(chunk_t tpm_version_info)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create_from_data(size_t length,
+                                                                                                                         chunk_t data)
 {
        private_tcg_pts_attr_tpm_version_info_t *this;
 
@@ -218,6 +231,7 @@ pa_tnc_attr_t *tcg_pts_attr_tpm_version_info_create_from_data(chunk_t data)
                        .set_tpm_version_info = _set_tpm_version_info,
                },
                .type = { PEN_TCG, TCG_PTS_TPM_VERSION_INFO },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index e03b57f..d87d72b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -63,8 +64,10 @@ pa_tnc_attr_t* tcg_pts_attr_tpm_version_info_create(chunk_t tpm_version_info);
 /**
  * Creates an tcg_pts_attr_tpm_version_info_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_tpm_version_info_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_tpm_version_info_create_from_data(size_t length,
+                                                                                                                         chunk_t value);
 
 #endif /** TCG_PTS_ATTR_TPM_VERSION_INFO_H_ @}*/
index eff64c2..c8c2708 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2011-2012 Sansar Choinyambuu, Andreas Steffen
+ * Copyright (C) 2011-2012 Sansar Choinyambuu
+ * Copyright (C) 2011-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -88,7 +89,12 @@ struct private_tcg_pts_attr_file_meta_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -168,6 +174,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -183,10 +190,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        chunk_t filename;
        status_t status = FAILED;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < PTS_FILE_META_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for PTS Unix-Style file metadata header");
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -323,7 +335,8 @@ pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create(pts_file_meta_t *metadata)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create_from_data(size_t length,
+                                                                                                                       chunk_t data)
 {
        private_tcg_pts_attr_file_meta_t *this;
 
@@ -342,6 +355,7 @@ pa_tnc_attr_t *tcg_pts_attr_unix_file_meta_create_from_data(chunk_t data)
                        .get_metadata = _get_metadata,
                },
                .type = { PEN_TCG, TCG_PTS_UNIX_FILE_META },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 2118d39..d08261c 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Sansar Choinyambuu
+ * Copyright (C) 2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -58,8 +59,10 @@ pa_tnc_attr_t* tcg_pts_attr_unix_file_meta_create(pts_file_meta_t *metadata);
 /**
  * Creates an tcg_pts_attr_file_meta_t object from received data
  *
- * @param value                                        unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_pts_attr_unix_file_meta_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_pts_attr_unix_file_meta_create_from_data(size_t length,
+                                                                                                                       chunk_t value);
 
 #endif /** TCG_PTS_ATTR_UNIX_FILE_META_H_ @}*/
index 8e82314..017bf2c 100644 (file)
@@ -51,7 +51,12 @@ struct private_tcg_seg_attr_max_size_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -114,6 +119,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint32(writer, this->max_seg_size);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -122,11 +128,16 @@ METHOD(pa_tnc_attr_t, process, status_t,
 {
        bio_reader_t *reader;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < TCG_SEG_ATTR_MAX_SIZE_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names,
                                                                                                  this->type.type);
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -204,7 +215,8 @@ pa_tnc_attr_t* tcg_seg_attr_max_size_create(uint32_t max_attr_size,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_seg_attr_max_size_create_from_data(chunk_t data,
+pa_tnc_attr_t *tcg_seg_attr_max_size_create_from_data(size_t length,
+                                                                                                         chunk_t data,
                                                                                                          bool request)
 {
        private_tcg_seg_attr_max_size_t *this;
@@ -225,6 +237,7 @@ pa_tnc_attr_t *tcg_seg_attr_max_size_create_from_data(chunk_t data,
                },
                .type = { PEN_TCG, request ? TCG_SEG_MAX_ATTR_SIZE_REQ :
                                                                         TCG_SEG_MAX_ATTR_SIZE_RESP },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 404e85a..72660ac 100644 (file)
@@ -62,10 +62,12 @@ pa_tnc_attr_t* tcg_seg_attr_max_size_create(uint32_t max_attr_size,
 /**
  * Creates an tcg_seg_attr_max_size_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  * @param request                      TRUE for a request, FALSE for a response
  */
-pa_tnc_attr_t* tcg_seg_attr_max_size_create_from_data(chunk_t value,
+pa_tnc_attr_t* tcg_seg_attr_max_size_create_from_data(size_t length,
+                                                                                                         chunk_t value,
                                                                                                          bool request);
 
 #endif /** TCG_SEG_ATTR_MAX_SIZE_H_ @}*/
index 22934cc..c2dcad3 100644 (file)
@@ -54,7 +54,12 @@ struct private_tcg_seg_attr_next_seg_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -118,6 +123,7 @@ METHOD(pa_tnc_attr_t, build, void,
        writer->write_uint24(writer, this->base_attr_id);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -127,11 +133,18 @@ METHOD(pa_tnc_attr_t, process, status_t,
        bio_reader_t *reader;
        uint8_t flags;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               DBG1(DBG_TNC, "segmentation not allowed for %N", tcg_attr_names,
+                                                                                                                this->type.type);
+               return FAILED;
+       }
        if (this->value.len < TCG_SEG_ATTR_NEXT_SEG_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names,
                                                                                                  this->type.type);
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -207,7 +220,8 @@ pa_tnc_attr_t* tcg_seg_attr_next_seg_create(uint32_t base_attr_id, bool cancel)
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_seg_attr_next_seg_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_seg_attr_next_seg_create_from_data(size_t length,
+                                                                                                         chunk_t data)
 {
        private_tcg_seg_attr_next_seg_t *this;
 
@@ -227,6 +241,7 @@ pa_tnc_attr_t *tcg_seg_attr_next_seg_create_from_data(chunk_t data)
                        .get_cancel_flag = _get_cancel_flag,
                },
                .type = { PEN_TCG, TCG_SEG_NEXT_SEG_REQ },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index c9f53f8..49a4d36 100644 (file)
@@ -64,8 +64,10 @@ pa_tnc_attr_t* tcg_seg_attr_next_seg_create(uint32_t base_attr_id, bool cancel);
 /**
  * Creates an tcg_seg_attr_next_seg_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_seg_attr_next_seg_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_seg_attr_next_seg_create_from_data(size_t length,
+                                                                                                         chunk_t value);
 
 #endif /** TCG_SEG_ATTR_NEXT_SEG_H_ @}*/
index 833111f..fb53212 100644 (file)
@@ -51,7 +51,12 @@ struct private_tcg_seg_attr_seg_env_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -109,6 +114,7 @@ METHOD(pa_tnc_attr_t, build, void,
        private_tcg_seg_attr_seg_env_t *this)
 {
        /* constructor already allocated and built value */
+       this->length = this->value.len;
        return;
 }
 
@@ -117,11 +123,18 @@ METHOD(pa_tnc_attr_t, process, status_t,
 {
        bio_reader_t *reader;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               DBG1(DBG_TNC, "segmentation not allowed for %N", tcg_attr_names,
+                                                                                                                this->type.type);
+               return FAILED;
+       }
        if (this->value.len < TCG_SEG_ATTR_SEG_ENV_HEADER)
        {
                DBG1(DBG_TNC, "insufficient data for %N", tcg_attr_names,
                                                                                                  this->type.type);
-               *offset = 0;
                return FAILED;
        }
        reader = bio_reader_create(this->value);
@@ -206,7 +219,8 @@ pa_tnc_attr_t* tcg_seg_attr_seg_env_create(chunk_t segment, uint8_t flags,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_seg_attr_seg_env_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_seg_attr_seg_env_create_from_data(size_t length,
+                                                                                                        chunk_t data)
 {
        private_tcg_seg_attr_seg_env_t *this;
 
@@ -226,6 +240,7 @@ pa_tnc_attr_t *tcg_seg_attr_seg_env_create_from_data(chunk_t data)
                        .get_segment = _get_segment,
                },
                .type = { PEN_TCG, TCG_SEG_ATTR_SEG_ENV },
+               .length = length,
                .value = chunk_clone(data),
                .ref = 1,
        );
index 1918439..a8b3d7c 100644 (file)
@@ -67,8 +67,10 @@ pa_tnc_attr_t* tcg_seg_attr_seg_env_create(chunk_t segment, uint8_t flags,
 /**
  * Creates an tcg_seg_attr_seg_env_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_seg_attr_seg_env_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_seg_attr_seg_env_create_from_data(size_t length,
+                                                                                                        chunk_t value);
 
 #endif /** TCG_SEG_ATTR_SEG_ENV_H_ @}*/
index 51e3900..35254cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Andreas Steffen
+ * Copyright (C) 2013-2014 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -62,7 +62,13 @@ struct private_tcg_swid_attr_req_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -151,6 +157,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -162,10 +169,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        chunk_t tag_creator, unique_sw_id;
        swid_tag_id_t *tag_id;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < TCG_SWID_REQ_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for SWID Request");
-               *offset = 0;
                return FAILED;
        }
 
@@ -296,7 +308,7 @@ pa_tnc_attr_t *tcg_swid_attr_req_create(u_int8_t flags, u_int32_t request_id,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_swid_attr_req_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_swid_attr_req_create_from_data(size_t length, chunk_t data)
 {
        private_tcg_swid_attr_req_t *this;
 
@@ -319,6 +331,7 @@ pa_tnc_attr_t *tcg_swid_attr_req_create_from_data(chunk_t data)
                        .get_targets = _get_targets,
                },
                .type = { PEN_TCG, TCG_SWID_REQUEST },
+               .length = length,
                .value = chunk_clone(data),
                .targets = swid_inventory_create(FALSE),
                .ref = 1,
index 9655c3c..fd2ccdc 100644 (file)
@@ -98,8 +98,9 @@ pa_tnc_attr_t* tcg_swid_attr_req_create(u_int8_t flags, u_int32_t request_id,
 /**
  * Creates an tcg_swid_attr_req_t object from received data
  *
- * @param value                                unparsed attribute value
+ * @param length                       Total length of attribute value
+ * @param value                                Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_swid_attr_req_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_swid_attr_req_create_from_data(size_t length, chunk_t value);
 
 #endif /** TCG_SWID_ATTR_REQ_H_ @}*/
index d0b92c8..6e9ebd4 100644 (file)
@@ -64,7 +64,12 @@ struct private_tcg_swid_attr_tag_id_inv_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -155,6 +160,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -167,10 +173,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        chunk_t tag_creator, unique_sw_id, instance_id;
        swid_tag_id_t *tag_id;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < TCG_SWID_TAG_ID_INV_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for SWID Tag Identifier Inventory");
-               *offset = 0;
                return FAILED;
        }
 
@@ -300,7 +311,8 @@ pa_tnc_attr_t *tcg_swid_attr_tag_id_inv_create(uint32_t request_id,
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_swid_attr_tag_id_inv_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_swid_attr_tag_id_inv_create_from_data(size_t length,
+                                                                                                                chunk_t data)
 {
        private_tcg_swid_attr_tag_id_inv_t *this;
 
@@ -322,6 +334,7 @@ pa_tnc_attr_t *tcg_swid_attr_tag_id_inv_create_from_data(chunk_t data)
                        .get_inventory = _get_inventory,
                },
                .type = { PEN_TCG, TCG_SWID_TAG_ID_INVENTORY },
+               .length = length,
                .value = chunk_clone(data),
                .inventory = swid_inventory_create(FALSE),
                .ref = 1,
index c4ade90..897fd49 100644 (file)
@@ -88,8 +88,10 @@ pa_tnc_attr_t* tcg_swid_attr_tag_id_inv_create(uint32_t request_id,
 /**
  * Creates an tcg_swid_attr_tag_id_inv_t object from received data
  *
- * @param value                                        unparsed attribute value
+ * @param length                               Total length of attribute value
+ * @param value                                        Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_swid_attr_tag_id_inv_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_swid_attr_tag_id_inv_create_from_data(size_t length,
+                                                                                                                chunk_t value);
 
 #endif /** TCG_SWID_ATTR_TAG_ID_INV_H_ @}*/
index 5864e5a..5923f56 100644 (file)
@@ -64,7 +64,12 @@ struct private_tcg_swid_attr_tag_inv_t {
        pen_type_t type;
 
        /**
-        * Attribute value
+        * Length of attribute value
+        */
+       size_t length;
+
+       /**
+        * Attribute value or segment
         */
        chunk_t value;
 
@@ -151,6 +156,7 @@ METHOD(pa_tnc_attr_t, build, void,
        enumerator->destroy(enumerator);
 
        this->value = writer->extract_buf(writer);
+       this->length = this->value.len;
        writer->destroy(writer);
 }
 
@@ -163,10 +169,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
        chunk_t tag_encoding, instance_id;
        swid_tag_t *tag;
 
+       *offset = 0;
+
+       if (this->value.len < this->length)
+       {
+               return NEED_MORE;
+       }
        if (this->value.len < TCG_SWID_TAG_INV_MIN_SIZE)
        {
                DBG1(DBG_TNC, "insufficient data for SWID Tag Inventory");
-               *offset = 0;
                return FAILED;
        }
 
@@ -284,11 +295,11 @@ pa_tnc_attr_t *tcg_swid_attr_tag_inv_create(uint32_t request_id,
        return &this->public.pa_tnc_attribute;
 }
 
-
 /**
  * Described in header.
  */
-pa_tnc_attr_t *tcg_swid_attr_tag_inv_create_from_data(chunk_t data)
+pa_tnc_attr_t *tcg_swid_attr_tag_inv_create_from_data(size_t length,
+                                                                                                         chunk_t data)
 {
        private_tcg_swid_attr_tag_inv_t *this;
 
@@ -310,6 +321,7 @@ pa_tnc_attr_t *tcg_swid_attr_tag_inv_create_from_data(chunk_t data)
                        .get_inventory = _get_inventory,
                },
                .type = { PEN_TCG, TCG_SWID_TAG_INVENTORY },
+               .length = length,
                .value = chunk_clone(data),
                .inventory = swid_inventory_create(TRUE),
                .ref = 1,
index 69966c7..4795fd0 100644 (file)
@@ -87,8 +87,10 @@ pa_tnc_attr_t* tcg_swid_attr_tag_inv_create(uint32_t request_id,
 /**
  * Creates an tcg_swid_attr_tag_inv_t object from received data
  *
- * @param value                                        unparsed attribute value
+ * @param length                               Total length of attribute value
+ * @param value                                        Unparsed attribute value (might be a segment)
  */
-pa_tnc_attr_t* tcg_swid_attr_tag_inv_create_from_data(chunk_t value);
+pa_tnc_attr_t* tcg_swid_attr_tag_inv_create_from_data(size_t length,
+                                                                                                         chunk_t value);
 
 #endif /** TCG_SWID_ATTR_TAG_INV_H_ @}*/
index d4ae1da..7949291 100644 (file)
@@ -183,62 +183,73 @@ ENUM_END(tcg_attr_names,  TCG_PTS_AIK);
 /**
  * See header
  */
-pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value)
+pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, size_t length, chunk_t value)
 {
        switch (type)
        {
                case TCG_SWID_REQUEST:
-                       return tcg_swid_attr_req_create_from_data(value);
+                       return tcg_swid_attr_req_create_from_data(length, value);
                case TCG_SWID_TAG_ID_INVENTORY:
-                       return tcg_swid_attr_tag_id_inv_create_from_data(value);
+                       return tcg_swid_attr_tag_id_inv_create_from_data(length, value);
                case TCG_SWID_TAG_INVENTORY:
-                       return tcg_swid_attr_tag_inv_create_from_data(value);
+                       return tcg_swid_attr_tag_inv_create_from_data(length, value);
                case TCG_SEG_MAX_ATTR_SIZE_REQ:
-                       return tcg_seg_attr_max_size_create_from_data(value, TRUE);
+                       return tcg_seg_attr_max_size_create_from_data(length, value, TRUE);
                case TCG_SEG_MAX_ATTR_SIZE_RESP:
-                       return tcg_seg_attr_max_size_create_from_data(value, FALSE);
+                       return tcg_seg_attr_max_size_create_from_data(length, value, FALSE);
                case TCG_SEG_ATTR_SEG_ENV:
-                       return tcg_seg_attr_seg_env_create_from_data(value);
+                       return tcg_seg_attr_seg_env_create_from_data(length, value);
                case TCG_SEG_NEXT_SEG_REQ:
-                       return tcg_seg_attr_next_seg_create_from_data(value);
+                       return tcg_seg_attr_next_seg_create_from_data(length, value);
                case TCG_PTS_REQ_PROTO_CAPS:
-                       return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
+                       return tcg_pts_attr_proto_caps_create_from_data(length, value,
+                                                                                                                       TRUE);
                case TCG_PTS_PROTO_CAPS:
-                       return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
+                       return tcg_pts_attr_proto_caps_create_from_data(length, value,
+                                                                                                                       FALSE);
                case TCG_PTS_DH_NONCE_PARAMS_REQ:
-                       return tcg_pts_attr_dh_nonce_params_req_create_from_data(value);
+                       return tcg_pts_attr_dh_nonce_params_req_create_from_data(length,
+                                                                                                                                        value);
                case TCG_PTS_DH_NONCE_PARAMS_RESP:
-                       return tcg_pts_attr_dh_nonce_params_resp_create_from_data(value);
+                       return tcg_pts_attr_dh_nonce_params_resp_create_from_data(length,
+                                                                                                                                         value);
                case TCG_PTS_DH_NONCE_FINISH:
-                       return tcg_pts_attr_dh_nonce_finish_create_from_data(value);
+                       return tcg_pts_attr_dh_nonce_finish_create_from_data(length, value);
                case TCG_PTS_MEAS_ALGO:
-                       return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
+                       return tcg_pts_attr_meas_algo_create_from_data(length, value,
+                                                                                                                  FALSE);
                case TCG_PTS_MEAS_ALGO_SELECTION:
-                       return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
+                       return tcg_pts_attr_meas_algo_create_from_data(length, value,
+                                                                                                                  TRUE);
                case TCG_PTS_GET_TPM_VERSION_INFO:
-                       return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
+                       return tcg_pts_attr_get_tpm_version_info_create_from_data(length,
+                                                                                                                                         value);
                case TCG_PTS_TPM_VERSION_INFO:
-                       return tcg_pts_attr_tpm_version_info_create_from_data(value);
+                       return tcg_pts_attr_tpm_version_info_create_from_data(length,
+                                                                                                                                 value);
                case TCG_PTS_GET_AIK:
-                       return tcg_pts_attr_get_aik_create_from_data(value);
+                       return tcg_pts_attr_get_aik_create_from_data(length, value);
                case TCG_PTS_AIK:
-                       return tcg_pts_attr_aik_create_from_data(value);
+                       return tcg_pts_attr_aik_create_from_data(length, value);
                case TCG_PTS_REQ_FUNC_COMP_EVID:
-                       return tcg_pts_attr_req_func_comp_evid_create_from_data(value);
+                       return tcg_pts_attr_req_func_comp_evid_create_from_data(length,
+                                                                                                                                       value);
                case TCG_PTS_GEN_ATTEST_EVID:
-                       return tcg_pts_attr_gen_attest_evid_create_from_data(value);
+                       return tcg_pts_attr_gen_attest_evid_create_from_data(length, value);
                case TCG_PTS_SIMPLE_COMP_EVID:
-                       return tcg_pts_attr_simple_comp_evid_create_from_data(value);
+                       return tcg_pts_attr_simple_comp_evid_create_from_data(length,
+                                                                                                                                 value);
                case TCG_PTS_SIMPLE_EVID_FINAL:
-                       return tcg_pts_attr_simple_evid_final_create_from_data(value);
+                       return tcg_pts_attr_simple_evid_final_create_from_data(length,
+                                                                                                                                  value);
                case TCG_PTS_REQ_FILE_MEAS:
-                       return tcg_pts_attr_req_file_meas_create_from_data(value);
+                       return tcg_pts_attr_req_file_meas_create_from_data(length, value);
                case TCG_PTS_FILE_MEAS:
-                       return tcg_pts_attr_file_meas_create_from_data(value);
+                       return tcg_pts_attr_file_meas_create_from_data(length, value);
                case TCG_PTS_REQ_FILE_META:
-                       return tcg_pts_attr_req_file_meta_create_from_data(value);
+                       return tcg_pts_attr_req_file_meta_create_from_data(length, value);
                case TCG_PTS_UNIX_FILE_META:
-                       return tcg_pts_attr_unix_file_meta_create_from_data(value);
+                       return tcg_pts_attr_unix_file_meta_create_from_data(length, value);
                /* unsupported TCG/SWID attributes */
                case TCG_SWID_TAG_ID_EVENTS:
                case TCG_SWID_TAG_EVENTS:
index 3964c8c..24ec6e1 100644 (file)
@@ -96,8 +96,10 @@ extern enum_name_t *tcg_attr_names;
  * Create a TCG PA-TNC attribute from data
  *
  * @param type                         attribute type
- * @param value                                attribute value
+ * @param length                       attribute length
+ * @param value                                attribute value or segment
  */
-pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value);
+pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, size_t length,
+                                                                                chunk_t value);
 
 #endif /** TCG_ATTR_H_ @}*/