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