File not Found, Invalid path, Invalid Delimiter PTS errors case checks implemented
[strongswan.git] / src / libimcv / plugins / imc_attestation / imc_attestation.c
index 3b23cac..58fb178 100644 (file)
@@ -21,6 +21,8 @@
 #include <ietf/ietf_attr_pa_tnc_error.h>
 #include <ietf/ietf_attr_product_info.h>
 
 #include <ietf/ietf_attr_pa_tnc_error.h>
 #include <ietf/ietf_attr_product_info.h>
 
+#include <libpts.h>
+
 #include <pts/pts_error.h>
 
 #include <tcg/tcg_pts_attr_proto_caps.h>
 #include <pts/pts_error.h>
 
 #include <tcg/tcg_pts_attr_proto_caps.h>
@@ -69,12 +71,19 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
                DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
                return TNC_RESULT_ALREADY_INITIALIZED;
        }
                DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
                return TNC_RESULT_ALREADY_INITIALIZED;
        }
+       if (!pts_meas_probe_algorithms(&supported_algorithms))
+       {
+               return TNC_RESULT_FATAL;
+       }
        imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
        imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
-                                                               imc_id, actual_version);
-       if (!imc_attestation || !pts_meas_probe_algorithms(&supported_algorithms))
+                                                                          imc_id, actual_version);
+       if (!imc_attestation)
        {
                return TNC_RESULT_FATAL;
        }
        {
                return TNC_RESULT_FATAL;
        }
+
+       libpts_init();
+
        if (min_version > TNC_IFIMC_VERSION_1 || max_version < TNC_IFIMC_VERSION_1)
        {
                DBG1(DBG_IMC, "no common IF-IMC version");
        if (min_version > TNC_IFIMC_VERSION_1 || max_version < TNC_IFIMC_VERSION_1)
        {
                DBG1(DBG_IMC, "no common IF-IMC version");
@@ -359,6 +368,7 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
                                        
                                        if (pts->is_path_valid(pts, pathname, &pts_error) && pts_error)
                                        {
                                        
                                        if (pts->is_path_valid(pts, pathname, &pts_error) && pts_error)
                                        {
+                                               attr_info = attr->get_value(attr);
                                                attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
                                                                                                pts_error, attr_info);
                                                attr_list->insert_last(attr_list, attr);
                                                attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
                                                                                                pts_error, attr_info);
                                                attr_list->insert_last(attr_list, attr);
@@ -371,6 +381,7 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
                                        
                                        if (delimiter != SOLIDUS_UTF && delimiter != REVERSE_SOLIDUS_UTF)
                                        {
                                        
                                        if (delimiter != SOLIDUS_UTF && delimiter != REVERSE_SOLIDUS_UTF)
                                        {
+                                               attr_info = attr->get_value(attr);
                                                attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
                                                                                                TCG_PTS_INVALID_DELIMITER, attr_info);
                                                attr_list->insert_last(attr_list, attr);
                                                attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
                                                                                                TCG_PTS_INVALID_DELIMITER, attr_info);
                                                attr_list->insert_last(attr_list, attr);
@@ -474,6 +485,9 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id)
                DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
                return TNC_RESULT_NOT_INITIALIZED;
        }
                DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
                return TNC_RESULT_NOT_INITIALIZED;
        }
+
+       libpts_deinit();
+
        imc_attestation->destroy(imc_attestation);
        imc_attestation = NULL;
 
        imc_attestation->destroy(imc_attestation);
        imc_attestation = NULL;