File not Found, Invalid path, Invalid Delimiter PTS errors case checks implemented
authorSansar Choinyambuu <schoinya@hsr.ch>
Fri, 9 Sep 2011 09:23:19 +0000 (11:23 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 28 Nov 2011 13:41:27 +0000 (14:41 +0100)
src/libimcv/plugins/imc_attestation/imc_attestation.c

index c975644..9234777 100644 (file)
@@ -256,8 +256,187 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
                        if (!imc_attestation_process(attr, attr_list, attestation_state,
                                supported_algorithms, supported_dh_groups, evidences))
                        {
-                               result = TNC_RESULT_FATAL;
-                               break;
+                               case TCG_PTS_REQ_PROTO_CAPS:
+                               {
+                                       tcg_pts_attr_proto_caps_t *attr_cast;
+                                       pts_proto_caps_flag_t imc_flags, imv_flags;
+
+                                       attr_cast = (tcg_pts_attr_proto_caps_t*)attr;
+                                       imv_flags = attr_cast->get_flags(attr_cast);
+                                       imc_flags = pts->get_proto_caps(pts);
+                                       pts->set_proto_caps(pts, imc_flags & imv_flags);
+
+                                       /* Send PTS Protocol Capabilities attribute */
+                                       attr = tcg_pts_attr_proto_caps_create(imc_flags & imv_flags,
+                                                                                                                 FALSE);
+                                       attr_list->insert_last(attr_list, attr);
+                                       break;
+                               }
+                               case TCG_PTS_MEAS_ALGO:
+                               {
+                                       tcg_pts_attr_meas_algo_t *attr_cast;
+                                       pts_meas_algorithms_t selected_algorithm;
+       
+                                       attr_cast = (tcg_pts_attr_meas_algo_t*)attr;
+                                       selected_algorithm = attr_cast->get_algorithms(attr_cast);
+
+                                       if ((supported_algorithms & PTS_MEAS_ALGO_SHA384) &&
+                                               (selected_algorithm & PTS_MEAS_ALGO_SHA384))
+                                       {
+                                               pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA384);
+                                       }
+                                       else if ((supported_algorithms & PTS_MEAS_ALGO_SHA256) &&
+                                                        (selected_algorithm & PTS_MEAS_ALGO_SHA256))
+                                       {
+                                               pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA256);
+                                       }
+
+                                       else if ((supported_algorithms & PTS_MEAS_ALGO_SHA1) &&
+                                                        (selected_algorithm & PTS_MEAS_ALGO_SHA1))
+                                       {
+                                               pts->set_meas_algorithm(pts, PTS_MEAS_ALGO_SHA1);
+                                       }
+                                       else
+                                       {
+                                               attr = pts_hash_alg_error_create(supported_algorithms);
+                                               attr_list->insert_last(attr_list, attr);
+                                               break;
+                                       }
+
+                                       /* Send Measurement Algorithm Selection attribute */
+                                       selected_algorithm = pts->get_meas_algorithm(pts);
+                                       attr = tcg_pts_attr_meas_algo_create(selected_algorithm,
+                                                                                                                TRUE);
+                                       attr_list->insert_last(attr_list, attr);
+                                       break;
+                               }
+       
+                               case TCG_PTS_GET_TPM_VERSION_INFO:
+                               {
+                                       chunk_t tpm_version_info, attr_info;
+
+                                       if (!pts->get_tpm_version_info(pts, &tpm_version_info))
+                                       {
+                                               attr_info = attr->get_value(attr);
+                                               attr = ietf_attr_pa_tnc_error_create(PEN_TCG,
+                                                                       TCG_PTS_TPM_VERS_NOT_SUPPORTED, attr_info);
+                                               attr_list->insert_last(attr_list, attr);
+                                               break;
+                                       }
+       
+                                       /* Send TPM Version Info attribute */
+                                       attr = tcg_pts_attr_tpm_version_info_create(tpm_version_info);
+                                       attr_list->insert_last(attr_list, attr);
+                                       break;
+                               }
+       
+                               case TCG_PTS_GET_AIK:
+                               {
+                                       certificate_t *aik;
+
+                                       aik = pts->get_aik(pts);
+                                       if (!aik)
+                                       {
+                                               DBG1(DBG_IMC, "no AIK certificate or public key available");
+                                               break;
+                                       }
+       
+                                       /* Send AIK attribute */
+                                       attr = tcg_pts_attr_aik_create(aik);
+                                       attr_list->insert_last(attr_list, attr);
+                                       break;
+                               }
+       
+                               /* PTS-based Attestation Evidence */
+                               case TCG_PTS_REQ_FUNCT_COMP_EVID:
+                                       break;
+                               case TCG_PTS_GEN_ATTEST_EVID:
+                                       break;
+                               case TCG_PTS_REQ_FILE_MEAS:
+                               {
+                                       tcg_pts_attr_req_file_meas_t *attr_cast;
+                                       char *pathname;
+                                       u_int16_t request_id;
+                                       bool is_directory;
+                                       u_int32_t delimiter;
+                                       pts_file_meas_t *measurements;
+                                       pts_error_code_t pts_error;
+                                       chunk_t attr_info;
+                                       
+                                       attr_info = attr->get_value(attr);
+                                       attr_cast = (tcg_pts_attr_req_file_meas_t*)attr;
+                                       is_directory = attr_cast->get_directory_flag(attr_cast);
+                                       request_id = attr_cast->get_request_id(attr_cast);
+                                       delimiter = attr_cast->get_delimiter(attr_cast);
+                                       pathname = attr_cast->get_pathname(attr_cast);
+                                       
+                                       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);
+                                               break;
+                                       }
+                                       else if (!pts->is_path_valid(pts, pathname, &pts_error))
+                                       {
+                                               break;
+                                       }
+                                       
+                                       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);
+                                               break;
+                                       }
+
+                                       /* Do PTS File Measurements and send them to PTS-IMV */
+                                       DBG2(DBG_IMC, "measurement request %d for %s '%s'",
+                                                request_id, is_directory ? "directory" : "file",
+                                                pathname);
+                                       measurements = pts->do_measurements(pts, request_id,
+                                                                                       pathname, is_directory);
+                                       if (!measurements)
+                                       {
+                                               /* TODO handle error codes from measurements */
+                                               return TNC_RESULT_FATAL;
+                                       }
+                                       attr = tcg_pts_attr_file_meas_create(measurements);
+                                       attr->set_noskip_flag(attr, TRUE);
+                                       attr_list->insert_last(attr_list, attr);
+                                       break;
+                               }
+                               /* TODO: Not implemented yet */
+                               case TCG_PTS_DH_NONCE_PARAMS_REQ:
+                               case TCG_PTS_DH_NONCE_FINISH:
+                               case TCG_PTS_REQ_FILE_META:
+                               case TCG_PTS_REQ_INTEG_MEAS_LOG:
+                               /* Attributes using XML */
+                               case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
+                               case TCG_PTS_UPDATE_TEMPL_REF_MANI:
+                               /* On Windows only*/
+                               case TCG_PTS_REQ_REGISTRY_VALUE:
+                               /* Received on IMV side only*/
+                               case TCG_PTS_PROTO_CAPS:
+                               case TCG_PTS_DH_NONCE_PARAMS_RESP:
+                               case TCG_PTS_MEAS_ALGO_SELECTION:
+                               case TCG_PTS_TPM_VERSION_INFO:
+                               case TCG_PTS_TEMPL_REF_MANI_SET_META:
+                               case TCG_PTS_AIK:
+                               case TCG_PTS_SIMPLE_COMP_EVID:
+                               case TCG_PTS_SIMPLE_EVID_FINAL:
+                               case TCG_PTS_VERIFICATION_RESULT:
+                               case TCG_PTS_INTEG_REPORT:
+                               case TCG_PTS_UNIX_FILE_META:
+                               case TCG_PTS_FILE_MEAS:
+                               case TCG_PTS_INTEG_MEAS_LOG:
+                               default:
+                                       DBG1(DBG_IMC, "received unsupported attribute '%N'",
+                                               tcg_attr_names, attr->get_type(attr));
+                                       break;
+>>>>>>> File not Found, Invalid path, Invalid Delimiter PTS errors case checks implemented
                        }
                }
        }