Skip to content

Commit

Permalink
Add restriction that HashFinal() must be after at least one HashUpdat…
Browse files Browse the repository at this point in the history
…e().

Just follow UEFI spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <[email protected]>
Reviewed-by: "Zhang, Chao B" <[email protected]>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18229 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
jyao1 authored and jyao1 committed Aug 18, 2015
1 parent 70bd699 commit a3a0974
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions SecurityPkg/Hash2DxeCrypto/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef struct {
EFI_HASH2_PROTOCOL Hash2Protocol;
VOID *HashContext;
VOID *HashInfoContext;
BOOLEAN Updated;
} HASH2_INSTANCE_DATA;

#define HASH2_INSTANCE_DATA_FROM_THIS(a) \
Expand Down
7 changes: 6 additions & 1 deletion SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ BaseCrypto2HashInit (
//
Instance->HashContext = HashCtx;
Instance->HashInfoContext = HashInfo;
Instance->Updated = FALSE;

return EFI_SUCCESS;
}
Expand Down Expand Up @@ -551,6 +552,8 @@ BaseCrypto2HashUpdate (
return EFI_OUT_OF_RESOURCES;
}

Instance->Updated = TRUE;

return EFI_SUCCESS;
}

Expand Down Expand Up @@ -590,7 +593,8 @@ BaseCrypto2HashFinal (
// Consistency Check
//
Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);
if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL)) {
if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL) ||
(!Instance->Updated)) {
return EFI_NOT_READY;
}
HashInfo = Instance->HashInfoContext;
Expand All @@ -604,6 +608,7 @@ BaseCrypto2HashFinal (
FreePool (HashCtx);
Instance->HashInfoContext = NULL;
Instance->HashContext = NULL;
Instance->Updated = FALSE;

if (!Ret) {
return EFI_OUT_OF_RESOURCES;
Expand Down

0 comments on commit a3a0974

Please sign in to comment.