]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
Add restriction that HashFinal() must be after at least one HashUpdate().
[mirror_edk2.git] / SecurityPkg / Hash2DxeCrypto / Hash2DxeCrypto.c
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