2 Implement TPM2 Capability related command.
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
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.
15 #include <IndustryStandard/UefiTcgPlatform.h>
16 #include <Library/Tpm2CommandLib.h>
17 #include <Library/Tpm2DeviceLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/DebugLib.h>
25 TPM2_COMMAND_HEADER Header
;
29 } TPM2_GET_CAPABILITY_COMMAND
;
32 TPM2_RESPONSE_HEADER Header
;
34 TPMS_CAPABILITY_DATA CapabilityData
;
35 } TPM2_GET_CAPABILITY_RESPONSE
;
38 TPM2_COMMAND_HEADER Header
;
39 TPMT_PUBLIC_PARMS Parameters
;
40 } TPM2_TEST_PARMS_COMMAND
;
43 TPM2_RESPONSE_HEADER Header
;
44 } TPM2_TEST_PARMS_RESPONSE
;
49 This command returns various information regarding the TPM and its current state.
51 The capability parameter determines the category of data returned. The property parameter
52 selects the first value of the selected category to be returned. If there is no property
53 that corresponds to the value of property, the next higher value is returned, if it exists.
54 The moreData parameter will have a value of YES if there are more values of the requested
55 type that were not returned.
56 If no next capability exists, the TPM will return a zero-length list and moreData will have
60 To simplify this function, leave returned CapabilityData for caller to unpack since there are
61 many capability categories and only few categories will be used in firmware. It means the caller
62 need swap the byte order for the feilds in CapabilityData.
64 @param[in] Capability Group selection; determines the format of the response.
65 @param[in] Property Further definition of information.
66 @param[in] PropertyCount Number of properties of the indicated type to return.
67 @param[out] MoreData Flag to indicate if there are more values of this type.
68 @param[out] CapabilityData The capability data.
70 @retval EFI_SUCCESS Operation completed successfully.
71 @retval EFI_DEVICE_ERROR The command was unsuccessful.
76 IN TPM_CAP Capability
,
78 IN UINT32 PropertyCount
,
79 OUT TPMI_YES_NO
*MoreData
,
80 OUT TPMS_CAPABILITY_DATA
*CapabilityData
84 TPM2_GET_CAPABILITY_COMMAND SendBuffer
;
85 TPM2_GET_CAPABILITY_RESPONSE RecvBuffer
;
86 UINT32 SendBufferSize
;
87 UINT32 RecvBufferSize
;
92 SendBuffer
.Header
.tag
= SwapBytes16(TPM_ST_NO_SESSIONS
);
93 SendBuffer
.Header
.commandCode
= SwapBytes32(TPM_CC_GetCapability
);
95 SendBuffer
.Capability
= SwapBytes32 (Capability
);
96 SendBuffer
.Property
= SwapBytes32 (Property
);
97 SendBuffer
.PropertyCount
= SwapBytes32 (PropertyCount
);
99 SendBufferSize
= (UINT32
) sizeof (SendBuffer
);
100 SendBuffer
.Header
.paramSize
= SwapBytes32 (SendBufferSize
);
105 RecvBufferSize
= sizeof (RecvBuffer
);
106 Status
= Tpm2SubmitCommand (SendBufferSize
, (UINT8
*)&SendBuffer
, &RecvBufferSize
, (UINT8
*)&RecvBuffer
);
107 if (EFI_ERROR (Status
)) {
111 if (RecvBufferSize
<= sizeof (TPM2_RESPONSE_HEADER
) + sizeof (UINT8
)) {
112 return EFI_DEVICE_ERROR
;
116 // Return the response
118 *MoreData
= RecvBuffer
.MoreData
;
120 // Does not unpack all possiable property here, the caller should unpack it and note the byte order.
122 CopyMem (CapabilityData
, &RecvBuffer
.CapabilityData
, RecvBufferSize
- sizeof (TPM2_RESPONSE_HEADER
) - sizeof (UINT8
));
128 This command returns the information of TPM Family.
130 This function parse the value got from TPM2_GetCapability and return the Family.
132 @param[out] Family The Family of TPM. (a 4-octet character string)
134 @retval EFI_SUCCESS Operation completed successfully.
135 @retval EFI_DEVICE_ERROR The command was unsuccessful.
139 Tpm2GetCapabilityFamily (
143 TPMS_CAPABILITY_DATA TpmCap
;
144 TPMI_YES_NO MoreData
;
147 Status
= Tpm2GetCapability (
148 TPM_CAP_TPM_PROPERTIES
,
149 TPM_PT_FAMILY_INDICATOR
,
154 if (EFI_ERROR (Status
)) {
157 CopyMem (Family
, &TpmCap
.data
.tpmProperties
.tpmProperty
->value
, 4);
163 This command returns the information of TPM manufacture ID.
165 This function parse the value got from TPM2_GetCapability and return the TPM manufacture ID.
167 @param[out] ManufactureId The manufacture ID of TPM.
169 @retval EFI_SUCCESS Operation completed successfully.
170 @retval EFI_DEVICE_ERROR The command was unsuccessful.
174 Tpm2GetCapabilityManufactureID (
175 OUT UINT32
*ManufactureId
178 TPMS_CAPABILITY_DATA TpmCap
;
179 TPMI_YES_NO MoreData
;
182 Status
= Tpm2GetCapability (
183 TPM_CAP_TPM_PROPERTIES
,
189 if (EFI_ERROR (Status
)) {
192 *ManufactureId
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
198 This command returns the information of TPM FirmwareVersion.
200 This function parse the value got from TPM2_GetCapability and return the TPM FirmwareVersion.
202 @param[out] FirmwareVersion1 The FirmwareVersion1.
203 @param[out] FirmwareVersion2 The FirmwareVersion2.
205 @retval EFI_SUCCESS Operation completed successfully.
206 @retval EFI_DEVICE_ERROR The command was unsuccessful.
210 Tpm2GetCapabilityFirmwareVersion (
211 OUT UINT32
*FirmwareVersion1
,
212 OUT UINT32
*FirmwareVersion2
215 TPMS_CAPABILITY_DATA TpmCap
;
216 TPMI_YES_NO MoreData
;
219 Status
= Tpm2GetCapability (
220 TPM_CAP_TPM_PROPERTIES
,
221 TPM_PT_FIRMWARE_VERSION_1
,
226 if (EFI_ERROR (Status
)) {
229 *FirmwareVersion1
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
231 Status
= Tpm2GetCapability (
232 TPM_CAP_TPM_PROPERTIES
,
233 TPM_PT_FIRMWARE_VERSION_2
,
238 if (EFI_ERROR (Status
)) {
241 *FirmwareVersion2
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
247 This command returns the information of the maximum value for commandSize and responseSize in a command.
249 This function parse the value got from TPM2_GetCapability and return the max command size and response size
251 @param[out] MaxCommandSize The maximum value for commandSize in a command.
252 @param[out] MaxResponseSize The maximum value for responseSize in a command.
254 @retval EFI_SUCCESS Operation completed successfully.
255 @retval EFI_DEVICE_ERROR The command was unsuccessful.
259 Tpm2GetCapabilityMaxCommandResponseSize (
260 OUT UINT32
*MaxCommandSize
,
261 OUT UINT32
*MaxResponseSize
264 TPMS_CAPABILITY_DATA TpmCap
;
265 TPMI_YES_NO MoreData
;
268 Status
= Tpm2GetCapability (
269 TPM_CAP_TPM_PROPERTIES
,
270 TPM_PT_MAX_COMMAND_SIZE
,
275 if (EFI_ERROR (Status
)) {
279 *MaxCommandSize
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
281 Status
= Tpm2GetCapability (
282 TPM_CAP_TPM_PROPERTIES
,
283 TPM_PT_MAX_RESPONSE_SIZE
,
288 if (EFI_ERROR (Status
)) {
292 *MaxResponseSize
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
297 This command returns Returns a list of TPMS_ALG_PROPERTIES. Each entry is an
298 algorithm ID and a set of properties of the algorithm.
300 This function parse the value got from TPM2_GetCapability and return the list.
302 @param[out] AlgList List of algorithm.
304 @retval EFI_SUCCESS Operation completed successfully.
305 @retval EFI_DEVICE_ERROR The command was unsuccessful.
309 Tpm2GetCapabilitySupportedAlg (
310 OUT TPML_ALG_PROPERTY
*AlgList
313 TPMS_CAPABILITY_DATA TpmCap
;
314 TPMI_YES_NO MoreData
;
318 Status
= Tpm2GetCapability (
325 if (EFI_ERROR (Status
)) {
329 CopyMem (AlgList
, &TpmCap
.data
.algorithms
, sizeof (TPML_ALG_PROPERTY
));
331 AlgList
->count
= SwapBytes32 (AlgList
->count
);
332 for (Index
= 0; Index
< AlgList
->count
; Index
++) {
333 AlgList
->algProperties
[Index
].alg
= SwapBytes16 (AlgList
->algProperties
[Index
].alg
);
334 WriteUnaligned32 ((UINT32
*)&AlgList
->algProperties
[Index
].algProperties
, SwapBytes32 (ReadUnaligned32 ((UINT32
*)&AlgList
->algProperties
[Index
].algProperties
)));
341 This command returns the information of TPM LockoutCounter.
343 This function parse the value got from TPM2_GetCapability and return the LockoutCounter.
345 @param[out] LockoutCounter The LockoutCounter of TPM.
347 @retval EFI_SUCCESS Operation completed successfully.
348 @retval EFI_DEVICE_ERROR The command was unsuccessful.
352 Tpm2GetCapabilityLockoutCounter (
353 OUT UINT32
*LockoutCounter
356 TPMS_CAPABILITY_DATA TpmCap
;
357 TPMI_YES_NO MoreData
;
360 Status
= Tpm2GetCapability (
361 TPM_CAP_TPM_PROPERTIES
,
362 TPM_PT_LOCKOUT_COUNTER
,
367 if (EFI_ERROR (Status
)) {
370 *LockoutCounter
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
376 This command returns the information of TPM LockoutInterval.
378 This function parse the value got from TPM2_GetCapability and return the LockoutInterval.
380 @param[out] LockoutInterval The LockoutInterval of TPM.
382 @retval EFI_SUCCESS Operation completed successfully.
383 @retval EFI_DEVICE_ERROR The command was unsuccessful.
387 Tpm2GetCapabilityLockoutInterval (
388 OUT UINT32
*LockoutInterval
391 TPMS_CAPABILITY_DATA TpmCap
;
392 TPMI_YES_NO MoreData
;
395 Status
= Tpm2GetCapability (
396 TPM_CAP_TPM_PROPERTIES
,
397 TPM_PT_LOCKOUT_INTERVAL
,
402 if (EFI_ERROR (Status
)) {
405 *LockoutInterval
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
411 This command returns the information of TPM InputBufferSize.
413 This function parse the value got from TPM2_GetCapability and return the InputBufferSize.
415 @param[out] InputBufferSize The InputBufferSize of TPM.
416 the maximum size of a parameter (typically, a TPM2B_MAX_BUFFER)
418 @retval EFI_SUCCESS Operation completed successfully.
419 @retval EFI_DEVICE_ERROR The command was unsuccessful.
423 Tpm2GetCapabilityInputBufferSize (
424 OUT UINT32
*InputBufferSize
427 TPMS_CAPABILITY_DATA TpmCap
;
428 TPMI_YES_NO MoreData
;
431 Status
= Tpm2GetCapability (
432 TPM_CAP_TPM_PROPERTIES
,
438 if (EFI_ERROR (Status
)) {
441 *InputBufferSize
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
447 This command returns the information of TPM PCRs.
449 This function parse the value got from TPM2_GetCapability and return the PcrSelection.
451 @param[out] Pcrs The Pcr Selection
453 @retval EFI_SUCCESS Operation completed successfully.
454 @retval EFI_DEVICE_ERROR The command was unsuccessful.
458 Tpm2GetCapabilityPcrs (
459 OUT TPML_PCR_SELECTION
*Pcrs
462 TPMS_CAPABILITY_DATA TpmCap
;
463 TPMI_YES_NO MoreData
;
467 Status
= Tpm2GetCapability (
474 if (EFI_ERROR (Status
)) {
478 Pcrs
->count
= SwapBytes32 (TpmCap
.data
.assignedPCR
.count
);
479 for (Index
= 0; Index
< Pcrs
->count
; Index
++) {
480 Pcrs
->pcrSelections
[Index
].hash
= SwapBytes16 (TpmCap
.data
.assignedPCR
.pcrSelections
[Index
].hash
);
481 Pcrs
->pcrSelections
[Index
].sizeofSelect
= TpmCap
.data
.assignedPCR
.pcrSelections
[Index
].sizeofSelect
;
482 CopyMem (Pcrs
->pcrSelections
[Index
].pcrSelect
, TpmCap
.data
.assignedPCR
.pcrSelections
[Index
].pcrSelect
, Pcrs
->pcrSelections
[Index
].sizeofSelect
);
489 This command returns the information of TPM AlgorithmSet.
491 This function parse the value got from TPM2_GetCapability and return the AlgorithmSet.
493 @param[out] AlgorithmSet The AlgorithmSet of TPM.
495 @retval EFI_SUCCESS Operation completed successfully.
496 @retval EFI_DEVICE_ERROR The command was unsuccessful.
500 Tpm2GetCapabilityAlgorithmSet (
501 OUT UINT32
*AlgorithmSet
504 TPMS_CAPABILITY_DATA TpmCap
;
505 TPMI_YES_NO MoreData
;
508 Status
= Tpm2GetCapability (
509 TPM_CAP_TPM_PROPERTIES
,
510 TPM_PT_ALGORITHM_SET
,
515 if (EFI_ERROR (Status
)) {
518 *AlgorithmSet
= SwapBytes32 (TpmCap
.data
.tpmProperties
.tpmProperty
->value
);
524 This command is used to check to see if specific combinations of algorithm parameters are supported.
526 @param[in] Parameters Algorithm parameters to be validated
528 @retval EFI_SUCCESS Operation completed successfully.
529 @retval EFI_DEVICE_ERROR Unexpected device behavior.
534 IN TPMT_PUBLIC_PARMS
*Parameters
538 TPM2_TEST_PARMS_COMMAND SendBuffer
;
539 TPM2_TEST_PARMS_RESPONSE RecvBuffer
;
540 UINT32 SendBufferSize
;
541 UINT32 RecvBufferSize
;
547 SendBuffer
.Header
.tag
= SwapBytes16(TPM_ST_NO_SESSIONS
);
548 SendBuffer
.Header
.commandCode
= SwapBytes32(TPM_CC_TestParms
);
550 Buffer
= (UINT8
*)&SendBuffer
.Parameters
;
551 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->type
));
552 Buffer
+= sizeof(UINT16
);
553 switch (Parameters
->type
) {
554 case TPM_ALG_KEYEDHASH
:
555 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.keyedHashDetail
.scheme
.scheme
));
556 Buffer
+= sizeof(UINT16
);
557 switch (Parameters
->parameters
.keyedHashDetail
.scheme
.scheme
) {
559 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.keyedHashDetail
.scheme
.details
.hmac
.hashAlg
));
560 Buffer
+= sizeof(UINT16
);
563 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.keyedHashDetail
.scheme
.details
.xor.hashAlg
));
564 Buffer
+= sizeof(UINT16
);
565 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.keyedHashDetail
.scheme
.details
.xor.kdf
));
566 Buffer
+= sizeof(UINT16
);
569 return EFI_INVALID_PARAMETER
;
571 case TPM_ALG_SYMCIPHER
:
572 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.algorithm
));
573 Buffer
+= sizeof(UINT16
);
574 switch (Parameters
->parameters
.symDetail
.algorithm
) {
576 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.keyBits
.aes
));
577 Buffer
+= sizeof(UINT16
);
578 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.mode
.aes
));
579 Buffer
+= sizeof(UINT16
);
582 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.keyBits
.SM4
));
583 Buffer
+= sizeof(UINT16
);
584 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.mode
.SM4
));
585 Buffer
+= sizeof(UINT16
);
588 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.symDetail
.keyBits
.xor));
589 Buffer
+= sizeof(UINT16
);
594 return EFI_INVALID_PARAMETER
;
598 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.symmetric
.algorithm
));
599 Buffer
+= sizeof(UINT16
);
600 switch (Parameters
->parameters
.rsaDetail
.symmetric
.algorithm
) {
602 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.symmetric
.keyBits
.aes
));
603 Buffer
+= sizeof(UINT16
);
604 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.symmetric
.mode
.aes
));
605 Buffer
+= sizeof(UINT16
);
608 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.symmetric
.keyBits
.SM4
));
609 Buffer
+= sizeof(UINT16
);
610 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.symmetric
.mode
.SM4
));
611 Buffer
+= sizeof(UINT16
);
616 return EFI_INVALID_PARAMETER
;
618 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.scheme
.scheme
));
619 Buffer
+= sizeof(UINT16
);
620 switch (Parameters
->parameters
.rsaDetail
.scheme
.scheme
) {
622 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.scheme
.details
.rsassa
.hashAlg
));
623 Buffer
+= sizeof(UINT16
);
626 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.scheme
.details
.rsapss
.hashAlg
));
627 Buffer
+= sizeof(UINT16
);
632 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.scheme
.details
.oaep
.hashAlg
));
633 Buffer
+= sizeof(UINT16
);
638 return EFI_INVALID_PARAMETER
;
640 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.rsaDetail
.keyBits
));
641 Buffer
+= sizeof(UINT16
);
642 WriteUnaligned32 ((UINT32
*)Buffer
, SwapBytes32 (Parameters
->parameters
.rsaDetail
.exponent
));
643 Buffer
+= sizeof(UINT32
);
646 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.symmetric
.algorithm
));
647 Buffer
+= sizeof(UINT16
);
648 switch (Parameters
->parameters
.eccDetail
.symmetric
.algorithm
) {
650 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.symmetric
.keyBits
.aes
));
651 Buffer
+= sizeof(UINT16
);
652 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.symmetric
.mode
.aes
));
653 Buffer
+= sizeof(UINT16
);
656 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.symmetric
.keyBits
.SM4
));
657 Buffer
+= sizeof(UINT16
);
658 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.symmetric
.mode
.SM4
));
659 Buffer
+= sizeof(UINT16
);
664 return EFI_INVALID_PARAMETER
;
666 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.scheme
.scheme
));
667 Buffer
+= sizeof(UINT16
);
668 switch (Parameters
->parameters
.eccDetail
.scheme
.scheme
) {
670 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.scheme
.details
.ecdsa
.hashAlg
));
671 Buffer
+= sizeof(UINT16
);
674 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.scheme
.details
.ecdaa
.hashAlg
));
675 Buffer
+= sizeof(UINT16
);
677 case TPM_ALG_ECSCHNORR
:
678 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.scheme
.details
.ecSchnorr
.hashAlg
));
679 Buffer
+= sizeof(UINT16
);
686 return EFI_INVALID_PARAMETER
;
688 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.curveID
));
689 Buffer
+= sizeof(UINT16
);
690 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.kdf
.scheme
));
691 Buffer
+= sizeof(UINT16
);
692 switch (Parameters
->parameters
.eccDetail
.kdf
.scheme
) {
694 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.kdf
.details
.mgf1
.hashAlg
));
695 Buffer
+= sizeof(UINT16
);
697 case TPM_ALG_KDF1_SP800_108
:
698 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.kdf
.details
.kdf1_sp800_108
.hashAlg
));
699 Buffer
+= sizeof(UINT16
);
701 case TPM_ALG_KDF1_SP800_56a
:
702 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.kdf
.details
.kdf1_SP800_56a
.hashAlg
));
703 Buffer
+= sizeof(UINT16
);
706 WriteUnaligned16 ((UINT16
*)Buffer
, SwapBytes16 (Parameters
->parameters
.eccDetail
.kdf
.details
.kdf2
.hashAlg
));
707 Buffer
+= sizeof(UINT16
);
712 return EFI_INVALID_PARAMETER
;
716 return EFI_INVALID_PARAMETER
;
719 SendBufferSize
= (UINT32
)((UINTN
)Buffer
- (UINTN
)&SendBuffer
);
720 SendBuffer
.Header
.paramSize
= SwapBytes32 (SendBufferSize
);
725 RecvBufferSize
= sizeof (RecvBuffer
);
726 Status
= Tpm2SubmitCommand (SendBufferSize
, (UINT8
*)&SendBuffer
, &RecvBufferSize
, (UINT8
*)&RecvBuffer
);
727 if (EFI_ERROR (Status
)) {
731 if (RecvBufferSize
< sizeof (TPM2_RESPONSE_HEADER
)) {
732 DEBUG ((EFI_D_ERROR
, "Tpm2TestParms - RecvBufferSize Error - %x\n", RecvBufferSize
));
733 return EFI_DEVICE_ERROR
;
735 if (SwapBytes32(RecvBuffer
.Header
.responseCode
) != TPM_RC_SUCCESS
) {
736 DEBUG ((EFI_D_ERROR
, "Tpm2TestParms - responseCode - %x\n", SwapBytes32(RecvBuffer
.Header
.responseCode
)));
737 return EFI_UNSUPPORTED
;