SecurityPkg/Tpm12CommandLib: Always check response returnCode

https://bugzilla.tianocore.org/show_bug.cgi?id=338

Update the Tpm12CommandLib to consistently check the returnCode
field of a response packet.  These checks are missing from the
GetCapability and SelfTest commands.  The functions
Tpm12ContinueSelfTest(), Tpm12GetCapabilityFlagPermanent(), and
Tpm12GetCapabilityFlagVolatile() are updated to verify that the
response returnCode is not an error.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
This commit is contained in:
Michael Kinney
2017-01-10 08:46:20 -08:00
parent 2bdfb11df9
commit 8b17ad862c
2 changed files with 25 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/** @file
Implement TPM1.2 Get Capabilities related commands.
Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. <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
@ -79,6 +79,11 @@ Tpm12GetCapabilityFlagPermanent (
return Status;
}
if (SwapBytes32 (Response.Hdr.returnCode) != TPM_SUCCESS) {
DEBUG ((DEBUG_ERROR, "Tpm12GetCapabilityFlagPermanent: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.Hdr.returnCode)));
return EFI_DEVICE_ERROR;
}
ZeroMem (TpmPermanentFlags, sizeof (*TpmPermanentFlags));
CopyMem (TpmPermanentFlags, &Response.Flags, MIN (sizeof (*TpmPermanentFlags), Response.ResponseSize));
@ -120,6 +125,11 @@ Tpm12GetCapabilityFlagVolatile (
return Status;
}
if (SwapBytes32 (Response.Hdr.returnCode) != TPM_SUCCESS) {
DEBUG ((DEBUG_ERROR, "Tpm12GetCapabilityFlagVolatile: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.Hdr.returnCode)));
return EFI_DEVICE_ERROR;
}
ZeroMem (VolatileFlags, sizeof (*VolatileFlags));
CopyMem (VolatileFlags, &Response.Flags, MIN (sizeof (*VolatileFlags), Response.ResponseSize));