in DfciPkg/IdentityAndAuthManager/CertSupport.c [291:344]
OUT UINT8 (*CertDigest)[SHA1_FINGERPRINT_DIGEST_SIZE])
{
VOID *Sha1Ctx= NULL;
UINTN CtxSize;
BOOLEAN Flag = FALSE;
EFI_STATUS Status;
if ((TrustedCert == NULL) || (CertLength == 0) || (CertDigest == NULL))
{
DEBUG((DEBUG_ERROR, "%a: Invalid input parameters.\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
//Thumbprint is nothing but SHA1 Digest. There are no library functions available to read this from X509 Cert.
CtxSize = Sha1GetContextSize();
Sha1Ctx = AllocatePool(CtxSize);
if (Sha1Ctx == NULL)
{
DEBUG((DEBUG_ERROR, "%a: Failed to allocate Sha1Ctx.\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
Status = EFI_ABORTED;
Flag = Sha1Init(Sha1Ctx);
if (!Flag)
{
DEBUG((DEBUG_ERROR, "%a: Failed to Sha1Init.\n", __FUNCTION__));
goto CLEANUP;
}
Flag = Sha1Update(Sha1Ctx, TrustedCert, CertLength);
if (!Flag)
{
DEBUG((DEBUG_ERROR, "%a: Failed to Sha1Update.\n", __FUNCTION__));
goto CLEANUP;
}
Flag = Sha1Final(Sha1Ctx, (UINT8 *) CertDigest);
if (!Flag)
{
DEBUG((DEBUG_ERROR, "%a: Failed to Sha1Final.\n", __FUNCTION__));
goto CLEANUP;
}
Status = EFI_SUCCESS;
CLEANUP:
if (Sha1Ctx)
{
FreePool(Sha1Ctx);
}
return Status;
}