added some new TCG IF-M message subtypes and attributes
[strongswan.git] / src / libpts / tcg / tcg_attr.c
1 /*
2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #include "tcg_attr.h"
16 #include "tcg/tcg_pts_attr_proto_caps.h"
17 #include "tcg/tcg_pts_attr_dh_nonce_params_req.h"
18 #include "tcg/tcg_pts_attr_dh_nonce_params_resp.h"
19 #include "tcg/tcg_pts_attr_dh_nonce_finish.h"
20 #include "tcg/tcg_pts_attr_meas_algo.h"
21 #include "tcg/tcg_pts_attr_get_tpm_version_info.h"
22 #include "tcg/tcg_pts_attr_tpm_version_info.h"
23 #include "tcg/tcg_pts_attr_get_aik.h"
24 #include "tcg/tcg_pts_attr_aik.h"
25 #include "tcg/tcg_pts_attr_req_func_comp_evid.h"
26 #include "tcg/tcg_pts_attr_gen_attest_evid.h"
27 #include "tcg/tcg_pts_attr_simple_comp_evid.h"
28 #include "tcg/tcg_pts_attr_simple_evid_final.h"
29 #include "tcg/tcg_pts_attr_req_file_meas.h"
30 #include "tcg/tcg_pts_attr_file_meas.h"
31 #include "tcg/tcg_pts_attr_req_file_meta.h"
32 #include "tcg/tcg_pts_attr_unix_file_meta.h"
33
34 ENUM_BEGIN(tcg_attr_names, TCG_SCAP_REFERENCES,
35 TCG_SCAP_SUMMARY_RESULTS,
36 "SCAP References",
37 "SCAP Capabilities and Inventory",
38 "SCAP Content",
39 "SCAP Assessment",
40 "SCAP Results",
41 "SCAP Summary Results");
42 ENUM_NEXT(tcg_attr_names, TCG_SWID_INVENTORY_REQUEST,
43 TCG_SWID_TAG_IDENTIFIER_RESPONSE,
44 TCG_SCAP_SUMMARY_RESULTS,
45 "SWID Inventory Request",
46 "SWID Tag Response",
47 "SWID Tag Identifier Response");
48 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FUNC_COMP_EVID,
49 TCG_PTS_REQ_FUNC_COMP_EVID,
50 TCG_SWID_TAG_IDENTIFIER_RESPONSE,
51 "Request Functional Component Evidence");
52 ENUM_NEXT(tcg_attr_names, TCG_PTS_GEN_ATTEST_EVID,
53 TCG_PTS_GEN_ATTEST_EVID,
54 TCG_PTS_REQ_FUNC_COMP_EVID,
55 "Generate Attestation Evidence");
56 ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_COMP_EVID,
57 TCG_PTS_SIMPLE_COMP_EVID,
58 TCG_PTS_GEN_ATTEST_EVID,
59 "Simple Component Evidence");
60 ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_EVID_FINAL,
61 TCG_PTS_SIMPLE_EVID_FINAL,
62 TCG_PTS_SIMPLE_COMP_EVID,
63 "Simple Evidence Final");
64 ENUM_NEXT(tcg_attr_names, TCG_PTS_VERIFICATION_RESULT,
65 TCG_PTS_VERIFICATION_RESULT,
66 TCG_PTS_SIMPLE_EVID_FINAL,
67 "Verification Result");
68 ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_REPORT,
69 TCG_PTS_INTEG_REPORT,
70 TCG_PTS_VERIFICATION_RESULT,
71 "Integrity Report");
72 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_META,
73 TCG_PTS_REQ_FILE_META,
74 TCG_PTS_INTEG_REPORT,
75 "Request File Metadata");
76 ENUM_NEXT(tcg_attr_names, TCG_PTS_WIN_FILE_META,
77 TCG_PTS_WIN_FILE_META,
78 TCG_PTS_REQ_FILE_META,
79 "Windows-Style File Metadata");
80 ENUM_NEXT(tcg_attr_names, TCG_PTS_UNIX_FILE_META,
81 TCG_PTS_UNIX_FILE_META,
82 TCG_PTS_WIN_FILE_META,
83 "Unix-Style File Metadata");
84 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_REGISTRY_VALUE,
85 TCG_PTS_REQ_REGISTRY_VALUE,
86 TCG_PTS_UNIX_FILE_META,
87 "Request Registry Value");
88 ENUM_NEXT(tcg_attr_names, TCG_PTS_REGISTRY_VALUE,
89 TCG_PTS_REGISTRY_VALUE,
90 TCG_PTS_REQ_REGISTRY_VALUE,
91 "Registry Value");
92 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_MEAS,
93 TCG_PTS_REQ_FILE_MEAS,
94 TCG_PTS_REGISTRY_VALUE,
95 "Request File Measurement");
96 ENUM_NEXT(tcg_attr_names, TCG_PTS_FILE_MEAS,
97 TCG_PTS_FILE_MEAS,
98 TCG_PTS_REQ_FILE_MEAS,
99 "File Measurement");
100 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_INTEG_MEAS_LOG,
101 TCG_PTS_REQ_INTEG_MEAS_LOG,
102 TCG_PTS_FILE_MEAS,
103 "Request Integrity Measurement Log");
104 ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_MEAS_LOG,
105 TCG_PTS_INTEG_MEAS_LOG,
106 TCG_PTS_REQ_INTEG_MEAS_LOG,
107 "Integrity Measurement Log");
108 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_PROTO_CAPS,
109 TCG_PTS_REQ_PROTO_CAPS,
110 TCG_PTS_INTEG_MEAS_LOG,
111 "Request PTS Protocol Capabilities");
112 ENUM_NEXT(tcg_attr_names, TCG_PTS_PROTO_CAPS,
113 TCG_PTS_PROTO_CAPS,
114 TCG_PTS_REQ_PROTO_CAPS,
115 "PTS Protocol Capabilities");
116 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_REQ,
117 TCG_PTS_DH_NONCE_PARAMS_REQ,
118 TCG_PTS_PROTO_CAPS,
119 "DH Nonce Parameters Request");
120 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_RESP,
121 TCG_PTS_DH_NONCE_PARAMS_RESP,
122 TCG_PTS_DH_NONCE_PARAMS_REQ,
123 "DH Nonce Parameters Response");
124 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_FINISH,
125 TCG_PTS_DH_NONCE_FINISH,
126 TCG_PTS_DH_NONCE_PARAMS_RESP,
127 "DH Nonce Finish");
128 ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO,
129 TCG_PTS_MEAS_ALGO,
130 TCG_PTS_DH_NONCE_FINISH,
131 "PTS Measurement Algorithm Request");
132 ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO_SELECTION,
133 TCG_PTS_MEAS_ALGO_SELECTION,
134 TCG_PTS_MEAS_ALGO,
135 "PTS Measurement Algorithm");
136 ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_TPM_VERSION_INFO,
137 TCG_PTS_GET_TPM_VERSION_INFO,
138 TCG_PTS_MEAS_ALGO_SELECTION,
139 "Get TPM Version Information");
140 ENUM_NEXT(tcg_attr_names, TCG_PTS_TPM_VERSION_INFO,
141 TCG_PTS_TPM_VERSION_INFO,
142 TCG_PTS_GET_TPM_VERSION_INFO,
143 "TPM Version Information");
144 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
145 TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
146 TCG_PTS_TPM_VERSION_INFO,
147 "Request Template Reference Manifest Set Metadata");
148 ENUM_NEXT(tcg_attr_names, TCG_PTS_TEMPL_REF_MANI_SET_META,
149 TCG_PTS_TEMPL_REF_MANI_SET_META,
150 TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
151 "Template Reference Manifest Set Metadata");
152 ENUM_NEXT(tcg_attr_names, TCG_PTS_UPDATE_TEMPL_REF_MANI,
153 TCG_PTS_UPDATE_TEMPL_REF_MANI,
154 TCG_PTS_TEMPL_REF_MANI_SET_META,
155 "Update Template Reference Manifest");
156 ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_AIK,
157 TCG_PTS_GET_AIK,
158 TCG_PTS_UPDATE_TEMPL_REF_MANI,
159 "Get Attestation Identity Key");
160 ENUM_NEXT(tcg_attr_names, TCG_PTS_AIK,
161 TCG_PTS_AIK,
162 TCG_PTS_GET_AIK,
163 "Attestation Identity Key");
164 ENUM_END(tcg_attr_names, TCG_PTS_AIK);
165
166 /**
167 * See header
168 */
169 pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value)
170 {
171 switch (type)
172 {
173 case TCG_PTS_REQ_PROTO_CAPS:
174 return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
175 case TCG_PTS_PROTO_CAPS:
176 return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
177 case TCG_PTS_DH_NONCE_PARAMS_REQ:
178 return tcg_pts_attr_dh_nonce_params_req_create_from_data(value);
179 case TCG_PTS_DH_NONCE_PARAMS_RESP:
180 return tcg_pts_attr_dh_nonce_params_resp_create_from_data(value);
181 case TCG_PTS_DH_NONCE_FINISH:
182 return tcg_pts_attr_dh_nonce_finish_create_from_data(value);
183 case TCG_PTS_MEAS_ALGO:
184 return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
185 case TCG_PTS_MEAS_ALGO_SELECTION:
186 return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
187 case TCG_PTS_GET_TPM_VERSION_INFO:
188 return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
189 case TCG_PTS_TPM_VERSION_INFO:
190 return tcg_pts_attr_tpm_version_info_create_from_data(value);
191 case TCG_PTS_GET_AIK:
192 return tcg_pts_attr_get_aik_create_from_data(value);
193 case TCG_PTS_AIK:
194 return tcg_pts_attr_aik_create_from_data(value);
195 case TCG_PTS_REQ_FUNC_COMP_EVID:
196 return tcg_pts_attr_req_func_comp_evid_create_from_data(value);
197 case TCG_PTS_GEN_ATTEST_EVID:
198 return tcg_pts_attr_gen_attest_evid_create_from_data(value);
199 case TCG_PTS_SIMPLE_COMP_EVID:
200 return tcg_pts_attr_simple_comp_evid_create_from_data(value);
201 case TCG_PTS_SIMPLE_EVID_FINAL:
202 return tcg_pts_attr_simple_evid_final_create_from_data(value);
203 case TCG_PTS_REQ_FILE_MEAS:
204 return tcg_pts_attr_req_file_meas_create_from_data(value);
205 case TCG_PTS_FILE_MEAS:
206 return tcg_pts_attr_file_meas_create_from_data(value);
207 case TCG_PTS_REQ_FILE_META:
208 return tcg_pts_attr_req_file_meta_create_from_data(value);
209 case TCG_PTS_UNIX_FILE_META:
210 return tcg_pts_attr_unix_file_meta_create_from_data(value);
211 case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
212 case TCG_PTS_TEMPL_REF_MANI_SET_META:
213 case TCG_PTS_UPDATE_TEMPL_REF_MANI:
214 case TCG_PTS_VERIFICATION_RESULT:
215 case TCG_PTS_INTEG_REPORT:
216 case TCG_PTS_WIN_FILE_META:
217 case TCG_PTS_REQ_REGISTRY_VALUE:
218 case TCG_PTS_REGISTRY_VALUE:
219 case TCG_PTS_REQ_INTEG_MEAS_LOG:
220 case TCG_PTS_INTEG_MEAS_LOG:
221 default:
222 return NULL;
223 }
224 }