TianoCore EDK2 master
Loading...
Searching...
No Matches
HashInstanceLibSha384.c
Go to the documentation of this file.
1
10#include <PiPei.h>
11
12#include <Library/BaseLib.h>
14#include <Library/DebugLib.h>
17#include <Library/HashLib.h>
18
25VOID
27 IN TPML_DIGEST_VALUES *DigestList,
28 IN UINT8 *Sha384Digest
29 )
30{
31 DigestList->count = 1;
32 DigestList->digests[0].hashAlg = TPM_ALG_SHA384;
33 CopyMem (
34 DigestList->digests[0].digest.sha384,
35 Sha384Digest,
37 );
38}
39
49EFIAPI
51 OUT HASH_HANDLE *HashHandle
52 )
53{
54 VOID *Sha384Ctx;
55 UINTN CtxSize;
56
57 CtxSize = Sha384GetContextSize ();
58 Sha384Ctx = AllocatePool (CtxSize);
59 ASSERT (Sha384Ctx != NULL);
60
61 Sha384Init (Sha384Ctx);
62
63 *HashHandle = (HASH_HANDLE)Sha384Ctx;
64
65 return EFI_SUCCESS;
66}
67
78EFIAPI
80 IN HASH_HANDLE HashHandle,
81 IN VOID *DataToHash,
82 IN UINTN DataToHashLen
83 )
84{
85 VOID *Sha384Ctx;
86
87 Sha384Ctx = (VOID *)HashHandle;
88 Sha384Update (Sha384Ctx, DataToHash, DataToHashLen);
89
90 return EFI_SUCCESS;
91}
92
102EFIAPI
104 IN HASH_HANDLE HashHandle,
105 OUT TPML_DIGEST_VALUES *DigestList
106 )
107{
108 UINT8 Digest[SHA384_DIGEST_SIZE];
109 VOID *Sha384Ctx;
110
111 Sha384Ctx = (VOID *)HashHandle;
112 Sha384Final (Sha384Ctx, Digest);
113
114 FreePool (Sha384Ctx);
115
116 Tpm2SetSha384ToDigestList (DigestList, Digest);
117
118 return EFI_SUCCESS;
119}
120
121HASH_INTERFACE mSha384InternalHashInstance = {
122 HASH_ALGORITHM_SHA384_GUID,
126};
127
134EFIAPI
136 VOID
137 )
138{
139 EFI_STATUS Status;
140
141 Status = RegisterHashInterfaceLib (&mSha384InternalHashInstance);
142 if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
143 //
144 // Unsupported means platform policy does not need this instance enabled.
145 //
146 return EFI_SUCCESS;
147 }
148
149 return Status;
150}
UINT64 UINTN
UINTN EFIAPI Sha384GetContextSize(VOID)
Definition: CryptSha512.c:20
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:115
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:163
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
Definition: CryptSha512.c:44
#define SHA384_DIGEST_SIZE
Definition: BaseCryptLib.h:49
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI Sha384HashUpdate(IN HASH_HANDLE HashHandle, IN VOID *DataToHash, IN UINTN DataToHashLen)
EFI_STATUS EFIAPI Sha384HashInit(OUT HASH_HANDLE *HashHandle)
EFI_STATUS EFIAPI HashInstanceLibSha384Constructor(VOID)
VOID Tpm2SetSha384ToDigestList(IN TPML_DIGEST_VALUES *DigestList, IN UINT8 *Sha384Digest)
EFI_STATUS EFIAPI Sha384HashFinal(IN HASH_HANDLE HashHandle, OUT TPML_DIGEST_VALUES *DigestList)
EFI_STATUS EFIAPI RegisterHashInterfaceLib(IN HASH_INTERFACE *HashInterface)
Definition: HashLibTdx.c:185
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112