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>
Implement TPM1.2 NV storage related command.\r
\r
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. <BR>\r
Implement TPM1.2 NV storage related command.\r
\r
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. <BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
{\r
EFI_STATUS Status;\r
TPM_CMD_NV_WRITE_VALUE Command;\r
{\r
EFI_STATUS Status;\r
TPM_CMD_NV_WRITE_VALUE Command;\r
+ UINT32 CommandLength;\r
TPM_RSP_COMMAND_HDR Response;\r
TPM_RSP_COMMAND_HDR Response;\r
+ UINT32 ResponseLength;\r
\r
if (DataSize > sizeof (Command.Data)) {\r
return EFI_UNSUPPORTED;\r
\r
if (DataSize > sizeof (Command.Data)) {\r
return EFI_UNSUPPORTED;\r
// send Tpm command TPM_ORD_NV_WriteValue\r
//\r
Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
// send Tpm command TPM_ORD_NV_WriteValue\r
//\r
Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
- Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) + DataSize);\r
+ CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;\r
+ Command.Hdr.paramSize = SwapBytes32 (CommandLength);\r
Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_NV_WriteValue);\r
Command.NvIndex = SwapBytes32 (NvIndex);\r
Command.Offset = SwapBytes32 (Offset);\r
Command.DataSize = SwapBytes32 (DataSize);\r
CopyMem (Command.Data, Data, DataSize);\r
Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_NV_WriteValue);\r
Command.NvIndex = SwapBytes32 (NvIndex);\r
Command.Offset = SwapBytes32 (Offset);\r
Command.DataSize = SwapBytes32 (DataSize);\r
CopyMem (Command.Data, Data, DataSize);\r
- Length = sizeof (Response);\r
- Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r
+ ResponseLength = sizeof (Response);\r
+ Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, &ResponseLength, (UINT8 *)&Response);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r