20 TPMI_RH_HIERARCHY_AUTH AuthHandle;
21 UINT32 AuthSessionSize;
24 TPMI_ALG_HASH HashAlg;
29 UINT32 AuthSessionSize;
35 TPMI_RH_CLEAR AuthHandle;
36 UINT32 AuthorizationSize;
48 TPMI_RH_CLEAR AuthHandle;
49 UINT32 AuthorizationSize;
62 TPMI_RH_HIERARCHY_AUTH AuthHandle;
63 UINT32 AuthorizationSize;
76 TPMI_RH_PLATFORM AuthHandle;
77 UINT32 AuthorizationSize;
89 TPMI_RH_PLATFORM AuthHandle;
90 UINT32 AuthorizationSize;
102 TPMI_RH_HIERARCHY AuthHandle;
103 UINT32 AuthorizationSize;
105 TPMI_RH_HIERARCHY Hierarchy;
111 UINT32 ParameterSize;
132 IN TPMI_RH_HIERARCHY_AUTH AuthHandle,
135 IN TPMI_ALG_HASH HashAlg
141 UINT32 SendBufferSize;
142 UINT32 RecvBufferSize;
144 UINT32 SessionInfoSize;
149 SendBuffer.Header.tag =
SwapBytes16 (TPM_ST_SESSIONS);
150 SendBuffer.Header.commandCode =
SwapBytes32 (TPM_CC_SetPrimaryPolicy);
157 Buffer = (UINT8 *)&SendBuffer.AuthSession;
161 Buffer += SessionInfoSize;
162 SendBuffer.AuthSessionSize =
SwapBytes32 (SessionInfoSize);
168 Buffer +=
sizeof (UINT16);
169 CopyMem (Buffer, AuthPolicy->buffer, AuthPolicy->size);
170 Buffer += AuthPolicy->size;
172 Buffer +=
sizeof (UINT16);
174 SendBufferSize = (UINT32)((
UINTN)Buffer - (
UINTN)&SendBuffer);
175 SendBuffer.Header.paramSize =
SwapBytes32 (SendBufferSize);
180 RecvBufferSize =
sizeof (RecvBuffer);
181 Status =
Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
182 if (EFI_ERROR (Status)) {
187 DEBUG ((DEBUG_ERROR,
"Tpm2SetPrimaryPolicy - RecvBufferSize Error - %x\n", RecvBufferSize));
188 Status = EFI_DEVICE_ERROR;
192 if (
SwapBytes32 (RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
193 DEBUG ((DEBUG_ERROR,
"Tpm2SetPrimaryPolicy - responseCode - %x\n",
SwapBytes32 (RecvBuffer.Header.responseCode)));
194 Status = EFI_DEVICE_ERROR;
202 ZeroMem (&SendBuffer,
sizeof (SendBuffer));
203 ZeroMem (&RecvBuffer,
sizeof (RecvBuffer));
219 IN TPMI_RH_CLEAR AuthHandle,
226 UINT32 ResultBufSize;
230 UINT32 SessionInfoSize;
233 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_Clear);
239 Buffer = (UINT8 *)&Cmd.AuthSession;
243 Buffer += SessionInfoSize;
244 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
246 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
249 ResultBufSize =
sizeof (Res);
250 Status =
Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
251 if (EFI_ERROR (Status)) {
255 if (ResultBufSize >
sizeof (Res)) {
256 DEBUG ((DEBUG_ERROR,
"Clear: Failed ExecuteCommand: Buffer Too Small\r\n"));
257 Status = EFI_BUFFER_TOO_SMALL;
265 if (RespSize >
sizeof (Res)) {
266 DEBUG ((DEBUG_ERROR,
"Clear: Response size too large! %d\r\n", RespSize));
267 Status = EFI_BUFFER_TOO_SMALL;
274 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
275 DEBUG ((DEBUG_ERROR,
"Clear: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
276 Status = EFI_DEVICE_ERROR;
308 IN TPMI_RH_CLEAR AuthHandle,
310 IN TPMI_YES_NO Disable
316 UINT32 ResultBufSize;
320 UINT32 SessionInfoSize;
323 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_ClearControl);
329 Buffer = (UINT8 *)&Cmd.AuthSession;
333 Buffer += SessionInfoSize;
334 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
337 *(UINT8 *)Buffer = Disable;
340 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
343 ResultBufSize =
sizeof (Res);
344 Status =
Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
345 if (EFI_ERROR (Status)) {
349 if (ResultBufSize >
sizeof (Res)) {
350 DEBUG ((DEBUG_ERROR,
"ClearControl: Failed ExecuteCommand: Buffer Too Small\r\n"));
351 Status = EFI_BUFFER_TOO_SMALL;
359 if (RespSize >
sizeof (Res)) {
360 DEBUG ((DEBUG_ERROR,
"ClearControl: Response size too large! %d\r\n", RespSize));
361 Status = EFI_BUFFER_TOO_SMALL;
368 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
369 DEBUG ((DEBUG_ERROR,
"ClearControl: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
370 Status = EFI_DEVICE_ERROR;
402 IN TPMI_RH_HIERARCHY_AUTH AuthHandle,
413 UINT32 SessionInfoSize;
415 UINT32 ResultBufSize;
422 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_HierarchyChangeAuth);
428 Buffer = (UINT8 *)&Cmd.AuthSession;
432 Buffer += SessionInfoSize;
433 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
437 Buffer +=
sizeof (UINT16);
440 CopyMem (Buffer, NewAuth->buffer, NewAuth->size);
441 Buffer += NewAuth->size;
443 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
446 ResultBuf = (UINT8 *)&Res;
447 ResultBufSize =
sizeof (Res);
458 if (EFI_ERROR (Status)) {
462 if (ResultBufSize >
sizeof (Res)) {
463 DEBUG ((DEBUG_ERROR,
"HierarchyChangeAuth: Failed ExecuteCommand: Buffer Too Small\r\n"));
464 Status = EFI_BUFFER_TOO_SMALL;
472 if (RespSize >
sizeof (Res)) {
473 DEBUG ((DEBUG_ERROR,
"HierarchyChangeAuth: Response size too large! %d\r\n", RespSize));
474 Status = EFI_BUFFER_TOO_SMALL;
481 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
482 DEBUG ((DEBUG_ERROR,
"HierarchyChangeAuth: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
483 Status = EFI_DEVICE_ERROR;
509 IN TPMI_RH_PLATFORM AuthHandle,
519 UINT32 SessionInfoSize;
521 UINT32 ResultBufSize;
528 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_ChangeEPS);
534 Buffer = (UINT8 *)&Cmd.AuthSession;
538 Buffer += SessionInfoSize;
539 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
541 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
544 ResultBuf = (UINT8 *)&Res;
545 ResultBufSize =
sizeof (Res);
556 if (EFI_ERROR (Status)) {
560 if (ResultBufSize >
sizeof (Res)) {
561 DEBUG ((DEBUG_ERROR,
"ChangeEPS: Failed ExecuteCommand: Buffer Too Small\r\n"));
562 Status = EFI_BUFFER_TOO_SMALL;
570 if (RespSize >
sizeof (Res)) {
571 DEBUG ((DEBUG_ERROR,
"ChangeEPS: Response size too large! %d\r\n", RespSize));
572 Status = EFI_BUFFER_TOO_SMALL;
579 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
580 DEBUG ((DEBUG_ERROR,
"ChangeEPS: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
581 Status = EFI_DEVICE_ERROR;
607 IN TPMI_RH_PLATFORM AuthHandle,
617 UINT32 SessionInfoSize;
619 UINT32 ResultBufSize;
626 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_ChangePPS);
632 Buffer = (UINT8 *)&Cmd.AuthSession;
636 Buffer += SessionInfoSize;
637 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
639 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
642 ResultBuf = (UINT8 *)&Res;
643 ResultBufSize =
sizeof (Res);
654 if (EFI_ERROR (Status)) {
658 if (ResultBufSize >
sizeof (Res)) {
659 DEBUG ((DEBUG_ERROR,
"ChangePPS: Failed ExecuteCommand: Buffer Too Small\r\n"));
660 Status = EFI_BUFFER_TOO_SMALL;
668 if (RespSize >
sizeof (Res)) {
669 DEBUG ((DEBUG_ERROR,
"ChangePPS: Response size too large! %d\r\n", RespSize));
670 Status = EFI_BUFFER_TOO_SMALL;
677 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
678 DEBUG ((DEBUG_ERROR,
"ChangePPS: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
679 Status = EFI_DEVICE_ERROR;
707 IN TPMI_RH_HIERARCHY AuthHandle,
709 IN TPMI_RH_HIERARCHY Hierarchy,
719 UINT32 SessionInfoSize;
721 UINT32 ResultBufSize;
728 Cmd.Header.commandCode =
SwapBytes32 (TPM_CC_HierarchyControl);
734 Buffer = (UINT8 *)&Cmd.AuthSession;
738 Buffer += SessionInfoSize;
739 Cmd.AuthorizationSize =
SwapBytes32 (SessionInfoSize);
742 Buffer +=
sizeof (UINT32);
744 *(UINT8 *)Buffer = State;
747 CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
750 ResultBuf = (UINT8 *)&Res;
751 ResultBufSize =
sizeof (Res);
762 if (EFI_ERROR (Status)) {
766 if (ResultBufSize >
sizeof (Res)) {
767 DEBUG ((DEBUG_ERROR,
"HierarchyControl: Failed ExecuteCommand: Buffer Too Small\r\n"));
768 Status = EFI_BUFFER_TOO_SMALL;
776 if (RespSize >
sizeof (Res)) {
777 DEBUG ((DEBUG_ERROR,
"HierarchyControl: Response size too large! %d\r\n", RespSize));
778 Status = EFI_BUFFER_TOO_SMALL;
785 if (
SwapBytes32 (Res.Header.responseCode) != TPM_RC_SUCCESS) {
786 DEBUG ((DEBUG_ERROR,
"HierarchyControl: Response Code error! 0x%08x\r\n",
SwapBytes32 (Res.Header.responseCode)));
787 Status = EFI_DEVICE_ERROR;
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define DEBUG(Expression)
UINT32 EFIAPI CopyAuthSessionCommand(IN TPMS_AUTH_COMMAND *AuthSessionIn OPTIONAL, OUT UINT8 *AuthSessionOut)
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
EFI_STATUS EFIAPI Tpm2ChangeEPS(IN TPMI_RH_PLATFORM AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession)
EFI_STATUS EFIAPI Tpm2Clear(IN TPMI_RH_CLEAR AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL)
EFI_STATUS EFIAPI Tpm2HierarchyChangeAuth(IN TPMI_RH_HIERARCHY_AUTH AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession, IN TPM2B_AUTH *NewAuth)
EFI_STATUS EFIAPI Tpm2HierarchyControl(IN TPMI_RH_HIERARCHY AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession, IN TPMI_RH_HIERARCHY Hierarchy, IN TPMI_YES_NO State)
EFI_STATUS EFIAPI Tpm2SetPrimaryPolicy(IN TPMI_RH_HIERARCHY_AUTH AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession, IN TPM2B_DIGEST *AuthPolicy, IN TPMI_ALG_HASH HashAlg)
EFI_STATUS EFIAPI Tpm2ClearControl(IN TPMI_RH_CLEAR AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, IN TPMI_YES_NO Disable)
EFI_STATUS EFIAPI Tpm2ChangePPS(IN TPMI_RH_PLATFORM AuthHandle, IN TPMS_AUTH_COMMAND *AuthSession)