summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
authorYao, Jiewen <Jiewen.Yao@intel.com>2015-08-17 05:48:30 +0000
committerjyao1 <jyao1@Edk2>2015-08-17 05:48:30 +0000
commit099bff5def30b277157b2387d5d910e2ad14f84e (patch)
treebd47e6b58d9c5cdcd379e4e0d2e58af92d9ad7ce /SecurityPkg
parent13a220a998a9d504cdeb7a858cc083f6879ec26e (diff)
downloadedk2-platforms-099bff5def30b277157b2387d5d910e2ad14f84e.tar.xz
Add context check and init in BaseCrypto2Hash().
Follow UEFI specification to add context check and init in BaseCrypto2Hash(), so that other function can get proper status on hash operation. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <Jiewen.Yao@intel.com> Reviewed-by: "Zhang, Chao B" <chao.b.zhang@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18227 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c b/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
index dab0299236..94057ab2e1 100644
--- a/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
+++ b/SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
@@ -358,6 +358,7 @@ BaseCrypto2Hash (
UINTN CtxSize;
BOOLEAN Ret;
EFI_STATUS Status;
+ HASH2_INSTANCE_DATA *Instance;
Status = EFI_SUCCESS;
@@ -373,6 +374,13 @@ BaseCrypto2Hash (
if (HashInfo == NULL) {
return EFI_UNSUPPORTED;
}
+
+ Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);
+ if (Instance->HashContext != NULL) {
+ FreePool (Instance->HashContext);
+ }
+ Instance->HashInfoContext = NULL;
+ Instance->HashContext = NULL;
//
// Start hash sequence
@@ -392,6 +400,12 @@ BaseCrypto2Hash (
goto Done;
}
+ //
+ // Setup the context
+ //
+ Instance->HashContext = HashCtx;
+ Instance->HashInfoContext = HashInfo;
+
Ret = HashInfo->Update (HashCtx, Message, MessageSize);
if (!Ret) {
Status = EFI_OUT_OF_RESOURCES;
@@ -404,7 +418,12 @@ BaseCrypto2Hash (
goto Done;
}
Done:
+ //
+ // Cleanup the context
+ //
FreePool (HashCtx);
+ Instance->HashInfoContext = NULL;
+ Instance->HashContext = NULL;
return Status;
}