Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecurityPkg: Fixed compilation for OvmfPkgX64 -D TPM2_ENABLE. #68

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -595,15 +595,15 @@ IsCertHashFoundInDbx (
goto Done;
}

if (!mHash[HashAlg].HashInit (HashCtx)) {
if (EFI_ERROR(mHash[HashAlg].HashInit (HashCtx))) {
goto Done;
}

if (!mHash[HashAlg].HashUpdate (HashCtx, TBSCert, TBSCertSize)) {
if (EFI_ERROR(mHash[HashAlg].HashUpdate (HashCtx, TBSCert, TBSCertSize))) {
goto Done;
}

if (!mHash[HashAlg].HashFinal (HashCtx, CertDigest)) {
if (EFI_ERROR(mHash[HashAlg].HashFinal (HashCtx, CertDigest))) {
goto Done;
}

Expand Down
34 changes: 18 additions & 16 deletions SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,26 @@ Tpm2SetSha1ToDigestList (
@retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
@retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha1HashInit (
OUT VOID **HashHandle
OUT HASH_HANDLE *HashHandle
)
{
VOID *Sha1Ctx;
UINTN CtxSize;

CtxSize = Sha1GetContextSize ();
Sha1Ctx = AllocatePool (CtxSize);
ASSERT (Sha1Ctx != NULL);
if (Sha1Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}

Sha1Init (Sha1Ctx);

*HashHandle = Sha1Ctx;
*HashHandle = (HASH_HANDLE)Sha1Ctx;

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -74,17 +76,17 @@ Sha1HashInit (

@retval EFI_SUCCESS Hash sequence updated.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha1HashUpdate (
IN VOID *HashHandle,
IN CONST VOID *DataToHash,
IN HASH_HANDLE HashHandle,
IN VOID *DataToHash,
IN UINTN DataToHashLen
)
{
Sha1Update (HashHandle, DataToHash, DataToHashLen);
Sha1Update ((VOID *)HashHandle, DataToHash, DataToHashLen);

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -95,28 +97,28 @@ Sha1HashUpdate (

@retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha1HashFinal (
IN VOID *HashHandle,
IN HASH_HANDLE HashHandle,
OUT TPML_DIGEST_VALUES *DigestList
)
{
UINT8 Digest[SHA1_DIGEST_SIZE];

Sha1Final (HashHandle, Digest);
Sha1Final ((VOID *)HashHandle, Digest);

FreePool (HashHandle);
FreePool ((VOID *)HashHandle);

Tpm2SetSha1ToDigestList (DigestList, Digest);

return TRUE;
return EFI_SUCCESS;
}

HASH_INTERFACE mSha1InternalHashInstance = {
HASH_ALGORITHM_SHA1_GUID,
Sha1HashInit,
Sha1Update,
Sha1HashUpdate,
Sha1HashFinal,
};

Expand Down
32 changes: 17 additions & 15 deletions SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,26 @@ Tpm2SetSha256ToDigestList (
@retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
@retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha256HashInit (
OUT VOID **HashHandle
OUT HASH_HANDLE *HashHandle
)
{
VOID *Sha256Ctx;
UINTN CtxSize;

CtxSize = Sha256GetContextSize ();
Sha256Ctx = AllocatePool (CtxSize);
ASSERT (Sha256Ctx != NULL);
if (Sha256Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}

Sha256Init (Sha256Ctx);

*HashHandle = Sha256Ctx;
*HashHandle = (HASH_HANDLE)Sha256Ctx;

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -74,17 +76,17 @@ Sha256HashInit (

@retval EFI_SUCCESS Hash sequence updated.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha256HashUpdate (
IN VOID *HashHandle,
IN CONST VOID *DataToHash,
IN HASH_HANDLE HashHandle,
IN VOID *DataToHash,
IN UINTN DataToHashLen
)
{
Sha256Update (HashHandle, DataToHash, DataToHashLen);
Sha256Update ((VOID *)HashHandle, DataToHash, DataToHashLen);

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -95,22 +97,22 @@ Sha256HashUpdate (

@retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha256HashFinal (
IN VOID *HashHandle,
IN HASH_HANDLE HashHandle,
OUT TPML_DIGEST_VALUES *DigestList
)
{
UINT8 Digest[SHA256_DIGEST_SIZE];

Sha256Final (HashHandle, Digest);
Sha256Final ((VOID *)HashHandle, Digest);

FreePool (HashHandle);
FreePool ((VOID *)HashHandle);

Tpm2SetSha256ToDigestList (DigestList, Digest);

return TRUE;
return EFI_SUCCESS;
}

HASH_INTERFACE mSha256InternalHashInstance = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Sha384HashInit (

CtxSize = Sha384GetContextSize ();
Sha384Ctx = AllocatePool (CtxSize);
ASSERT (Sha384Ctx != NULL);
if (Sha384Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}

Sha384Init (Sha384Ctx);

Expand Down Expand Up @@ -106,12 +108,10 @@ Sha384HashFinal (
)
{
UINT8 Digest[SHA384_DIGEST_SIZE];
VOID *Sha384Ctx;

Sha384Ctx = (VOID *)HashHandle;
Sha384Final (Sha384Ctx, Digest);
Sha384Final ((VOID *)HashHandle, Digest);

FreePool (Sha384Ctx);
FreePool ((VOID *)HashHandle);

Tpm2SetSha384ToDigestList (DigestList, Digest);

Expand Down
36 changes: 18 additions & 18 deletions SecurityPkg/Library/HashInstanceLibSha512/HashInstanceLibSha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,26 @@ Tpm2SetSha512ToDigestList (
@retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
@retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha512HashInit (
OUT VOID **HashHandle
OUT HASH_HANDLE *HashHandle
)
{
VOID *Sha512Ctx;
UINTN CtxSize;

CtxSize = Sha512GetContextSize ();
Sha512Ctx = AllocatePool (CtxSize);
ASSERT (Sha512Ctx != NULL);
if (Sha512Ctx == NULL) {
return EFI_OUT_OF_RESOURCES;
}

Sha512Init (Sha512Ctx);

*HashHandle = Sha512Ctx;
*HashHandle = (HASH_HANDLE)Sha512Ctx;

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -73,17 +75,17 @@ Sha512HashInit (

@retval EFI_SUCCESS Hash sequence updated.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha512HashUpdate (
IN VOID *HashHandle,
IN CONST VOID *DataToHash,
IN UINTN DataToHashLen
IN HASH_HANDLE HashHandle,
IN VOID *DataToHash,
IN UINTN DataToHashLen
)
{
Sha512Update (HashHandle, DataToHash, DataToHashLen);
Sha512Update ((VOID *)HashHandle, DataToHash, DataToHashLen);

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -94,24 +96,22 @@ Sha512HashUpdate (

@retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sha512HashFinal (
IN VOID *HashHandle,
IN HASH_HANDLE HashHandle,
OUT TPML_DIGEST_VALUES *DigestList
)
{
UINT8 Digest[SHA512_DIGEST_SIZE];
VOID *Sha512Ctx;

Sha512Ctx = (VOID *)HashHandle;
Sha512Final (Sha512Ctx, Digest);
Sha512Final ((VOID *)HashHandle, Digest);

FreePool (Sha512Ctx);
FreePool ((VOID *)HashHandle);

Tpm2SetSha512ToDigestList (DigestList, Digest);

return TRUE;
return EFI_SUCCESS;
}

HASH_INTERFACE mSha512InternalHashInstance = {
Expand Down
32 changes: 16 additions & 16 deletions SecurityPkg/Library/HashInstanceLibSm3/HashInstanceLibSm3.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ Tpm2SetSm3ToDigestList (
@retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
@retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sm3HashInit (
OUT VOID **HashHandle
OUT HASH_HANDLE *HashHandle
)
{
VOID *Sm3Ctx;
Expand All @@ -56,14 +56,14 @@ Sm3HashInit (
CtxSize = Sm3GetContextSize ();
Sm3Ctx = AllocatePool (CtxSize);
if (Sm3Ctx == NULL) {
return FALSE;
return EFI_OUT_OF_RESOURCES;
}

Sm3Init (Sm3Ctx);

*HashHandle = Sm3Ctx;
*HashHandle = (HASH_HANDLE)Sm3Ctx;

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -75,17 +75,17 @@ Sm3HashInit (

@retval EFI_SUCCESS Hash sequence updated.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sm3HashUpdate (
IN VOID *HashHandle,
IN CONST VOID *DataToHash,
IN UINTN DataToHashLen
IN HASH_HANDLE HashHandle,
IN VOID *DataToHash,
IN UINTN DataToHashLen
)
{
Sm3Update (HashHandle, DataToHash, DataToHashLen);
Sm3Update ((VOID *)HashHandle, DataToHash, DataToHashLen);

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -96,22 +96,22 @@ Sm3HashUpdate (

@retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
**/
BOOLEAN
EFI_STATUS
EFIAPI
Sm3HashFinal (
IN VOID *HashHandle,
IN HASH_HANDLE HashHandle,
OUT TPML_DIGEST_VALUES *DigestList
)
{
UINT8 Digest[SM3_256_DIGEST_SIZE];

Sm3Final (HashHandle, Digest);
Sm3Final ((VOID *)HashHandle, Digest);

FreePool (HashHandle);
FreePool ((VOID *)HashHandle);

Tpm2SetSm3ToDigestList (DigestList, Digest);

return TRUE;
return EFI_SUCCESS;
}

HASH_INTERFACE mSm3InternalHashInstance = {
Expand Down
Loading
Loading