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