]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add restriction that HashFinal() must be after at least one HashUpdate().
authorYao, Jiewen <Jiewen.Yao@intel.com>
Tue, 18 Aug 2015 02:11:10 +0000 (02:11 +0000)
committerjyao1 <jyao1@Edk2>
Tue, 18 Aug 2015 02:11:10 +0000 (02:11 +0000)
Just follow UEFI spec.

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@18229 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Hash2DxeCrypto/Driver.h
SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c

index 771aedc1ed663b6b16c3d43a541677c929167342..a145858fa0e066e575e8847f51d7acb2742c887f 100644 (file)
@@ -57,6 +57,7 @@ typedef struct {
   EFI_HASH2_PROTOCOL               Hash2Protocol;\r
   VOID                             *HashContext;\r
   VOID                             *HashInfoContext;\r
+  BOOLEAN                          Updated;\r
 } HASH2_INSTANCE_DATA;\r
 \r
 #define HASH2_INSTANCE_DATA_FROM_THIS(a) \\r
index 94057ab2e1fc7489ea344fbce509883b8db65352..ab34de735116b9a67499b2b74fa6b3b990ff9fc3 100644 (file)
@@ -500,6 +500,7 @@ BaseCrypto2HashInit (
   //\r
   Instance->HashContext = HashCtx;\r
   Instance->HashInfoContext = HashInfo;\r
+  Instance->Updated = FALSE;\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -551,6 +552,8 @@ BaseCrypto2HashUpdate (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  Instance->Updated = TRUE;\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -590,7 +593,8 @@ BaseCrypto2HashFinal (
   // Consistency Check\r
   //\r
   Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);\r
-  if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL)) {\r
+  if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL) ||\r
+      (!Instance->Updated)) {\r
     return EFI_NOT_READY;\r
   }\r
   HashInfo = Instance->HashInfoContext;\r
@@ -604,6 +608,7 @@ BaseCrypto2HashFinal (
   FreePool (HashCtx);\r
   Instance->HashInfoContext = NULL;\r
   Instance->HashContext = NULL;\r
+  Instance->Updated = FALSE;\r
 \r
   if (!Ret) {\r
     return EFI_OUT_OF_RESOURCES;\r