Updated the SWID 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_REQUEST,
43 TCG_SWID_TAG_EVENTS,
44 TCG_SCAP_SUMMARY_RESULTS,
45 "SWID Request",
46 "SWID Tag Identifier Inventory",
47 "SWID Tag Identifier Events",
48 "SWID Tag Inventory",
49 "SWID Tag Events");
50 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FUNC_COMP_EVID,
51 TCG_PTS_REQ_FUNC_COMP_EVID,
52 TCG_SWID_TAG_EVENTS,
53 "Request Functional Component Evidence");
54 ENUM_NEXT(tcg_attr_names, TCG_PTS_GEN_ATTEST_EVID,
55 TCG_PTS_GEN_ATTEST_EVID,
56 TCG_PTS_REQ_FUNC_COMP_EVID,
57 "Generate Attestation Evidence");
58 ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_COMP_EVID,
59 TCG_PTS_SIMPLE_COMP_EVID,
60 TCG_PTS_GEN_ATTEST_EVID,
61 "Simple Component Evidence");
62 ENUM_NEXT(tcg_attr_names, TCG_PTS_SIMPLE_EVID_FINAL,
63 TCG_PTS_SIMPLE_EVID_FINAL,
64 TCG_PTS_SIMPLE_COMP_EVID,
65 "Simple Evidence Final");
66 ENUM_NEXT(tcg_attr_names, TCG_PTS_VERIFICATION_RESULT,
67 TCG_PTS_VERIFICATION_RESULT,
68 TCG_PTS_SIMPLE_EVID_FINAL,
69 "Verification Result");
70 ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_REPORT,
71 TCG_PTS_INTEG_REPORT,
72 TCG_PTS_VERIFICATION_RESULT,
73 "Integrity Report");
74 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_META,
75 TCG_PTS_REQ_FILE_META,
76 TCG_PTS_INTEG_REPORT,
77 "Request File Metadata");
78 ENUM_NEXT(tcg_attr_names, TCG_PTS_WIN_FILE_META,
79 TCG_PTS_WIN_FILE_META,
80 TCG_PTS_REQ_FILE_META,
81 "Windows-Style File Metadata");
82 ENUM_NEXT(tcg_attr_names, TCG_PTS_UNIX_FILE_META,
83 TCG_PTS_UNIX_FILE_META,
84 TCG_PTS_WIN_FILE_META,
85 "Unix-Style File Metadata");
86 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_REGISTRY_VALUE,
87 TCG_PTS_REQ_REGISTRY_VALUE,
88 TCG_PTS_UNIX_FILE_META,
89 "Request Registry Value");
90 ENUM_NEXT(tcg_attr_names, TCG_PTS_REGISTRY_VALUE,
91 TCG_PTS_REGISTRY_VALUE,
92 TCG_PTS_REQ_REGISTRY_VALUE,
93 "Registry Value");
94 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_FILE_MEAS,
95 TCG_PTS_REQ_FILE_MEAS,
96 TCG_PTS_REGISTRY_VALUE,
97 "Request File Measurement");
98 ENUM_NEXT(tcg_attr_names, TCG_PTS_FILE_MEAS,
99 TCG_PTS_FILE_MEAS,
100 TCG_PTS_REQ_FILE_MEAS,
101 "File Measurement");
102 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_INTEG_MEAS_LOG,
103 TCG_PTS_REQ_INTEG_MEAS_LOG,
104 TCG_PTS_FILE_MEAS,
105 "Request Integrity Measurement Log");
106 ENUM_NEXT(tcg_attr_names, TCG_PTS_INTEG_MEAS_LOG,
107 TCG_PTS_INTEG_MEAS_LOG,
108 TCG_PTS_REQ_INTEG_MEAS_LOG,
109 "Integrity Measurement Log");
110 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_PROTO_CAPS,
111 TCG_PTS_REQ_PROTO_CAPS,
112 TCG_PTS_INTEG_MEAS_LOG,
113 "Request PTS Protocol Capabilities");
114 ENUM_NEXT(tcg_attr_names, TCG_PTS_PROTO_CAPS,
115 TCG_PTS_PROTO_CAPS,
116 TCG_PTS_REQ_PROTO_CAPS,
117 "PTS Protocol Capabilities");
118 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_REQ,
119 TCG_PTS_DH_NONCE_PARAMS_REQ,
120 TCG_PTS_PROTO_CAPS,
121 "DH Nonce Parameters Request");
122 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_PARAMS_RESP,
123 TCG_PTS_DH_NONCE_PARAMS_RESP,
124 TCG_PTS_DH_NONCE_PARAMS_REQ,
125 "DH Nonce Parameters Response");
126 ENUM_NEXT(tcg_attr_names, TCG_PTS_DH_NONCE_FINISH,
127 TCG_PTS_DH_NONCE_FINISH,
128 TCG_PTS_DH_NONCE_PARAMS_RESP,
129 "DH Nonce Finish");
130 ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO,
131 TCG_PTS_MEAS_ALGO,
132 TCG_PTS_DH_NONCE_FINISH,
133 "PTS Measurement Algorithm Request");
134 ENUM_NEXT(tcg_attr_names, TCG_PTS_MEAS_ALGO_SELECTION,
135 TCG_PTS_MEAS_ALGO_SELECTION,
136 TCG_PTS_MEAS_ALGO,
137 "PTS Measurement Algorithm");
138 ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_TPM_VERSION_INFO,
139 TCG_PTS_GET_TPM_VERSION_INFO,
140 TCG_PTS_MEAS_ALGO_SELECTION,
141 "Get TPM Version Information");
142 ENUM_NEXT(tcg_attr_names, TCG_PTS_TPM_VERSION_INFO,
143 TCG_PTS_TPM_VERSION_INFO,
144 TCG_PTS_GET_TPM_VERSION_INFO,
145 "TPM Version Information");
146 ENUM_NEXT(tcg_attr_names, TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
147 TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
148 TCG_PTS_TPM_VERSION_INFO,
149 "Request Template Reference Manifest Set Metadata");
150 ENUM_NEXT(tcg_attr_names, TCG_PTS_TEMPL_REF_MANI_SET_META,
151 TCG_PTS_TEMPL_REF_MANI_SET_META,
152 TCG_PTS_REQ_TEMPL_REF_MANI_SET_META,
153 "Template Reference Manifest Set Metadata");
154 ENUM_NEXT(tcg_attr_names, TCG_PTS_UPDATE_TEMPL_REF_MANI,
155 TCG_PTS_UPDATE_TEMPL_REF_MANI,
156 TCG_PTS_TEMPL_REF_MANI_SET_META,
157 "Update Template Reference Manifest");
158 ENUM_NEXT(tcg_attr_names, TCG_PTS_GET_AIK,
159 TCG_PTS_GET_AIK,
160 TCG_PTS_UPDATE_TEMPL_REF_MANI,
161 "Get Attestation Identity Key");
162 ENUM_NEXT(tcg_attr_names, TCG_PTS_AIK,
163 TCG_PTS_AIK,
164 TCG_PTS_GET_AIK,
165 "Attestation Identity Key");
166 ENUM_END(tcg_attr_names, TCG_PTS_AIK);
167
168 /**
169 * See header
170 */
171 pa_tnc_attr_t* tcg_attr_create_from_data(u_int32_t type, chunk_t value)
172 {
173 switch (type)
174 {
175 case TCG_PTS_REQ_PROTO_CAPS:
176 return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
177 case TCG_PTS_PROTO_CAPS:
178 return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
179 case TCG_PTS_DH_NONCE_PARAMS_REQ:
180 return tcg_pts_attr_dh_nonce_params_req_create_from_data(value);
181 case TCG_PTS_DH_NONCE_PARAMS_RESP:
182 return tcg_pts_attr_dh_nonce_params_resp_create_from_data(value);
183 case TCG_PTS_DH_NONCE_FINISH:
184 return tcg_pts_attr_dh_nonce_finish_create_from_data(value);
185 case TCG_PTS_MEAS_ALGO:
186 return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
187 case TCG_PTS_MEAS_ALGO_SELECTION:
188 return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
189 case TCG_PTS_GET_TPM_VERSION_INFO:
190 return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
191 case TCG_PTS_TPM_VERSION_INFO:
192 return tcg_pts_attr_tpm_version_info_create_from_data(value);
193 case TCG_PTS_GET_AIK:
194 return tcg_pts_attr_get_aik_create_from_data(value);
195 case TCG_PTS_AIK:
196 return tcg_pts_attr_aik_create_from_data(value);
197 case TCG_PTS_REQ_FUNC_COMP_EVID:
198 return tcg_pts_attr_req_func_comp_evid_create_from_data(value);
199 case TCG_PTS_GEN_ATTEST_EVID:
200 return tcg_pts_attr_gen_attest_evid_create_from_data(value);
201 case TCG_PTS_SIMPLE_COMP_EVID:
202 return tcg_pts_attr_simple_comp_evid_create_from_data(value);
203 case TCG_PTS_SIMPLE_EVID_FINAL:
204 return tcg_pts_attr_simple_evid_final_create_from_data(value);
205 case TCG_PTS_REQ_FILE_MEAS:
206 return tcg_pts_attr_req_file_meas_create_from_data(value);
207 case TCG_PTS_FILE_MEAS:
208 return tcg_pts_attr_file_meas_create_from_data(value);
209 case TCG_PTS_REQ_FILE_META:
210 return tcg_pts_attr_req_file_meta_create_from_data(value);
211 case TCG_PTS_UNIX_FILE_META:
212 return tcg_pts_attr_unix_file_meta_create_from_data(value);
213 case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
214 case TCG_PTS_TEMPL_REF_MANI_SET_META:
215 case TCG_PTS_UPDATE_TEMPL_REF_MANI:
216 case TCG_PTS_VERIFICATION_RESULT:
217 case TCG_PTS_INTEG_REPORT:
218 case TCG_PTS_WIN_FILE_META:
219 case TCG_PTS_REQ_REGISTRY_VALUE:
220 case TCG_PTS_REGISTRY_VALUE:
221 case TCG_PTS_REQ_INTEG_MEAS_LOG:
222 case TCG_PTS_INTEG_MEAS_LOG:
223 default:
224 return NULL;
225 }
226 }