12#define PARALLELHASH_CUSTOMIZATION "ParallelHash"
18UINTN mBlockResultSize;
19UINT8 *mBlockHashResult;
20BOOLEAN *mBlockIsCompleted;
33 IN VOID *ProcedureArgument
39 for (Index = 0; Index < mBlockNum; Index++) {
44 if (mBlockIsCompleted[Index]) {
53 mInput + Index * mBlockSize,
54 (Index == (mBlockNum - 1)) ? mLastBlockSize : mBlockSize,
60 mBlockHashResult + Index * mBlockResultSize
62 if (!EFI_ERROR (Status)) {
63 mBlockIsCompleted[Index] =
TRUE;
100 UINT8 EncBufB[
sizeof (
UINTN)+1];
102 UINT8 EncBufN[
sizeof (
UINTN)+1];
104 UINT8 EncBufL[
sizeof (
UINTN)+1];
107 UINT8 *CombinedInput;
108 UINTN CombinedInputSize;
109 BOOLEAN AllCompleted;
113 if ((InputByteLen == 0) || (OutputByteLen == 0) || (BlockSize == 0)) {
121 if ((CustomByteLen != 0) && (Customization ==
NULL)) {
125 mBlockSize = BlockSize;
130 mBlockNum = InputByteLen % mBlockSize == 0 ? InputByteLen / mBlockSize : InputByteLen / mBlockSize + 1;
135 mBlockResultSize = OutputByteLen;
142 EncSizeL =
RightEncode (EncBufL, OutputByteLen * CHAR_BIT);
147 CombinedInputSize = EncSizeB + EncSizeN + EncSizeL + mBlockNum * mBlockResultSize;
151 if ((CombinedInput ==
NULL) || (mBlockIsCompleted ==
NULL) || (mSpinLockList ==
NULL)) {
159 CopyMem (CombinedInput, EncBufB, EncSizeB);
164 mBlockHashResult = CombinedInput + EncSizeB;
165 mInput = (UINT8 *)
Input;
166 mLastBlockSize = InputByteLen % mBlockSize == 0 ? mBlockSize : InputByteLen % mBlockSize;
171 for (Index = 0; Index < mBlockNum; Index++) {
185 for (Index = 0; Index < mBlockNum; Index++) {
187 if (!mBlockIsCompleted[Index]) {
188 AllCompleted =
FALSE;
190 mInput + Index * mBlockSize,
191 (Index == (mBlockNum - 1)) ? mLastBlockSize : mBlockSize,
197 mBlockHashResult + Index * mBlockResultSize
200 mBlockIsCompleted[Index] =
TRUE;
209 AllCompleted =
FALSE;
213 }
while (!AllCompleted);
218 Offset = EncSizeB + mBlockNum * mBlockResultSize;
219 CopyMem (CombinedInput + Offset, EncBufN, EncSizeN);
225 CopyMem (CombinedInput + Offset, EncBufL, EncSizeL);
231 PARALLELHASH_CUSTOMIZATION,
239 ZeroMem (CombinedInput, CombinedInputSize);
241 if (CombinedInput !=
NULL) {
245 if (mSpinLockList !=
NULL) {
249 if (mBlockIsCompleted !=
NULL) {
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI CShake256HashAll(IN CONST VOID *Data, IN UINTN DataSize, IN UINTN OutputLen, IN CONST VOID *Name, IN UINTN NameLen, IN CONST VOID *Customization, IN UINTN CustomizationLen, OUT UINT8 *HashValue)
VOID EFIAPI DispatchBlockToAp(VOID)
BOOLEAN EFIAPI ParallelHash256HashAll(IN CONST VOID *Input, IN UINTN InputByteLen, IN UINTN BlockSize, OUT VOID *Output, IN UINTN OutputByteLen, IN CONST VOID *Customization, IN UINTN CustomByteLen)
VOID EFIAPI ParallelHashApExecute(IN VOID *ProcedureArgument)
UINTN EFIAPI RightEncode(OUT UINT8 *EncBuf, IN UINTN Value)
UINTN EFIAPI LeftEncode(OUT UINT8 *EncBuf, IN UINTN Value)
VOID EFIAPI Input(IN CHAR16 *Prompt OPTIONAL, OUT CHAR16 *InStr, IN UINTN StrLen)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
SPIN_LOCK *EFIAPI InitializeSpinLock(OUT SPIN_LOCK *SpinLock)
SPIN_LOCK *EFIAPI ReleaseSpinLock(IN OUT SPIN_LOCK *SpinLock)
BOOLEAN EFIAPI AcquireSpinLockOrFail(IN OUT SPIN_LOCK *SpinLock)
VOID EFIAPI Exit(IN EFI_STATUS Status)