Changes according to the new PTS Attributes addition
[strongswan.git] / src / libimcv / plugins / imv_attestation / imv_attestation.c
index b594378..2aa52d8 100644 (file)
 #include <ietf/ietf_attr_pa_tnc_error.h>
 #include <tcg/tcg_attr.h>
 
-#include <pen/pen.h>
+#include <tncif_pa_subtypes.h>
 
+#include <pen/pen.h>
 #include <debug.h>
 
 /* IMV definitions */
 
 static const char imv_name[] = "Attestation";
 
-#define IMV_VENDOR_ID  PEN_ITA
-#define IMV_SUBTYPE            0x02
+#define IMV_VENDOR_ID  PEN_TCG
+#define IMV_SUBTYPE    PA_SUBTYPE_TCG_PTS
 
 static imv_agent_t *imv_attestation;
 
@@ -95,7 +96,8 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id,
                         */
                        return TNC_RESULT_SUCCESS;
                default:
-                       return imv_attestation->change_state(imv_attestation, connection_id, new_state);
+                       return imv_attestation->change_state(imv_attestation, connection_id,
+                                                                                                new_state, NULL);
        }
 }
 
@@ -167,6 +169,7 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
                        ietf_attr_pa_tnc_error_t *error_attr;
                        pa_tnc_error_code_t error_code;
                        chunk_t msg_info, attr_info;
+                       u_int32_t offset;
 
                        error_attr = (ietf_attr_pa_tnc_error_t*)attr;
                        error_code = error_attr->get_error_code(error_attr);
@@ -176,6 +179,10 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
                                 pa_tnc_error_code_names, error_code, &msg_info);
                        switch (error_code)
                        {
+                               case PA_ERROR_INVALID_PARAMETER:
+                                       offset = error_attr->get_offset(error_attr);
+                                       DBG1(DBG_IMV, "  occurred at offset of %u bytes", offset);
+                                       break;
                                case PA_ERROR_ATTR_TYPE_NOT_SUPPORTED:
                                        attr_info = error_attr->get_attr_info(error_attr);
                                        DBG1(DBG_IMV, "  unsupported attribute %#B", &attr_info);
@@ -190,6 +197,59 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
                        /**
                         * Handle TCG PTS attributes
                         */
+                       switch(attr->get_type(attr))
+                       {
+                               case TCG_PTS_PROTO_CAPS:
+                                       break;
+                               case TCG_PTS_DH_NONCE_PARAMS_RESP:
+                                       break;
+                               case TCG_PTS_MEAS_ALGO_SELECTION:
+                                       break;
+                               case TCG_PTS_TPM_VERSION_INFO:
+                                       break;
+                               case TCG_PTS_TEMPL_REF_MANI_SET_META:
+                                       break;
+                               case TCG_PTS_AIK:
+                                       break;
+                               
+                               /* PTS-based Attestation Evidence */
+                               case TCG_PTS_SIMPLE_COMP_EVID:
+                                       break;
+                               case TCG_PTS_SIMPLE_EVID_FINAL:
+                                       break;
+                               case TCG_PTS_VERIFICATION_RESULT:
+                                       break;
+                               case TCG_PTS_INTEG_REPORT:
+                                       break;
+                               case TCG_PTS_UNIX_FILE_META:
+                                       break;
+                               case TCG_PTS_FILE_MEAS:
+                                       break;
+                               case TCG_PTS_INTEG_MEAS_LOG:
+                                       break;
+                                       
+                               /* On Windows only*/
+                               case TCG_PTS_WIN_FILE_META:
+                               case TCG_PTS_REGISTRY_VALUE:
+                               /* Received on IMC side only*/
+                               case TCG_PTS_REQ_PROTO_CAPS:
+                               case TCG_PTS_DH_NONCE_PARAMS_REQ:
+                               case TCG_PTS_DH_NONCE_FINISH:
+                               case TCG_PTS_MEAS_ALGO:
+                               case TCG_PTS_GET_TPM_VERSION_INFO:
+                               case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
+                               case TCG_PTS_UPDATE_TEMPL_REF_MANI:
+                               case TCG_PTS_GET_AIK:
+                               case TCG_PTS_REQ_FUNCT_COMP_EVID:
+                               case TCG_PTS_GEN_ATTEST_EVID:
+                               case TCG_PTS_REQ_FILE_META:
+                               case TCG_PTS_REQ_FILE_MEAS:
+                               case TCG_PTS_REQ_INTEG_MEAS_LOG:
+                               default:
+                                       DBG1(DBG_IMC, "received unsupported attribute '%N'",
+                                               tcg_attr_names, attr->get_type(attr));
+                                       break;
+                       }
                }
        }
        enumerator->destroy(enumerator);