/src/tpm2/GetCapability.c
Line | Count | Source |
1 | | // This file was extracted from the TCG Published |
2 | | // Trusted Platform Module Library |
3 | | // Part 3: Commands |
4 | | // Family "2.0" |
5 | | // Level 00 Revision 01.16 |
6 | | // October 30, 2014 |
7 | | |
8 | | #include "InternalRoutines.h" |
9 | | #include "GetCapability_fp.h" |
10 | | // |
11 | | // |
12 | | // Error Returns Meaning |
13 | | // |
14 | | // TPM_RC_HANDLE value of property is in an unsupported handle range for the |
15 | | // TPM_CAP_HANDLES capability value |
16 | | // TPM_RC_VALUE invalid capability; or property is not 0 for the TPM_CAP_PCRS |
17 | | // capability value |
18 | | // |
19 | | TPM_RC |
20 | | TPM2_GetCapability( |
21 | | GetCapability_In *in, // IN: input parameter list |
22 | | GetCapability_Out *out // OUT: output parameter list |
23 | | ) |
24 | 0 | { |
25 | | // Command Output |
26 | | |
27 | | // Set output capability type the same as input type |
28 | 0 | out->capabilityData.capability = in->capability; |
29 | |
|
30 | 0 | switch(in->capability) |
31 | 0 | { |
32 | 0 | case TPM_CAP_ALGS: |
33 | 0 | out->moreData = AlgorithmCapGetImplemented((TPM_ALG_ID) in->property, |
34 | 0 | in->propertyCount, &out->capabilityData.data.algorithms); |
35 | 0 | break; |
36 | 0 | case TPM_CAP_HANDLES: |
37 | 0 | switch(HandleGetType((TPM_HANDLE) in->property)) |
38 | 0 | { |
39 | 0 | case TPM_HT_TRANSIENT: |
40 | | // Get list of handles of loaded transient objects |
41 | 0 | out->moreData = ObjectCapGetLoaded((TPM_HANDLE) in->property, |
42 | 0 | in->propertyCount, |
43 | 0 | &out->capabilityData.data.handles); |
44 | 0 | break; |
45 | 0 | case TPM_HT_PERSISTENT: |
46 | | // Get list of handles of persistent objects |
47 | 0 | out->moreData = NvCapGetPersistent((TPM_HANDLE) in->property, |
48 | 0 | in->propertyCount, |
49 | 0 | &out->capabilityData.data.handles); |
50 | 0 | break; |
51 | 0 | case TPM_HT_NV_INDEX: |
52 | | // Get list of defined NV index |
53 | 0 | out->moreData = NvCapGetIndex((TPM_HANDLE) in->property, |
54 | 0 | in->propertyCount, |
55 | 0 | &out->capabilityData.data.handles); |
56 | 0 | break; |
57 | 0 | case TPM_HT_LOADED_SESSION: |
58 | | // Get list of handles of loaded sessions |
59 | 0 | out->moreData = SessionCapGetLoaded((TPM_HANDLE) in->property, |
60 | 0 | in->propertyCount, |
61 | 0 | &out->capabilityData.data.handles); |
62 | 0 | break; |
63 | 0 | case TPM_HT_ACTIVE_SESSION: |
64 | | // Get list of handles of |
65 | 0 | out->moreData = SessionCapGetSaved((TPM_HANDLE) in->property, |
66 | 0 | in->propertyCount, |
67 | 0 | &out->capabilityData.data.handles); |
68 | 0 | break; |
69 | 0 | case TPM_HT_PCR: |
70 | | // Get list of handles of PCR |
71 | 0 | out->moreData = PCRCapGetHandles((TPM_HANDLE) in->property, |
72 | 0 | in->propertyCount, |
73 | 0 | &out->capabilityData.data.handles); |
74 | 0 | break; |
75 | 0 | case TPM_HT_PERMANENT: |
76 | | // Get list of permanent handles |
77 | 0 | out->moreData = PermanentCapGetHandles( |
78 | 0 | (TPM_HANDLE) in->property, |
79 | 0 | in->propertyCount, |
80 | 0 | &out->capabilityData.data.handles); |
81 | 0 | break; |
82 | 0 | default: |
83 | | // Unsupported input handle type |
84 | 0 | return TPM_RC_HANDLE + RC_GetCapability_property; |
85 | 0 | break; |
86 | 0 | } |
87 | 0 | break; |
88 | 0 | case TPM_CAP_COMMANDS: |
89 | 0 | out->moreData = CommandCapGetCCList((TPM_CC) in->property, |
90 | 0 | in->propertyCount, |
91 | 0 | &out->capabilityData.data.command); |
92 | 0 | break; |
93 | 0 | case TPM_CAP_PP_COMMANDS: |
94 | 0 | out->moreData = PhysicalPresenceCapGetCCList((TPM_CC) in->property, |
95 | 0 | in->propertyCount, &out->capabilityData.data.ppCommands); |
96 | 0 | break; |
97 | 0 | case TPM_CAP_AUDIT_COMMANDS: |
98 | 0 | out->moreData = CommandAuditCapGetCCList((TPM_CC) in->property, |
99 | 0 | in->propertyCount, |
100 | 0 | &out->capabilityData.data.auditCommands); |
101 | 0 | break; |
102 | 0 | case TPM_CAP_PCRS: |
103 | | // Input property must be 0 |
104 | 0 | if(in->property != 0) |
105 | 0 | return TPM_RC_VALUE + RC_GetCapability_property; |
106 | 0 | out->moreData = PCRCapGetAllocation(in->propertyCount, |
107 | 0 | &out->capabilityData.data.assignedPCR); |
108 | 0 | break; |
109 | 0 | case TPM_CAP_PCR_PROPERTIES: |
110 | 0 | out->moreData = PCRCapGetProperties((TPM_PT_PCR) in->property, |
111 | 0 | in->propertyCount, |
112 | 0 | &out->capabilityData.data.pcrProperties); |
113 | 0 | break; |
114 | 0 | case TPM_CAP_TPM_PROPERTIES: |
115 | 0 | out->moreData = TPMCapGetProperties((TPM_PT) in->property, |
116 | 0 | in->propertyCount, |
117 | 0 | &out->capabilityData.data.tpmProperties); |
118 | 0 | break; |
119 | 0 | #ifdef TPM_ALG_ECC |
120 | 0 | case TPM_CAP_ECC_CURVES: |
121 | 0 | out->moreData = CryptCapGetECCCurve((TPM_ECC_CURVE ) in->property, |
122 | 0 | in->propertyCount, |
123 | 0 | &out->capabilityData.data.eccCurves); |
124 | 0 | break; |
125 | 0 | #endif // TPM_ALG_ECC |
126 | 0 | case TPM_CAP_VENDOR_PROPERTY: |
127 | | // vendor property is not implemented |
128 | 0 | default: |
129 | | // Unexpected TPM_CAP value |
130 | 0 | return TPM_RC_VALUE; |
131 | 0 | break; |
132 | 0 | } |
133 | | |
134 | 0 | return TPM_RC_SUCCESS; |
135 | 0 | } |