created libpts
[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 "ietf/ietf_attr_product_info.h"
21
22 #ifdef USE_PTS
23 #include "tcg/tcg_attr.h"
24 #include "tcg/tcg_pts_attr_proto_caps.h"
25 #include "tcg/tcg_pts_attr_meas_algo.h"
26 #include "tcg/tcg_pts_attr_get_tpm_version_info.h"
27 #include "tcg/tcg_pts_attr_tpm_version_info.h"
28 #include "tcg/tcg_pts_attr_get_aik.h"
29 #include "tcg/tcg_pts_attr_aik.h"
30 #include "tcg/tcg_pts_attr_req_funct_comp_evid.h"
31 #include "tcg/tcg_pts_attr_gen_attest_evid.h"
32 #include "tcg/tcg_pts_attr_simple_comp_evid.h"
33 #include "tcg/tcg_pts_attr_simple_evid_final.h"
34 #include "tcg/tcg_pts_attr_req_file_meas.h"
35 #include "tcg/tcg_pts_attr_file_meas.h"
36 #endif /* USE_PTS */
37
38 #include "ita/ita_attr.h"
39 #include "ita/ita_attr_command.h"
40
41 /**
42 * See header
43 */
44 pa_tnc_attr_t* pa_tnc_attr_create_from_data(pen_t vendor_id, u_int32_t type,
45 chunk_t value)
46 {
47 switch (vendor_id)
48 {
49 case PEN_IETF:
50 switch (type)
51 {
52 case IETF_ATTR_PORT_FILTER:
53 return ietf_attr_port_filter_create_from_data(value);
54 case IETF_ATTR_PA_TNC_ERROR:
55 return ietf_attr_pa_tnc_error_create_from_data(value);
56 case IETF_ATTR_PRODUCT_INFORMATION:
57 return ietf_attr_product_info_create_from_data(value);
58 case IETF_ATTR_TESTING:
59 case IETF_ATTR_ATTRIBUTE_REQUEST:
60 case IETF_ATTR_NUMERIC_VERSION:
61 case IETF_ATTR_STRING_VERSION:
62 case IETF_ATTR_OPERATIONAL_STATUS:
63 case IETF_ATTR_INSTALLED_PACKAGES:
64 case IETF_ATTR_ASSESSMENT_RESULT:
65 case IETF_ATTR_REMEDIATION_INSTRUCTIONS:
66 case IETF_ATTR_FORWARDING_ENABLED:
67 case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
68 case IETF_ATTR_RESERVED:
69 default:
70 break;
71 }
72 break;
73 #ifdef USE_PTS
74 case PEN_TCG:
75 switch (type)
76 {
77 case TCG_PTS_REQ_PROTO_CAPS:
78 return tcg_pts_attr_proto_caps_create_from_data(value, TRUE);
79 case TCG_PTS_PROTO_CAPS:
80 return tcg_pts_attr_proto_caps_create_from_data(value, FALSE);
81 case TCG_PTS_MEAS_ALGO:
82 return tcg_pts_attr_meas_algo_create_from_data(value, FALSE);
83 case TCG_PTS_MEAS_ALGO_SELECTION:
84 return tcg_pts_attr_meas_algo_create_from_data(value, TRUE);
85 case TCG_PTS_GET_TPM_VERSION_INFO:
86 return tcg_pts_attr_get_tpm_version_info_create_from_data(value);
87 case TCG_PTS_TPM_VERSION_INFO:
88 return tcg_pts_attr_tpm_version_info_create_from_data(value);
89 case TCG_PTS_GET_AIK:
90 return tcg_pts_attr_get_aik_create_from_data(value);
91 case TCG_PTS_AIK:
92 return tcg_pts_attr_aik_create_from_data(value);
93 case TCG_PTS_REQ_FUNCT_COMP_EVID:
94 return tcg_pts_attr_req_funct_comp_evid_create_from_data(value);
95 case TCG_PTS_GEN_ATTEST_EVID:
96 return tcg_pts_attr_gen_attest_evid_create_from_data(value);
97 case TCG_PTS_SIMPLE_COMP_EVID:
98 return tcg_pts_attr_simple_comp_evid_create_from_data(value);
99 case TCG_PTS_SIMPLE_EVID_FINAL:
100 return tcg_pts_attr_simple_evid_final_create_from_data(value);
101 case TCG_PTS_REQ_FILE_MEAS:
102 return tcg_pts_attr_req_file_meas_create_from_data(value);
103 case TCG_PTS_FILE_MEAS:
104 return tcg_pts_attr_file_meas_create_from_data(value);
105 case TCG_PTS_DH_NONCE_PARAMS_REQ:
106 case TCG_PTS_DH_NONCE_PARAMS_RESP:
107 case TCG_PTS_DH_NONCE_FINISH:
108 case TCG_PTS_REQ_TEMPL_REF_MANI_SET_META:
109 case TCG_PTS_TEMPL_REF_MANI_SET_META:
110 case TCG_PTS_UPDATE_TEMPL_REF_MANI:
111 case TCG_PTS_VERIFICATION_RESULT:
112 case TCG_PTS_INTEG_REPORT:
113 case TCG_PTS_REQ_FILE_META:
114 case TCG_PTS_WIN_FILE_META:
115 case TCG_PTS_UNIX_FILE_META:
116 case TCG_PTS_REQ_REGISTRY_VALUE:
117 case TCG_PTS_REGISTRY_VALUE:
118 case TCG_PTS_REQ_INTEG_MEAS_LOG:
119 case TCG_PTS_INTEG_MEAS_LOG:
120 default:
121 break;
122 }
123 break;
124 #endif /* HAVE _PTS */
125 case PEN_ITA:
126 switch (type)
127 {
128 case ITA_ATTR_COMMAND:
129 return ita_attr_command_create_from_data(value);
130 default:
131 break;
132 }
133 break;
134 default:
135 break;
136 }
137 return NULL;
138 }