]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add context check and init in BaseCrypto2Hash().
authorYao, Jiewen <Jiewen.Yao@intel.com>
Mon, 17 Aug 2015 05:48:30 +0000 (05:48 +0000)
committerjyao1 <jyao1@Edk2>
Mon, 17 Aug 2015 05:48:30 +0000 (05:48 +0000)
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

SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c

index dab02992362ed0c66caebfc769af69f89694317e..94057ab2e1fc7489ea344fbce509883b8db65352 100644 (file)
@@ -358,6 +358,7 @@ BaseCrypto2Hash (
   UINTN                    CtxSize;\r
   BOOLEAN                  Ret;\r
   EFI_STATUS               Status;\r
+  HASH2_INSTANCE_DATA      *Instance;\r
 \r
   Status = EFI_SUCCESS;\r
 \r
@@ -373,6 +374,13 @@ BaseCrypto2Hash (
   if (HashInfo == NULL) {\r
     return EFI_UNSUPPORTED;\r
   }\r
+  \r
+  Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);\r
+  if (Instance->HashContext != NULL) {\r
+    FreePool (Instance->HashContext);\r
+  }\r
+  Instance->HashInfoContext = NULL;\r
+  Instance->HashContext = NULL;\r
 \r
   //\r
   // Start hash sequence\r
@@ -392,6 +400,12 @@ BaseCrypto2Hash (
     goto Done;\r
   }\r
 \r
+  //\r
+  // Setup the context\r
+  //\r
+  Instance->HashContext = HashCtx;\r
+  Instance->HashInfoContext = HashInfo;\r
+\r
   Ret = HashInfo->Update (HashCtx, Message, MessageSize);\r
   if (!Ret) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
@@ -404,7 +418,12 @@ BaseCrypto2Hash (
     goto Done;\r
   }\r
 Done:\r
+  //\r
+  // Cleanup the context\r
+  //\r
   FreePool (HashCtx);\r
+  Instance->HashInfoContext = NULL;\r
+  Instance->HashContext = NULL;\r
   return Status;\r
 }\r
 \r