summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
authorSamer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com>2016-04-29 04:24:04 +0800
committerZhang, Chao B <chao.b.zhang@intel.com>2016-05-03 10:10:58 +0800
commit8b1331df8b303b296c85883935caf84561f54e37 (patch)
treec4625e50465a64686d6df58a651a188b8ed9fca1 /SecurityPkg
parentfd338d8bd75034fd4fd35c9b326e9829c835c84f (diff)
downloadedk2-platforms-8b1331df8b303b296c85883935caf84561f54e37.tar.xz
SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order
Fix Tpm12NvWriteValue() command/response length byte order. Tpm12SubmitCommand() was using the value from Command.Hdr.paramSize which was swapped to be Big Endian, but the function was expecting it in UINT32 Little Endian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hpe.com> Signed-off-by: Derek Lin <derek.lin2@hpe.com> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com> Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
index 7baafa8f55..e176b00f6b 100644
--- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
@@ -2,6 +2,7 @@
Implement TPM1.2 NV storage related command.
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. <BR>
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -199,8 +200,9 @@ Tpm12NvWriteValue (
{
EFI_STATUS Status;
TPM_CMD_NV_WRITE_VALUE Command;
+ UINT32 CommandLength;
TPM_RSP_COMMAND_HDR Response;
- UINT32 Length;
+ UINT32 ResponseLength;
if (DataSize > sizeof (Command.Data)) {
return EFI_UNSUPPORTED;
@@ -210,14 +212,15 @@ Tpm12NvWriteValue (
// send Tpm command TPM_ORD_NV_WriteValue
//
Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
- Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) + DataSize);
+ CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;
+ Command.Hdr.paramSize = SwapBytes32 (CommandLength);
Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_NV_WriteValue);
Command.NvIndex = SwapBytes32 (NvIndex);
Command.Offset = SwapBytes32 (Offset);
Command.DataSize = SwapBytes32 (DataSize);
CopyMem (Command.Data, Data, DataSize);
- Length = sizeof (Response);
- Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, &Length, (UINT8 *)&Response);
+ ResponseLength = sizeof (Response);
+ Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, &ResponseLength, (UINT8 *)&Response);
if (EFI_ERROR (Status)) {
return Status;
}