refactored PTS measurement algorithms
[strongswan.git] / src / libimcv / pa_tnc / pa_tnc_attr.c
1 /*
2 * Copyright (C) 2011 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "pa_tnc_attr.h"
17 #include "ietf/ietf_attr.h"
18 #include "ietf/ietf_attr_pa_tnc_error.h"
19 #include "ietf/ietf_attr_port_filter.h"
20 #include "tcg/tcg_attr.h"
21 #include "tcg/tcg_pts_attr_req_proto_caps.h"
22 #include "tcg/tcg_pts_attr_proto_caps.h"
23 #include "tcg/tcg_pts_attr_meas_algo.h"
24 #include "tcg/tcg_pts_attr_get_tpm_version_info.h"
25 #include "tcg/tcg_pts_attr_tpm_version_info.h"
26 #include "tcg/tcg_pts_attr_get_aik.h"
27 #include "tcg/tcg_pts_attr_aik.h"
28 #include "tcg/tcg_pts_attr_req_funct_comp_evid.h"
29 #include "tcg/tcg_pts_attr_gen_attest_evid.h"
30 #include "tcg/tcg_pts_attr_simple_comp_evid.h"
31 #include "tcg/tcg_pts_attr_simple_evid_final.h"
32 #include "tcg/tcg_pts_attr_req_file_meas.h"
33 #include "tcg/tcg_pts_attr_file_meas.h"
34 #include "ita/ita_attr_command.h"
35
36 /**
37 * See header
38 */
39 pa_tnc_attr_t* pa_tnc_attr_create_create_from_data(pen_t vendor_id, u_int32_t type,
40 chunk_t value)
41 {
42 switch (vendor_id)
43 {
44 case PEN_IETF:
45 switch (type)
46 {
47 case IETF_ATTR_PORT_FILTER:
48 return ietf_attr_port_filter_create_from_data(value);
49 case IETF_ATTR_PA_TNC_ERROR:
50 return ietf_attr_pa_tnc_error_create_from_data(value);
51 case IETF_ATTR_TESTING:
52 case IETF_ATTR_ATTRIBUTE_REQUEST:
53 case IETF_ATTR_PRODUCT_INFORMATION:
54 case IETF_ATTR_NUMERIC_VERSION:
55 case IETF_ATTR_STRING_VERSION:
56 case IETF_ATTR_OPERATIONAL_STATUS:
57 case IETF_ATTR_INSTALLED_PACKAGES:
58 case IETF_ATTR_ASSESSMENT_RESULT:
59 case IETF_ATTR_REMEDIATION_INSTRUCTIONS:
60 case IETF_ATTR_FORWARDING_ENABLED:
61 case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
62 case IETF_ATTR_RESERVED:
63 default:
64 break;
65 }
66 break;
67 case PEN_TCG:
68 switch (type)
69 {
70 case TCG_PTS_REQ_PROTO_CAPS:
71 return tcg_pts_attr_req_proto_caps_create_from_data(value);
72 case TCG_PTS_PROTO_CAPS:
73 return tcg_pts_attr_proto_caps_create_from_data(value);
74 case TCG_PTS_MEAS_ALGO:
75 return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
76 case TCG_PTS_MEAS_ALGO_SELECTION:
77 return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
78 case TCG_PTS_GET_TPM_VERSION_INFO:
79 return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
80 case TCG_PTS_TPM_VERSION_INFO:
81 return tcg_pts_attr_tpm_version_info_create_from_data(value);
82 case TCG_PTS_GET_AIK:
83 return tcg_pts_attr_get_aik_create_from_data(value);
84 case TCG_PTS_AIK:
85 return tcg_pts_attr_aik_create_from_data(value);
86 case TCG_PTS_REQ_FUNCT_COMP_EVID:
87 return tcg_pts_attr_req_funct_comp_evid_create_from_data(value);
88 case TCG_PTS_GEN_ATTEST_EVID:
89 return tcg_pts_attr_gen_attest_evid_create_from_data(value);
90 case TCG_PTS_SIMPLE_COMP_EVID:
91 return tcg_pts_attr_simple_comp_evid_create_from_data(value);
92 case TCG_PTS_SIMPLE_EVID_FINAL:
93 return tcg_pts_attr_simple_evid_final_create_from_data(value);
94 case TCG_PTS_REQ_FILE_MEAS:
95 return tcg_pts_attr_req_file_meas_create_from_data(value);
96 case TCG_PTS_FILE_MEAS:
97 return tcg_pts_attr_file_meas_create_from_data(value);
98 case TCG_PTS_DH_NONCE_PARAMS_REQ:
99 case TCG_PTS_DH_NONCE_PARAMS_RESP:
100 case TCG_PTS_DH_NONCE_FINISH:
101 case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
102 case TCG_PTS_TEMPL_REF_MANI_SET_META:
103 case TCG_PTS_UPDATE_TEMPL_REF_MANI:
104 case TCG_PTS_VERIFICATION_RESULT:
105 case TCG_PTS_INTEG_REPORT:
106 case TCG_PTS_REQ_FILE_META:
107 case TCG_PTS_WIN_FILE_META:
108 case TCG_PTS_UNIX_FILE_META:
109 case TCG_PTS_REQ_REGISTRY_VALUE:
110 case TCG_PTS_REGISTRY_VALUE:
111 case TCG_PTS_REQ_INTEG_MEAS_LOG:
112 case TCG_PTS_INTEG_MEAS_LOG:
113 default:
114 break;
115 }
116 break;
117 case PEN_ITA:
118 switch (type)
119 {
120 case ITA_ATTR_COMMAND:
121 return ita_attr_command_create_from_data(value);
122 default:
123 break;
124 }
125 break;
126 default:
127 break;
128 }
129 return NULL;
130 }