]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Include/Library/Tpm2CommandLib.h
Add TPM2 commands which might be used in provision.
[mirror_edk2.git] / SecurityPkg / Include / Library / Tpm2CommandLib.h
CommitLineData
c1d93242
JY
1/** @file\r
2 This library is used by other modules to send TPM2 command.\r
3\r
967eacca 4Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved. <BR>\r
c1d93242
JY
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _TPM2_COMMAND_LIB_H_\r
16#define _TPM2_COMMAND_LIB_H_\r
17\r
18#include <IndustryStandard/Tpm20.h>\r
19\r
20/**\r
21 This command starts a hash or an Event sequence.\r
22 If hashAlg is an implemented hash, then a hash sequence is started.\r
23 If hashAlg is TPM_ALG_NULL, then an Event sequence is started.\r
24\r
25 @param[in] HashAlg The hash algorithm to use for the hash sequence\r
26 An Event sequence starts if this is TPM_ALG_NULL.\r
27 @param[out] SequenceHandle A handle to reference the sequence\r
28 \r
29 @retval EFI_SUCCESS Operation completed successfully.\r
30 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
31**/\r
32EFI_STATUS\r
33EFIAPI\r
34Tpm2HashSequenceStart (\r
35 IN TPMI_ALG_HASH HashAlg,\r
36 OUT TPMI_DH_OBJECT *SequenceHandle\r
37 );\r
38\r
39/**\r
40 This command is used to add data to a hash or HMAC sequence.\r
41 The amount of data in buffer may be any size up to the limits of the TPM.\r
42 NOTE: In all TPM, a buffer size of 1,024 octets is allowed.\r
43\r
44 @param[in] SequenceHandle Handle for the sequence object\r
45 @param[in] Buffer Data to be added to hash\r
46 \r
47 @retval EFI_SUCCESS Operation completed successfully.\r
48 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
49**/\r
50EFI_STATUS\r
51EFIAPI\r
52Tpm2SequenceUpdate (\r
53 IN TPMI_DH_OBJECT SequenceHandle,\r
54 IN TPM2B_MAX_BUFFER *Buffer\r
55 );\r
56\r
57/**\r
58 This command adds the last part of data, if any, to an Event sequence and returns the result in a digest list.\r
59 If pcrHandle references a PCR and not TPM_RH_NULL, then the returned digest list is processed in\r
60 the same manner as the digest list input parameter to TPM2_PCR_Extend() with the pcrHandle in each\r
61 bank extended with the associated digest value.\r
62\r
63 @param[in] PcrHandle PCR to be extended with the Event data\r
64 @param[in] SequenceHandle Authorization for the sequence\r
65 @param[in] Buffer Data to be added to the Event\r
66 @param[out] Results List of digests computed for the PCR\r
67 \r
68 @retval EFI_SUCCESS Operation completed successfully.\r
69 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
70**/\r
71EFI_STATUS\r
72EFIAPI\r
73Tpm2EventSequenceComplete (\r
74 IN TPMI_DH_PCR PcrHandle,\r
75 IN TPMI_DH_OBJECT SequenceHandle,\r
76 IN TPM2B_MAX_BUFFER *Buffer,\r
77 OUT TPML_DIGEST_VALUES *Results\r
78 );\r
79\r
80/**\r
81 This command adds the last part of data, if any, to a hash/HMAC sequence and returns the result.\r
82\r
83 @param[in] SequenceHandle Authorization for the sequence\r
84 @param[in] Buffer Data to be added to the hash/HMAC\r
85 @param[out] Result The returned HMAC or digest in a sized buffer\r
86 \r
87 @retval EFI_SUCCESS Operation completed successfully.\r
88 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
89**/\r
90EFI_STATUS\r
91EFIAPI\r
92Tpm2SequenceComplete (\r
93 IN TPMI_DH_OBJECT SequenceHandle,\r
94 IN TPM2B_MAX_BUFFER *Buffer,\r
95 OUT TPM2B_DIGEST *Result\r
96 );\r
97\r
98/**\r
99 Send Startup command to TPM2.\r
100\r
101 @param[in] StartupType TPM_SU_CLEAR or TPM_SU_STATE\r
102\r
103 @retval EFI_SUCCESS Operation completed successfully.\r
104 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108Tpm2Startup (\r
109 IN TPM_SU StartupType\r
110 );\r
111\r
112/**\r
113 Send Shutdown command to TPM2.\r
114\r
115 @param[in] ShutdownType TPM_SU_CLEAR or TPM_SU_STATE.\r
116\r
117 @retval EFI_SUCCESS Operation completed successfully.\r
118 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122Tpm2Shutdown (\r
123 IN TPM_SU ShutdownType\r
124 );\r
125\r
126/**\r
127 This command causes the TPM to perform a test of its capabilities.\r
128 If the fullTest is YES, the TPM will test all functions.\r
129 If fullTest = NO, the TPM will only test those functions that have not previously been tested.\r
130\r
131 @param[in] FullTest YES if full test to be performed\r
132 NO if only test of untested functions required\r
133\r
134 @retval EFI_SUCCESS Operation completed successfully.\r
135 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
136**/\r
137EFI_STATUS\r
138EFIAPI\r
139Tpm2SelfTest (\r
140 IN TPMI_YES_NO FullTest\r
141 );\r
142\r
967eacca
JY
143/**\r
144 This command allows setting of the authorization policy for the platform hierarchy (platformPolicy), the\r
145 storage hierarchy (ownerPolicy), and and the endorsement hierarchy (endorsementPolicy).\r
146\r
147 @param[in] AuthHandle TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP} parameters to be validated\r
148 @param[in] AuthSession Auth Session context\r
149 @param[in] AuthPolicy An authorization policy hash\r
150 @param[in] HashAlg The hash algorithm to use for the policy\r
151\r
152 @retval EFI_SUCCESS Operation completed successfully.\r
153 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
154**/\r
155EFI_STATUS\r
156EFIAPI\r
157Tpm2SetPrimaryPolicy (\r
158 IN TPMI_RH_HIERARCHY_AUTH AuthHandle,\r
159 IN TPMS_AUTH_COMMAND *AuthSession,\r
160 IN TPM2B_DIGEST *AuthPolicy,\r
161 IN TPMI_ALG_HASH HashAlg\r
162 );\r
163\r
c1d93242
JY
164/**\r
165 This command removes all TPM context associated with a specific Owner.\r
166\r
167 @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}\r
168 @param[in] AuthSession Auth Session context\r
169 \r
170 @retval EFI_SUCCESS Operation completed successfully.\r
171 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
172**/\r
173EFI_STATUS\r
174EFIAPI\r
175Tpm2Clear (\r
176 IN TPMI_RH_CLEAR AuthHandle,\r
177 IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL\r
178 );\r
179\r
180/**\r
181 Disables and enables the execution of TPM2_Clear().\r
182\r
183 @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}\r
184 @param[in] AuthSession Auth Session context\r
185 @param[in] Disable YES if the disableOwnerClear flag is to be SET,\r
186 NO if the flag is to be CLEAR.\r
187\r
188 @retval EFI_SUCCESS Operation completed successfully.\r
189 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
190**/\r
191EFI_STATUS\r
192EFIAPI\r
193Tpm2ClearControl (\r
194 IN TPMI_RH_CLEAR AuthHandle,\r
195 IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL\r
196 IN TPMI_YES_NO Disable\r
197 );\r
198\r
199/**\r
200 This command allows the authorization secret for a hierarchy or lockout to be changed using the current\r
201 authorization value as the command authorization.\r
202\r
203 @param[in] AuthHandle TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}\r
204 @param[in] AuthSession Auth Session context\r
205 @param[in] NewAuth New authorization secret\r
206\r
207 @retval EFI_SUCCESS Operation completed successfully.\r
208 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212Tpm2HierarchyChangeAuth (\r
213 IN TPMI_RH_HIERARCHY_AUTH AuthHandle,\r
214 IN TPMS_AUTH_COMMAND *AuthSession,\r
215 IN TPM2B_AUTH *NewAuth\r
216 );\r
217\r
218/**\r
219 This replaces the current EPS with a value from the RNG and sets the Endorsement hierarchy controls to\r
220 their default initialization values.\r
221\r
222 @param[in] AuthHandle TPM_RH_PLATFORM+{PP}\r
223 @param[in] AuthSession Auth Session context\r
224\r
225 @retval EFI_SUCCESS Operation completed successfully.\r
226 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230Tpm2ChangeEPS (\r
231 IN TPMI_RH_PLATFORM AuthHandle,\r
232 IN TPMS_AUTH_COMMAND *AuthSession\r
233 );\r
234\r
235/**\r
236 This replaces the current PPS with a value from the RNG and sets platformPolicy to the default\r
237 initialization value (the Empty Buffer).\r
238\r
239 @param[in] AuthHandle TPM_RH_PLATFORM+{PP}\r
240 @param[in] AuthSession Auth Session context\r
241\r
242 @retval EFI_SUCCESS Operation completed successfully.\r
243 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
244**/\r
245EFI_STATUS\r
246EFIAPI\r
247Tpm2ChangePPS (\r
248 IN TPMI_RH_PLATFORM AuthHandle,\r
249 IN TPMS_AUTH_COMMAND *AuthSession\r
250 );\r
251\r
252/**\r
253 This command enables and disables use of a hierarchy.\r
254\r
255 @param[in] AuthHandle TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}\r
256 @param[in] AuthSession Auth Session context\r
257 @param[in] Hierarchy Hierarchy of the enable being modified\r
258 @param[in] State YES if the enable should be SET,\r
259 NO if the enable should be CLEAR\r
260\r
261 @retval EFI_SUCCESS Operation completed successfully.\r
262 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
263**/\r
264EFI_STATUS\r
265EFIAPI\r
266Tpm2HierarchyControl (\r
267 IN TPMI_RH_HIERARCHY AuthHandle,\r
268 IN TPMS_AUTH_COMMAND *AuthSession,\r
269 IN TPMI_RH_HIERARCHY Hierarchy,\r
270 IN TPMI_YES_NO State\r
271 );\r
272\r
273/**\r
274 This command cancels the effect of a TPM lockout due to a number of successive authorization failures.\r
275 If this command is properly authorized, the lockout counter is set to zero.\r
276\r
277 @param[in] LockHandle LockHandle\r
278 @param[in] AuthSession Auth Session context\r
279\r
280 @retval EFI_SUCCESS Operation completed successfully.\r
281 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
282**/\r
283EFI_STATUS\r
284EFIAPI\r
285Tpm2DictionaryAttackLockReset (\r
286 IN TPMI_RH_LOCKOUT LockHandle,\r
287 IN TPMS_AUTH_COMMAND *AuthSession\r
288 );\r
289\r
290/**\r
291 This command cancels the effect of a TPM lockout due to a number of successive authorization failures.\r
292 If this command is properly authorized, the lockout counter is set to zero.\r
293\r
294 @param[in] LockHandle LockHandle\r
295 @param[in] AuthSession Auth Session context\r
296 @param[in] NewMaxTries Count of authorization failures before the lockout is imposed\r
297 @param[in] NewRecoveryTime Time in seconds before the authorization failure count is automatically decremented\r
298 @param[in] LockoutRecovery Time in seconds after a lockoutAuth failure before use of lockoutAuth is allowed\r
299\r
300 @retval EFI_SUCCESS Operation completed successfully.\r
301 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
302**/\r
303EFI_STATUS\r
304EFIAPI\r
305Tpm2DictionaryAttackParameters (\r
306 IN TPMI_RH_LOCKOUT LockHandle,\r
307 IN TPMS_AUTH_COMMAND *AuthSession,\r
308 IN UINT32 NewMaxTries,\r
309 IN UINT32 NewRecoveryTime,\r
310 IN UINT32 LockoutRecovery\r
311 );\r
312\r
313/**\r
314 This command is used to read the public area and Name of an NV Index.\r
315\r
316 @param[in] NvIndex The NV Index.\r
317 @param[out] NvPublic The public area of the index.\r
318 @param[out] NvName The Name of the nvIndex.\r
319 \r
320 @retval EFI_SUCCESS Operation completed successfully.\r
321 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
322**/\r
323EFI_STATUS\r
324EFIAPI\r
325Tpm2NvReadPublic (\r
326 IN TPMI_RH_NV_INDEX NvIndex,\r
327 OUT TPM2B_NV_PUBLIC *NvPublic,\r
328 OUT TPM2B_NAME *NvName\r
329 );\r
330\r
331/**\r
332 This command defines the attributes of an NV Index and causes the TPM to\r
333 reserve space to hold the data associated with the index.\r
334 If a definition already exists at the index, the TPM will return TPM_RC_NV_DEFINED.\r
335\r
336 @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.\r
337 @param[in] AuthSession Auth Session context\r
338 @param[in] Auth The authorization data.\r
339 @param[in] NvPublic The public area of the index.\r
340 \r
341 @retval EFI_SUCCESS Operation completed successfully.\r
342 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
343 @retval EFI_ALREADY_STARTED The command was returned successfully, but NvIndex is already defined.\r
344**/\r
345EFI_STATUS\r
346EFIAPI\r
347Tpm2NvDefineSpace (\r
348 IN TPMI_RH_PROVISION AuthHandle,\r
349 IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL\r
350 IN TPM2B_AUTH *Auth,\r
351 IN TPM2B_NV_PUBLIC *NvPublic\r
352 );\r
353\r
354/**\r
355 This command removes an index from the TPM.\r
356\r
357 @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.\r
358 @param[in] NvIndex The NV Index.\r
359 @param[in] AuthSession Auth Session context\r
360 \r
361 @retval EFI_SUCCESS Operation completed successfully.\r
362 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
363 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
364**/\r
365EFI_STATUS\r
366EFIAPI\r
367Tpm2NvUndefineSpace (\r
368 IN TPMI_RH_PROVISION AuthHandle,\r
369 IN TPMI_RH_NV_INDEX NvIndex,\r
370 IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL\r
371 );\r
372\r
373/**\r
374 This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().\r
375\r
376 @param[in] AuthHandle the handle indicating the source of the authorization value.\r
377 @param[in] NvIndex The index to be read.\r
378 @param[in] AuthSession Auth Session context\r
379 @param[in] Size Number of bytes to read.\r
380 @param[in] Offset Byte offset into the area.\r
381 @param[in,out] OutData The data read.\r
382 \r
383 @retval EFI_SUCCESS Operation completed successfully.\r
384 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
385 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
386**/\r
387EFI_STATUS\r
388EFIAPI\r
389Tpm2NvRead (\r
390 IN TPMI_RH_NV_AUTH AuthHandle,\r
391 IN TPMI_RH_NV_INDEX NvIndex,\r
392 IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL\r
393 IN UINT16 Size,\r
394 IN UINT16 Offset,\r
395 IN OUT TPM2B_MAX_BUFFER *OutData\r
396 );\r
397\r
398/**\r
399 This command writes a value to an area in NV memory that was previously defined by TPM2_NV_DefineSpace().\r
400\r
401 @param[in] AuthHandle the handle indicating the source of the authorization value.\r
402 @param[in] NvIndex The NV Index of the area to write.\r
403 @param[in] AuthSession Auth Session context\r
404 @param[in] InData The data to write.\r
405 @param[in] Offset The offset into the NV Area.\r
406 \r
407 @retval EFI_SUCCESS Operation completed successfully.\r
408 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
409 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
410**/\r
411EFI_STATUS\r
412EFIAPI\r
413Tpm2NvWrite (\r
414 IN TPMI_RH_NV_AUTH AuthHandle,\r
415 IN TPMI_RH_NV_INDEX NvIndex,\r
416 IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL\r
417 IN TPM2B_MAX_BUFFER *InData,\r
418 IN UINT16 Offset\r
419 );\r
420\r
421/**\r
422 This command may be used to prevent further reads of the Index until the next TPM2_Startup (TPM_SU_CLEAR).\r
423\r
424 @param[in] AuthHandle the handle indicating the source of the authorization value.\r
425 @param[in] NvIndex The NV Index of the area to lock.\r
426 @param[in] AuthSession Auth Session context\r
427\r
428 @retval EFI_SUCCESS Operation completed successfully.\r
429 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
430 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
431**/\r
432EFI_STATUS\r
433EFIAPI\r
434Tpm2NvReadLock (\r
435 IN TPMI_RH_NV_AUTH AuthHandle,\r
436 IN TPMI_RH_NV_INDEX NvIndex,\r
437 IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL\r
438 );\r
439\r
440/**\r
441 This command may be used to inhibit further writes of the Index.\r
442\r
443 @param[in] AuthHandle the handle indicating the source of the authorization value.\r
444 @param[in] NvIndex The NV Index of the area to lock.\r
445 @param[in] AuthSession Auth Session context\r
446\r
447 @retval EFI_SUCCESS Operation completed successfully.\r
448 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
449 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
450**/\r
451EFI_STATUS\r
452EFIAPI\r
453Tpm2NvWriteLock (\r
454 IN TPMI_RH_NV_AUTH AuthHandle,\r
455 IN TPMI_RH_NV_INDEX NvIndex,\r
456 IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL\r
457 );\r
458\r
459/**\r
460 The command will SET TPMA_NV_WRITELOCKED for all indexes that have their TPMA_NV_GLOBALLOCK attribute SET.\r
461\r
462 @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.\r
463 @param[in] AuthSession Auth Session context\r
464\r
465 @retval EFI_SUCCESS Operation completed successfully.\r
466 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
467 @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.\r
468**/\r
469EFI_STATUS\r
470EFIAPI\r
471Tpm2NvGlobalWriteLock (\r
472 IN TPMI_RH_PROVISION AuthHandle,\r
473 IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL\r
474 );\r
475\r
476/**\r
477 This command is used to cause an update to the indicated PCR.\r
478 The digests parameter contains one or more tagged digest value identified by an algorithm ID.\r
479 For each digest, the PCR associated with pcrHandle is Extended into the bank identified by the tag (hashAlg).\r
480\r
481 @param[in] PcrHandle Handle of the PCR\r
482 @param[in] Digests List of tagged digest values to be extended\r
483\r
484 @retval EFI_SUCCESS Operation completed successfully.\r
485 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
486**/\r
487EFI_STATUS\r
488EFIAPI\r
489Tpm2PcrExtend (\r
490 IN TPMI_DH_PCR PcrHandle,\r
491 IN TPML_DIGEST_VALUES *Digests\r
492 );\r
493\r
494/**\r
495 This command is used to cause an update to the indicated PCR.\r
496 The data in eventData is hashed using the hash algorithm associated with each bank in which the\r
497 indicated PCR has been allocated. After the data is hashed, the digests list is returned. If the pcrHandle\r
498 references an implemented PCR and not TPM_ALG_NULL, digests list is processed as in\r
499 TPM2_PCR_Extend().\r
500 A TPM shall support an Event.size of zero through 1,024 inclusive.\r
501\r
502 @param[in] PcrHandle Handle of the PCR\r
503 @param[in] EventData Event data in sized buffer\r
504 @param[out] Digests List of digest\r
505\r
506 @retval EFI_SUCCESS Operation completed successfully.\r
507 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
508**/\r
509EFI_STATUS\r
510EFIAPI\r
511Tpm2PcrEvent (\r
512 IN TPMI_DH_PCR PcrHandle,\r
513 IN TPM2B_EVENT *EventData,\r
514 OUT TPML_DIGEST_VALUES *Digests\r
515 );\r
516\r
517/**\r
518 This command returns the values of all PCR specified in pcrSelect.\r
519\r
520 @param[in] PcrSelectionIn The selection of PCR to read.\r
521 @param[out] PcrUpdateCounter The current value of the PCR update counter.\r
522 @param[out] PcrSelectionOut The PCR in the returned list.\r
523 @param[out] PcrValues The contents of the PCR indicated in pcrSelect.\r
524 \r
525 @retval EFI_SUCCESS Operation completed successfully.\r
526 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
527**/\r
528EFI_STATUS\r
529EFIAPI\r
530Tpm2PcrRead (\r
531 IN TPML_PCR_SELECTION *PcrSelectionIn,\r
532 OUT UINT32 *PcrUpdateCounter,\r
533 OUT TPML_PCR_SELECTION *PcrSelectionOut,\r
534 OUT TPML_DIGEST *PcrValues\r
535 );\r
536\r
537/**\r
538 This command is used to set the desired PCR allocation of PCR and algorithms.\r
539\r
540 @param[in] AuthHandle TPM_RH_PLATFORM+{PP}\r
541 @param[in] AuthSession Auth Session context\r
542 @param[in] PcrAllocation The requested allocation\r
543 @param[out] AllocationSuccess YES if the allocation succeeded\r
544 @param[out] MaxPCR maximum number of PCR that may be in a bank\r
545 @param[out] SizeNeeded number of octets required to satisfy the request\r
546 @param[out] SizeAvailable Number of octets available. Computed before the allocation\r
547 \r
548 @retval EFI_SUCCESS Operation completed successfully.\r
549 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
550**/\r
551EFI_STATUS\r
552EFIAPI\r
553Tpm2PcrAllocate (\r
554 IN TPMI_RH_PLATFORM AuthHandle,\r
555 IN TPMS_AUTH_COMMAND *AuthSession,\r
556 IN TPML_PCR_SELECTION *PcrAllocation,\r
557 OUT TPMI_YES_NO *AllocationSuccess,\r
558 OUT UINT32 *MaxPCR,\r
559 OUT UINT32 *SizeNeeded,\r
560 OUT UINT32 *SizeAvailable\r
561 );\r
562\r
563/**\r
564 This command returns various information regarding the TPM and its current state.\r
565\r
566 The capability parameter determines the category of data returned. The property parameter \r
567 selects the first value of the selected category to be returned. If there is no property \r
568 that corresponds to the value of property, the next higher value is returned, if it exists.\r
569 The moreData parameter will have a value of YES if there are more values of the requested \r
570 type that were not returned.\r
571 If no next capability exists, the TPM will return a zero-length list and moreData will have \r
572 a value of NO.\r
573\r
574 NOTE: \r
575 To simplify this function, leave returned CapabilityData for caller to unpack since there are \r
576 many capability categories and only few categories will be used in firmware. It means the caller\r
577 need swap the byte order for the feilds in CapabilityData.\r
578\r
579 @param[in] Capability Group selection; determines the format of the response.\r
580 @param[in] Property Further definition of information. \r
581 @param[in] PropertyCount Number of properties of the indicated type to return.\r
582 @param[out] MoreData Flag to indicate if there are more values of this type.\r
583 @param[out] CapabilityData The capability data.\r
584 \r
585 @retval EFI_SUCCESS Operation completed successfully.\r
586 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
587**/\r
588EFI_STATUS\r
589EFIAPI\r
590Tpm2GetCapability (\r
591 IN TPM_CAP Capability,\r
592 IN UINT32 Property,\r
593 IN UINT32 PropertyCount,\r
594 OUT TPMI_YES_NO *MoreData,\r
595 OUT TPMS_CAPABILITY_DATA *CapabilityData\r
596 );\r
597\r
598/**\r
599 This command returns the information of TPM Family.\r
600\r
601 This function parse the value got from TPM2_GetCapability and return the Family.\r
602\r
603 @param[out] Family The Family of TPM. (a 4-octet character string)\r
604 \r
605 @retval EFI_SUCCESS Operation completed successfully.\r
606 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
607**/\r
608EFI_STATUS\r
609EFIAPI\r
610Tpm2GetCapabilityFamily (\r
611 OUT CHAR8 *Family\r
612 );\r
613\r
614/**\r
615 This command returns the information of TPM manufacture ID.\r
616\r
617 This function parse the value got from TPM2_GetCapability and return the TPM manufacture ID.\r
618\r
619 @param[out] ManufactureId The manufacture ID of TPM.\r
620 \r
621 @retval EFI_SUCCESS Operation completed successfully.\r
622 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
623**/\r
624EFI_STATUS\r
625EFIAPI\r
626Tpm2GetCapabilityManufactureID (\r
627 OUT UINT32 *ManufactureId\r
628 );\r
629\r
630/**\r
631 This command returns the information of TPM FirmwareVersion.\r
632\r
633 This function parse the value got from TPM2_GetCapability and return the TPM FirmwareVersion.\r
634\r
635 @param[out] FirmwareVersion1 The FirmwareVersion1.\r
636 @param[out] FirmwareVersion2 The FirmwareVersion2.\r
637 \r
638 @retval EFI_SUCCESS Operation completed successfully.\r
639 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
640**/\r
641EFI_STATUS\r
642EFIAPI\r
643Tpm2GetCapabilityFirmwareVersion (\r
644 OUT UINT32 *FirmwareVersion1,\r
645 OUT UINT32 *FirmwareVersion2\r
646 );\r
647\r
648/**\r
649 This command returns the information of the maximum value for commandSize and responseSize in a command.\r
650\r
651 This function parse the value got from TPM2_GetCapability and return the max command size and response size\r
652\r
653 @param[out] MaxCommandSize The maximum value for commandSize in a command.\r
654 @param[out] MaxResponseSize The maximum value for responseSize in a command.\r
655 \r
656 @retval EFI_SUCCESS Operation completed successfully.\r
657 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
658**/\r
659EFI_STATUS\r
660EFIAPI\r
661Tpm2GetCapabilityMaxCommandResponseSize (\r
662 OUT UINT32 *MaxCommandSize,\r
663 OUT UINT32 *MaxResponseSize\r
664 );\r
665\r
666/**\r
667 This command returns Returns a list of TPMS_ALG_PROPERTIES. Each entry is an\r
668 algorithm ID and a set of properties of the algorithm. \r
669\r
670 This function parse the value got from TPM2_GetCapability and return the list.\r
671\r
672 @param[out] AlgList List of algorithm.\r
673 \r
674 @retval EFI_SUCCESS Operation completed successfully.\r
675 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
676**/\r
677EFI_STATUS\r
678EFIAPI\r
679Tpm2GetCapabilitySupportedAlg (\r
680 OUT TPML_ALG_PROPERTY *AlgList\r
681 );\r
682\r
683/**\r
684 This command returns the information of TPM LockoutCounter.\r
685\r
686 This function parse the value got from TPM2_GetCapability and return the LockoutCounter.\r
687\r
688 @param[out] LockoutCounter The LockoutCounter of TPM.\r
689 \r
690 @retval EFI_SUCCESS Operation completed successfully.\r
691 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
692**/\r
693EFI_STATUS\r
694EFIAPI\r
695Tpm2GetCapabilityLockoutCounter (\r
696 OUT UINT32 *LockoutCounter\r
697 );\r
698\r
699/**\r
700 This command returns the information of TPM LockoutInterval.\r
701\r
702 This function parse the value got from TPM2_GetCapability and return the LockoutInterval.\r
703\r
704 @param[out] LockoutInterval The LockoutInterval of TPM.\r
705 \r
706 @retval EFI_SUCCESS Operation completed successfully.\r
707 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
708**/\r
709EFI_STATUS\r
710EFIAPI\r
711Tpm2GetCapabilityLockoutInterval (\r
712 OUT UINT32 *LockoutInterval\r
713 );\r
714\r
715/**\r
716 This command returns the information of TPM InputBufferSize.\r
717\r
718 This function parse the value got from TPM2_GetCapability and return the InputBufferSize.\r
719\r
720 @param[out] InputBufferSize The InputBufferSize of TPM.\r
721 the maximum size of a parameter (typically, a TPM2B_MAX_BUFFER)\r
722 \r
723 @retval EFI_SUCCESS Operation completed successfully.\r
724 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
725**/\r
726EFI_STATUS\r
727EFIAPI\r
728Tpm2GetCapabilityInputBufferSize (\r
729 OUT UINT32 *InputBufferSize\r
730 );\r
731\r
732/**\r
733 This command returns the information of TPM PCRs.\r
734\r
735 This function parse the value got from TPM2_GetCapability and return the PcrSelection.\r
736\r
737 @param[out] Pcrs The Pcr Selection\r
738 \r
739 @retval EFI_SUCCESS Operation completed successfully.\r
740 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
741**/\r
742EFI_STATUS\r
743EFIAPI\r
744Tpm2GetCapabilityPcrs (\r
745 OUT TPML_PCR_SELECTION *Pcrs\r
746 );\r
747\r
748/**\r
749 This command returns the information of TPM AlgorithmSet.\r
750\r
751 This function parse the value got from TPM2_GetCapability and return the AlgorithmSet.\r
752\r
753 @param[out] AlgorithmSet The AlgorithmSet of TPM.\r
754 \r
755 @retval EFI_SUCCESS Operation completed successfully.\r
756 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
757**/\r
758EFI_STATUS\r
759EFIAPI\r
760Tpm2GetCapabilityAlgorithmSet (\r
761 OUT UINT32 *AlgorithmSet\r
762 );\r
763\r
764/**\r
765 This command is used to check to see if specific combinations of algorithm parameters are supported.\r
766\r
767 @param[in] Parameters Algorithm parameters to be validated\r
768\r
769 @retval EFI_SUCCESS Operation completed successfully.\r
770 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
771**/\r
772EFI_STATUS\r
773EFIAPI\r
774Tpm2TestParms (\r
775 IN TPMT_PUBLIC_PARMS *Parameters\r
776 );\r
777\r
778/**\r
779 This command allows the platform to change the set of algorithms that are used by the TPM.\r
780 The algorithmSet setting is a vendor-dependent value.\r
781\r
782 @param[in] AuthHandle TPM_RH_PLATFORM\r
783 @param[in] AuthSession Auth Session context\r
784 @param[in] AlgorithmSet A TPM vendor-dependent value indicating the\r
785 algorithm set selection\r
786\r
787 @retval EFI_SUCCESS Operation completed successfully.\r
788 @retval EFI_DEVICE_ERROR Unexpected device behavior.\r
789**/\r
790EFI_STATUS\r
791EFIAPI\r
792Tpm2SetAlgorithmSet (\r
793 IN TPMI_RH_PLATFORM AuthHandle,\r
794 IN TPMS_AUTH_COMMAND *AuthSession,\r
795 IN UINT32 AlgorithmSet\r
796 );\r
797\r
967eacca
JY
798/**\r
799 This command is used to start an authorization session using alternative methods of\r
800 establishing the session key (sessionKey) that is used for authorization and encrypting value.\r
801\r
802 @param[in] TpmKey Handle of a loaded decrypt key used to encrypt salt.\r
803 @param[in] Bind Entity providing the authValue.\r
804 @param[in] NonceCaller Initial nonceCaller, sets nonce size for the session.\r
805 @param[in] Salt Value encrypted according to the type of tpmKey.\r
806 @param[in] SessionType Indicates the type of the session.\r
807 @param[in] Symmetric The algorithm and key size for parameter encryption.\r
808 @param[in] AuthHash Hash algorithm to use for the session.\r
809 @param[out] SessionHandle Handle for the newly created session.\r
810 @param[out] NonceTPM The initial nonce from the TPM, used in the computation of the sessionKey.\r
811 \r
812 @retval EFI_SUCCESS Operation completed successfully.\r
813 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
814**/\r
815EFI_STATUS\r
816EFIAPI\r
817Tpm2StartAuthSession (\r
818 IN TPMI_DH_OBJECT TpmKey,\r
819 IN TPMI_DH_ENTITY Bind,\r
820 IN TPM2B_NONCE *NonceCaller,\r
821 IN TPM2B_ENCRYPTED_SECRET *Salt,\r
822 IN TPM_SE SessionType,\r
823 IN TPMT_SYM_DEF *Symmetric,\r
824 IN TPMI_ALG_HASH AuthHash,\r
825 OUT TPMI_SH_AUTH_SESSION *SessionHandle,\r
826 OUT TPM2B_NONCE *NonceTPM\r
827 );\r
828\r
829/**\r
830 This command causes all context associated with a loaded object or session to be removed from TPM memory.\r
831\r
832 @param[in] FlushHandle The handle of the item to flush.\r
833 \r
834 @retval EFI_SUCCESS Operation completed successfully.\r
835 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
836**/\r
837EFI_STATUS\r
838EFIAPI\r
839Tpm2FlushContext (\r
840 IN TPMI_DH_CONTEXT FlushHandle\r
841 );\r
842\r
843/**\r
844 This command includes a secret-based authorization to a policy.\r
845 The caller proves knowledge of the secret value using an authorization\r
846 session using the authValue associated with authHandle.\r
847 \r
848 @param[in] AuthHandle Handle for an entity providing the authorization\r
849 @param[in] PolicySession Handle for the policy session being extended.\r
850 @param[in] AuthSession Auth Session context\r
851 @param[in] NonceTPM The policy nonce for the session.\r
852 @param[in] CpHashA Digest of the command parameters to which this authorization is limited.\r
853 @param[in] PolicyRef A reference to a policy relating to the authorization.\r
854 @param[in] Expiration Time when authorization will expire, measured in seconds from the time that nonceTPM was generated.\r
855 @param[out] Timeout Time value used to indicate to the TPM when the ticket expires.\r
856 @param[out] PolicyTicket A ticket that includes a value indicating when the authorization expires.\r
857 \r
858 @retval EFI_SUCCESS Operation completed successfully.\r
859 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
860**/\r
861EFI_STATUS\r
862EFIAPI\r
863Tpm2PolicySecret (\r
864 IN TPMI_DH_ENTITY AuthHandle,\r
865 IN TPMI_SH_POLICY PolicySession,\r
866 IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL\r
867 IN TPM2B_NONCE *NonceTPM,\r
868 IN TPM2B_DIGEST *CpHashA,\r
869 IN TPM2B_NONCE *PolicyRef,\r
870 IN INT32 Expiration,\r
871 OUT TPM2B_TIMEOUT *Timeout,\r
872 OUT TPMT_TK_AUTH *PolicyTicket\r
873 );\r
874\r
a50e58f4
JY
875/**\r
876 This command allows options in authorizations without requiring that the TPM evaluate all of the options.\r
877 If a policy may be satisfied by different sets of conditions, the TPM need only evaluate one set that\r
878 satisfies the policy. This command will indicate that one of the required sets of conditions has been\r
879 satisfied.\r
880\r
881 @param[in] PolicySession Handle for the policy session being extended.\r
882 @param[in] HashList the list of hashes to check for a match.\r
883 \r
884 @retval EFI_SUCCESS Operation completed successfully.\r
885 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
886**/\r
887EFI_STATUS\r
888EFIAPI\r
889Tpm2PolicyOR (\r
890 IN TPMI_SH_POLICY PolicySession,\r
891 IN TPML_DIGEST *HashList\r
892 );\r
893\r
967eacca
JY
894/**\r
895 This command indicates that the authorization will be limited to a specific command code.\r
896\r
897 @param[in] PolicySession Handle for the policy session being extended.\r
898 @param[in] Code The allowed commandCode.\r
899 \r
900 @retval EFI_SUCCESS Operation completed successfully.\r
901 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
902**/\r
903EFI_STATUS\r
904EFIAPI\r
905Tpm2PolicyCommandCode (\r
906 IN TPMI_SH_POLICY PolicySession,\r
907 IN TPM_CC Code\r
908 );\r
909\r
910/**\r
911 This command returns the current policyDigest of the session. This command allows the TPM\r
912 to be used to perform the actions required to precompute the authPolicy for an object.\r
913\r
914 @param[in] PolicySession Handle for the policy session.\r
915 @param[out] PolicyHash the current value of the policyHash of policySession.\r
916 \r
917 @retval EFI_SUCCESS Operation completed successfully.\r
918 @retval EFI_DEVICE_ERROR The command was unsuccessful.\r
919**/\r
920EFI_STATUS\r
921EFIAPI\r
922Tpm2PolicyGetDigest (\r
923 IN TPMI_SH_POLICY PolicySession,\r
924 OUT TPM2B_DIGEST *PolicyHash\r
925 );\r
926\r
c1d93242
JY
927//\r
928// Help function\r
929//\r
930\r
931/**\r
932 Copy AuthSessionIn to TPM2 command buffer.\r
933\r
934 @param [in] AuthSessionIn Input AuthSession data\r
935 @param [out] AuthSessionOut Output AuthSession data in TPM2 command buffer\r
936\r
937 @return AuthSession size\r
938**/\r
939UINT32\r
940EFIAPI\r
941CopyAuthSessionCommand (\r
942 IN TPMS_AUTH_COMMAND *AuthSessionIn, OPTIONAL\r
943 OUT UINT8 *AuthSessionOut\r
944 );\r
945\r
946/**\r
947 Copy AuthSessionIn from TPM2 response buffer.\r
948\r
949 @param [in] AuthSessionIn Input AuthSession data in TPM2 response buffer\r
950 @param [out] AuthSessionOut Output AuthSession data\r
951\r
952 @return AuthSession size\r
953**/\r
954UINT32\r
955EFIAPI\r
956CopyAuthSessionResponse (\r
957 IN UINT8 *AuthSessionIn,\r
958 OUT TPMS_AUTH_RESPONSE *AuthSessionOut OPTIONAL\r
959 );\r
960\r
961/**\r
962 Return size of digest.\r
963\r
964 @param[in] HashAlgo Hash algorithm\r
965\r
966 @return size of digest\r
967**/\r
968UINT16\r
969EFIAPI\r
970GetHashSizeFromAlgo (\r
971 IN TPMI_ALG_HASH HashAlgo\r
972 );\r
973\r
974#endif\r