/src/ibmswtpm2/src/CapabilityCommands.c
Line | Count | Source |
1 | | /********************************************************************************/ |
2 | | /* */ |
3 | | /* Capability Commands */ |
4 | | /* Written by Ken Goldman */ |
5 | | /* IBM Thomas J. Watson Research Center */ |
6 | | /* $Id: CapabilityCommands.c 1262 2018-07-11 21:03:43Z kgoldman $ */ |
7 | | /* */ |
8 | | /* Licenses and Notices */ |
9 | | /* */ |
10 | | /* 1. Copyright Licenses: */ |
11 | | /* */ |
12 | | /* - Trusted Computing Group (TCG) grants to the user of the source code in */ |
13 | | /* this specification (the "Source Code") a worldwide, irrevocable, */ |
14 | | /* nonexclusive, royalty free, copyright license to reproduce, create */ |
15 | | /* derivative works, distribute, display and perform the Source Code and */ |
16 | | /* derivative works thereof, and to grant others the rights granted herein. */ |
17 | | /* */ |
18 | | /* - The TCG grants to the user of the other parts of the specification */ |
19 | | /* (other than the Source Code) the rights to reproduce, distribute, */ |
20 | | /* display, and perform the specification solely for the purpose of */ |
21 | | /* developing products based on such documents. */ |
22 | | /* */ |
23 | | /* 2. Source Code Distribution Conditions: */ |
24 | | /* */ |
25 | | /* - Redistributions of Source Code must retain the above copyright licenses, */ |
26 | | /* this list of conditions and the following disclaimers. */ |
27 | | /* */ |
28 | | /* - Redistributions in binary form must reproduce the above copyright */ |
29 | | /* licenses, this list of conditions and the following disclaimers in the */ |
30 | | /* documentation and/or other materials provided with the distribution. */ |
31 | | /* */ |
32 | | /* 3. Disclaimers: */ |
33 | | /* */ |
34 | | /* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */ |
35 | | /* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */ |
36 | | /* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */ |
37 | | /* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */ |
38 | | /* Contact TCG Administration (admin@trustedcomputinggroup.org) for */ |
39 | | /* information on specification licensing rights available through TCG */ |
40 | | /* membership agreements. */ |
41 | | /* */ |
42 | | /* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */ |
43 | | /* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */ |
44 | | /* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */ |
45 | | /* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */ |
46 | | /* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */ |
47 | | /* */ |
48 | | /* - Without limitation, TCG and its members and licensors disclaim all */ |
49 | | /* liability, including liability for infringement of any proprietary */ |
50 | | /* rights, relating to use of information in this specification and to the */ |
51 | | /* implementation of this specification, and TCG disclaims all liability for */ |
52 | | /* cost of procurement of substitute goods or services, lost profits, loss */ |
53 | | /* of use, loss of data or any incidental, consequential, direct, indirect, */ |
54 | | /* or special damages, whether under contract, tort, warranty or otherwise, */ |
55 | | /* arising in any way out of use or reliance upon this specification or any */ |
56 | | /* information herein. */ |
57 | | /* */ |
58 | | /* (c) Copyright IBM Corp. and others, 2016 - 2018 */ |
59 | | /* */ |
60 | | /********************************************************************************/ |
61 | | |
62 | | #include "Tpm.h" |
63 | | #include "GetCapability_fp.h" |
64 | | #if CC_GetCapability // Conditional expansion of this file |
65 | | TPM_RC |
66 | | TPM2_GetCapability( |
67 | | GetCapability_In *in, // IN: input parameter list |
68 | | GetCapability_Out *out // OUT: output parameter list |
69 | | ) |
70 | 0 | { |
71 | 0 | TPMU_CAPABILITIES *data = &out->capabilityData.data; |
72 | | // Command Output |
73 | | // Set output capability type the same as input type |
74 | 0 | out->capabilityData.capability = in->capability; |
75 | 0 | switch(in->capability) |
76 | 0 | { |
77 | 0 | case TPM_CAP_ALGS: |
78 | 0 | out->moreData = AlgorithmCapGetImplemented((TPM_ALG_ID)in->property, |
79 | 0 | in->propertyCount, |
80 | 0 | &data->algorithms); |
81 | 0 | break; |
82 | 0 | case TPM_CAP_HANDLES: |
83 | 0 | switch(HandleGetType((TPM_HANDLE)in->property)) |
84 | 0 | { |
85 | 0 | case TPM_HT_TRANSIENT: |
86 | | // Get list of handles of loaded transient objects |
87 | 0 | out->moreData = ObjectCapGetLoaded((TPM_HANDLE)in->property, |
88 | 0 | in->propertyCount, |
89 | 0 | &data->handles); |
90 | 0 | break; |
91 | 0 | case TPM_HT_PERSISTENT: |
92 | | // Get list of handles of persistent objects |
93 | 0 | out->moreData = NvCapGetPersistent((TPM_HANDLE)in->property, |
94 | 0 | in->propertyCount, |
95 | 0 | &data->handles); |
96 | 0 | break; |
97 | 0 | case TPM_HT_NV_INDEX: |
98 | | // Get list of defined NV index |
99 | 0 | out->moreData = NvCapGetIndex((TPM_HANDLE)in->property, |
100 | 0 | in->propertyCount, |
101 | 0 | &data->handles); |
102 | 0 | break; |
103 | 0 | case TPM_HT_LOADED_SESSION: |
104 | | // Get list of handles of loaded sessions |
105 | 0 | out->moreData = SessionCapGetLoaded((TPM_HANDLE)in->property, |
106 | 0 | in->propertyCount, |
107 | 0 | &data->handles); |
108 | 0 | break; |
109 | 0 | #ifdef TPM_HT_SAVED_SESSION |
110 | 0 | case TPM_HT_SAVED_SESSION: |
111 | | #else |
112 | | case TPM_HT_ACTIVE_SESSION: |
113 | | #endif |
114 | | // Get list of handles of |
115 | 0 | out->moreData = SessionCapGetSaved((TPM_HANDLE)in->property, |
116 | 0 | in->propertyCount, |
117 | 0 | &data->handles); |
118 | 0 | break; |
119 | 0 | case TPM_HT_PCR: |
120 | | // Get list of handles of PCR |
121 | 0 | out->moreData = PCRCapGetHandles((TPM_HANDLE)in->property, |
122 | 0 | in->propertyCount, |
123 | 0 | &data->handles); |
124 | 0 | break; |
125 | 0 | case TPM_HT_PERMANENT: |
126 | | // Get list of permanent handles |
127 | 0 | out->moreData = PermanentCapGetHandles((TPM_HANDLE)in->property, |
128 | 0 | in->propertyCount, |
129 | 0 | &data->handles); |
130 | 0 | break; |
131 | 0 | default: |
132 | | // Unsupported input handle type |
133 | 0 | return TPM_RCS_HANDLE + RC_GetCapability_property; |
134 | 0 | break; |
135 | 0 | } |
136 | 0 | break; |
137 | 0 | case TPM_CAP_COMMANDS: |
138 | 0 | out->moreData = CommandCapGetCCList((TPM_CC)in->property, |
139 | 0 | in->propertyCount, |
140 | 0 | &data->command); |
141 | 0 | break; |
142 | 0 | case TPM_CAP_PP_COMMANDS: |
143 | 0 | out->moreData = PhysicalPresenceCapGetCCList((TPM_CC)in->property, |
144 | 0 | in->propertyCount, |
145 | 0 | &data->ppCommands); |
146 | 0 | break; |
147 | 0 | case TPM_CAP_AUDIT_COMMANDS: |
148 | 0 | out->moreData = CommandAuditCapGetCCList((TPM_CC)in->property, |
149 | 0 | in->propertyCount, |
150 | 0 | &data->auditCommands); |
151 | 0 | break; |
152 | 0 | case TPM_CAP_PCRS: |
153 | | // Input property must be 0 |
154 | 0 | if(in->property != 0) |
155 | 0 | return TPM_RCS_VALUE + RC_GetCapability_property; |
156 | 0 | out->moreData = PCRCapGetAllocation(in->propertyCount, |
157 | 0 | &data->assignedPCR); |
158 | 0 | break; |
159 | 0 | case TPM_CAP_PCR_PROPERTIES: |
160 | 0 | out->moreData = PCRCapGetProperties((TPM_PT_PCR)in->property, |
161 | 0 | in->propertyCount, |
162 | 0 | &data->pcrProperties); |
163 | 0 | break; |
164 | 0 | case TPM_CAP_TPM_PROPERTIES: |
165 | 0 | out->moreData = TPMCapGetProperties((TPM_PT)in->property, |
166 | 0 | in->propertyCount, |
167 | 0 | &data->tpmProperties); |
168 | 0 | break; |
169 | 0 | #if ALG_ECC |
170 | 0 | case TPM_CAP_ECC_CURVES: |
171 | 0 | out->moreData = CryptCapGetECCCurve((TPM_ECC_CURVE)in->property, |
172 | 0 | in->propertyCount, |
173 | 0 | &data->eccCurves); |
174 | 0 | break; |
175 | 0 | #endif // TPM_ALG_ECC |
176 | 0 | case TPM_CAP_AUTH_POLICIES: |
177 | 0 | if(HandleGetType((TPM_HANDLE)in->property) != TPM_HT_PERMANENT) |
178 | 0 | return TPM_RCS_VALUE + RC_GetCapability_property; |
179 | 0 | out->moreData = PermanentHandleGetPolicy((TPM_HANDLE)in->property, |
180 | 0 | in->propertyCount, |
181 | 0 | &data->authPolicies); |
182 | 0 | break; |
183 | 0 | case TPM_CAP_VENDOR_PROPERTY: |
184 | | // vendor property is not implemented |
185 | 0 | default: |
186 | | // Unsupported TPM_CAP value |
187 | 0 | return TPM_RCS_VALUE + RC_GetCapability_capability; |
188 | 0 | break; |
189 | 0 | } |
190 | 0 | return TPM_RC_SUCCESS; |
191 | 0 | } |
192 | | #endif // CC_GetCapability |
193 | | #include "Tpm.h" |
194 | | #include "TestParms_fp.h" |
195 | | #if CC_TestParms // Conditional expansion of this file |
196 | | TPM_RC |
197 | | TPM2_TestParms( |
198 | | TestParms_In *in // IN: input parameter list |
199 | | ) |
200 | 0 | { |
201 | | // Input parameter is not reference in command action |
202 | 0 | NOT_REFERENCED(in); |
203 | | // The parameters are tested at unmarshal process. We do nothing in command |
204 | | // action |
205 | 0 | return TPM_RC_SUCCESS; |
206 | 0 | } |
207 | | #endif // CC_TestParms |