diff options
Diffstat (limited to 'SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c')
-rw-r--r-- | SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c index 1afc562998..6f6ac1e2d0 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c @@ -24,9 +24,9 @@ typedef struct { } TPM2_SET_ALGORITHM_SET_COMMAND;
typedef struct {
- TPM2_RESPONSE_HEADER Header;
- UINT32 AuthSessionSize;
- TPMS_AUTH_RESPONSE AuthSession;
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
} TPM2_SET_ALGORITHM_SET_RESPONSE;
#pragma pack()
@@ -46,24 +46,24 @@ typedef struct { EFI_STATUS
EFIAPI
Tpm2SetAlgorithmSet (
- IN TPMI_RH_PLATFORM AuthHandle,
- IN TPMS_AUTH_COMMAND *AuthSession,
- IN UINT32 AlgorithmSet
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN UINT32 AlgorithmSet
)
{
- EFI_STATUS Status;
- TPM2_SET_ALGORITHM_SET_COMMAND SendBuffer;
- TPM2_SET_ALGORITHM_SET_RESPONSE RecvBuffer;
- UINT32 SendBufferSize;
- UINT32 RecvBufferSize;
- UINT8 *Buffer;
- UINT32 SessionInfoSize;
+ EFI_STATUS Status;
+ TPM2_SET_ALGORITHM_SET_COMMAND SendBuffer;
+ TPM2_SET_ALGORITHM_SET_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
//
// Construct command
//
- SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
- SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_SetAlgorithmSet);
+ SendBuffer.Header.tag = SwapBytes16 (TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32 (TPM_CC_SetAlgorithmSet);
SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
@@ -73,24 +73,24 @@ Tpm2SetAlgorithmSet ( Buffer = (UINT8 *)&SendBuffer.AuthSession;
// sessionInfoSize
- SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
- Buffer += SessionInfoSize;
- SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32 (SessionInfoSize);
//
// Real data
//
- WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(AlgorithmSet));
- Buffer += sizeof(UINT32);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (AlgorithmSet));
+ Buffer += sizeof (UINT32);
- SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
+ SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
//
// send Tpm command
//
RecvBufferSize = sizeof (RecvBuffer);
- Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -100,8 +100,9 @@ Tpm2SetAlgorithmSet ( Status = EFI_DEVICE_ERROR;
goto Done;
}
- if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Tpm2SetAlgorithmSet - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+
+ if (SwapBytes32 (RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((DEBUG_ERROR, "Tpm2SetAlgorithmSet - responseCode - %x\n", SwapBytes32 (RecvBuffer.Header.responseCode)));
Status = EFI_DEVICE_ERROR;
goto Done;
}
@@ -110,7 +111,7 @@ Done: //
// Clear AuthSession Content
//
- ZeroMem (&SendBuffer, sizeof(SendBuffer));
- ZeroMem (&RecvBuffer, sizeof(RecvBuffer));
+ ZeroMem (&SendBuffer, sizeof (SendBuffer));
+ ZeroMem (&RecvBuffer, sizeof (RecvBuffer));
return Status;
}
|