summaryrefslogtreecommitdiff
path: root/src/libpts/tcg/tcg_attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libpts/tcg/tcg_attr.c')
-rw-r--r--src/libpts/tcg/tcg_attr.c209
1 files changed, 209 insertions, 0 deletions
diff --git a/src/libpts/tcg/tcg_attr.c b/src/libpts/tcg/tcg_attr.c
new file mode 100644
index 000000000..656791a8f
--- /dev/null
+++ b/src/libpts/tcg/tcg_attr.c
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2011 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "tcg_attr.h"
+#include "tcg/tcg_pts_attr_proto_caps.h"
+#include "tcg/tcg_pts_attr_dh_nonce_params_req.h"
+#include "tcg/tcg_pts_attr_dh_nonce_params_resp.h"
+#include "tcg/tcg_pts_attr_dh_nonce_finish.h"
+#include "tcg/tcg_pts_attr_meas_algo.h"
+#include "tcg/tcg_pts_attr_get_tpm_version_info.h"
+#include "tcg/tcg_pts_attr_tpm_version_info.h"
+#include "tcg/tcg_pts_attr_get_aik.h"
+#include "tcg/tcg_pts_attr_aik.h"
+#include "tcg/tcg_pts_attr_req_func_comp_evid.h"
+#include "tcg/tcg_pts_attr_gen_attest_evid.h"
+#include "tcg/tcg_pts_attr_simple_comp_evid.h"
+#include "tcg/tcg_pts_attr_simple_evid_final.h"
+#include "tcg/tcg_pts_attr_req_file_meas.h"
+#include "tcg/tcg_pts_attr_file_meas.h"
+#include "tcg/tcg_pts_attr_req_file_meta.h"
+#include "tcg/tcg_pts_attr_unix_file_meta.h"
+
+ENUM_BEGIN(tcg_attr_names, TCG_PTS_REQ_FUNC_COMP_EVID,
+ TCG_PTS_REQ_FUNC_COMP_EVID,
+ "Request Functional Component Evidence");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_GEN_ATTEST_EVID,
+ TCG_PTS_GEN_ATTEST_EVID,
+ TCG_PTS_REQ_FUNC_COMP_EVID,
+ "Generate Attestation Evidence");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_COMP_EVID,
+ TCG_PTS_SIMPLE_COMP_EVID,
+ TCG_PTS_GEN_ATTEST_EVID,
+ "Simple Component Evidence");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_EVID_FINAL,
+ TCG_PTS_SIMPLE_EVID_FINAL,
+ TCG_PTS_SIMPLE_COMP_EVID,
+ "Simple Evidence Final");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_VERIFICATION_RESULT,
+ TCG_PTS_VERIFICATION_RESULT,
+ TCG_PTS_SIMPLE_EVID_FINAL,
+ "Verification Result");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_REPORT,
+ TCG_PTS_INTEG_REPORT,
+ TCG_PTS_VERIFICATION_RESULT,
+ "Integrity Report");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_META,
+ TCG_PTS_REQ_FILE_META,
+ TCG_PTS_INTEG_REPORT,
+ "Request File Metadata");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_WIN_FILE_META,
+ TCG_PTS_WIN_FILE_META,
+ TCG_PTS_REQ_FILE_META,
+ "Windows-Style File Metadata");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_UNIX_FILE_META,
+ TCG_PTS_UNIX_FILE_META,
+ TCG_PTS_WIN_FILE_META,
+ "Unix-Style File Metadata");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_REGISTRY_VALUE,
+ TCG_PTS_REQ_REGISTRY_VALUE,
+ TCG_PTS_UNIX_FILE_META,
+ "Request Registry Value");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REGISTRY_VALUE,
+ TCG_PTS_REGISTRY_VALUE,
+ TCG_PTS_REQ_REGISTRY_VALUE,
+ "Registry Value");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_MEAS,
+ TCG_PTS_REQ_FILE_MEAS,
+ TCG_PTS_REGISTRY_VALUE,
+ "Request File Measurement");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_FILE_MEAS,
+ TCG_PTS_FILE_MEAS,
+ TCG_PTS_REQ_FILE_MEAS,
+ "File Measurement");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_INTEG_MEAS_LOG,
+ TCG_PTS_REQ_INTEG_MEAS_LOG,
+ TCG_PTS_FILE_MEAS,
+ "Request Integrity Measurement Log");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_MEAS_LOG,
+ TCG_PTS_INTEG_MEAS_LOG,
+ TCG_PTS_REQ_INTEG_MEAS_LOG,
+ "Integrity Measurement Log");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_PROTO_CAPS,
+ TCG_PTS_REQ_PROTO_CAPS,
+ TCG_PTS_INTEG_MEAS_LOG,
+ "Request PTS Protocol Capabilities");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_PROTO_CAPS,
+ TCG_PTS_PROTO_CAPS,
+ TCG_PTS_REQ_PROTO_CAPS,
+ "PTS Protocol Capabilities");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_REQ,
+ TCG_PTS_DH_NONCE_PARAMS_REQ,
+ TCG_PTS_PROTO_CAPS,
+ "DH Nonce Parameters Request");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_RESP,
+ TCG_PTS_DH_NONCE_PARAMS_RESP,
+ TCG_PTS_DH_NONCE_PARAMS_REQ,
+ "DH Nonce Parameters Response");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_FINISH,
+ TCG_PTS_DH_NONCE_FINISH,
+ TCG_PTS_DH_NONCE_PARAMS_RESP,
+ "DH Nonce Finish");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO,
+ TCG_PTS_MEAS_ALGO,
+ TCG_PTS_DH_NONCE_FINISH,
+ "PTS Measurement Algorithm Request");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO_SELECTION,
+ TCG_PTS_MEAS_ALGO_SELECTION,
+ TCG_PTS_MEAS_ALGO,
+ "PTS Measurement Algorithm");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_TPM_VERSION_INFO,
+ TCG_PTS_GET_TPM_VERSION_INFO,
+ TCG_PTS_MEAS_ALGO_SELECTION,
+ "Get TPM Version Information");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_TPM_VERSION_INFO,
+ TCG_PTS_TPM_VERSION_INFO,
+ TCG_PTS_GET_TPM_VERSION_INFO,
+ "TPM Version Information");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
+ TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
+ TCG_PTS_TPM_VERSION_INFO,
+ "Request Template Reference Manifest Set Metadata");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_TEMPL_REF_MANI_SET_META,
+ TCG_PTS_TEMPL_REF_MANI_SET_META,
+ TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
+ "Template Reference Manifest Set Metadata");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_UPDATE_TEMPL_REF_MANI,
+ TCG_PTS_UPDATE_TEMPL_REF_MANI,
+ TCG_PTS_TEMPL_REF_MANI_SET_META,
+ "Update Template Reference Manifest");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_AIK,
+ TCG_PTS_GET_AIK,
+ TCG_PTS_UPDATE_TEMPL_REF_MANI,
+ "Get Attestation Identity Key");
+ENUM_NEXT(tcg_attr_names, TCG_PTS_AIK,
+ TCG_PTS_AIK,
+ TCG_PTS_GET_AIK,
+ "Attestation Identity Key");
+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)
+{
+ switch (type)
+ {
+ case TCG_PTS_REQ_PROTO_CAPS:
+ return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
+ case TCG_PTS_PROTO_CAPS:
+ return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
+ case TCG_PTS_DH_NONCE_PARAMS_REQ:
+ return tcg_pts_attr_dh_nonce_params_req_create_from_data(value);
+ case TCG_PTS_DH_NONCE_PARAMS_RESP:
+ return tcg_pts_attr_dh_nonce_params_resp_create_from_data(value);
+ case TCG_PTS_DH_NONCE_FINISH:
+ return tcg_pts_attr_dh_nonce_finish_create_from_data(value);
+ case TCG_PTS_MEAS_ALGO:
+ return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
+ case TCG_PTS_MEAS_ALGO_SELECTION:
+ return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
+ case TCG_PTS_GET_TPM_VERSION_INFO:
+ return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
+ case TCG_PTS_TPM_VERSION_INFO:
+ return tcg_pts_attr_tpm_version_info_create_from_data(value);
+ case TCG_PTS_GET_AIK:
+ return tcg_pts_attr_get_aik_create_from_data(value);
+ case TCG_PTS_AIK:
+ return tcg_pts_attr_aik_create_from_data(value);
+ case TCG_PTS_REQ_FUNC_COMP_EVID:
+ return tcg_pts_attr_req_func_comp_evid_create_from_data(value);
+ case TCG_PTS_GEN_ATTEST_EVID:
+ return tcg_pts_attr_gen_attest_evid_create_from_data(value);
+ case TCG_PTS_SIMPLE_COMP_EVID:
+ return tcg_pts_attr_simple_comp_evid_create_from_data(value);
+ case TCG_PTS_SIMPLE_EVID_FINAL:
+ return tcg_pts_attr_simple_evid_final_create_from_data(value);
+ case TCG_PTS_REQ_FILE_MEAS:
+ return tcg_pts_attr_req_file_meas_create_from_data(value);
+ case TCG_PTS_FILE_MEAS:
+ return tcg_pts_attr_file_meas_create_from_data(value);
+ case TCG_PTS_REQ_FILE_META:
+ return tcg_pts_attr_req_file_meta_create_from_data(value);
+ case TCG_PTS_UNIX_FILE_META:
+ return tcg_pts_attr_unix_file_meta_create_from_data(value);
+ case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
+ case TCG_PTS_TEMPL_REF_MANI_SET_META:
+ case TCG_PTS_UPDATE_TEMPL_REF_MANI:
+ case TCG_PTS_VERIFICATION_RESULT:
+ case TCG_PTS_INTEG_REPORT:
+ case TCG_PTS_WIN_FILE_META:
+ case TCG_PTS_REQ_REGISTRY_VALUE:
+ case TCG_PTS_REGISTRY_VALUE:
+ case TCG_PTS_REQ_INTEG_MEAS_LOG:
+ case TCG_PTS_INTEG_MEAS_LOG:
+ default:
+ return NULL;
+ }
+}