mirror of https://github.com/acidanthera/audk.git
Add restriction that HashFinal() must be after at least one HashUpdate().
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
This commit is contained in:
parent
70bd69912a
commit
a3a0974822
|
@ -57,6 +57,7 @@ typedef struct {
|
||||||
EFI_HASH2_PROTOCOL Hash2Protocol;
|
EFI_HASH2_PROTOCOL Hash2Protocol;
|
||||||
VOID *HashContext;
|
VOID *HashContext;
|
||||||
VOID *HashInfoContext;
|
VOID *HashInfoContext;
|
||||||
|
BOOLEAN Updated;
|
||||||
} HASH2_INSTANCE_DATA;
|
} HASH2_INSTANCE_DATA;
|
||||||
|
|
||||||
#define HASH2_INSTANCE_DATA_FROM_THIS(a) \
|
#define HASH2_INSTANCE_DATA_FROM_THIS(a) \
|
||||||
|
|
|
@ -500,6 +500,7 @@ BaseCrypto2HashInit (
|
||||||
//
|
//
|
||||||
Instance->HashContext = HashCtx;
|
Instance->HashContext = HashCtx;
|
||||||
Instance->HashInfoContext = HashInfo;
|
Instance->HashInfoContext = HashInfo;
|
||||||
|
Instance->Updated = FALSE;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -551,6 +552,8 @@ BaseCrypto2HashUpdate (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instance->Updated = TRUE;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +593,8 @@ BaseCrypto2HashFinal (
|
||||||
// Consistency Check
|
// Consistency Check
|
||||||
//
|
//
|
||||||
Instance = HASH2_INSTANCE_DATA_FROM_THIS(This);
|
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;
|
return EFI_NOT_READY;
|
||||||
}
|
}
|
||||||
HashInfo = Instance->HashInfoContext;
|
HashInfo = Instance->HashInfoContext;
|
||||||
|
@ -604,6 +608,7 @@ BaseCrypto2HashFinal (
|
||||||
FreePool (HashCtx);
|
FreePool (HashCtx);
|
||||||
Instance->HashInfoContext = NULL;
|
Instance->HashInfoContext = NULL;
|
||||||
Instance->HashContext = NULL;
|
Instance->HashContext = NULL;
|
||||||
|
Instance->Updated = FALSE;
|
||||||
|
|
||||||
if (!Ret) {
|
if (!Ret) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
|
Loading…
Reference in New Issue