38 if (BlockSize <=
sizeof (Context->buf)) {
39 memset (Context->A, 0, sizeof (Context->A));
42 Context->block_size = BlockSize;
43 Context->md_size = MessageDigestLen;
72 const UINT8 *DataCopy;
78 BlockSize = (UINT8)(Context->block_size);
84 if ((Num = Context->num) != 0) {
88 Rem = BlockSize - Num;
91 memcpy (Context->buf + Num, DataCopy, DataSize);
92 Context->num += DataSize;
101 memcpy (Context->buf + Num, DataCopy, Rem);
104 (void)
SHA3_absorb (Context->A, Context->buf, BlockSize, BlockSize);
109 if (DataSize >= BlockSize) {
110 Rem =
SHA3_absorb (Context->A, DataCopy, DataSize, BlockSize);
116 memcpy (Context->buf, DataCopy + DataSize - Rem, Rem);
139 OUT UINT8 *MessageDigest
145 BlockSize = Context->block_size;
148 if (Context->md_size == 0) {
157 memset (Context->buf + Num, 0, BlockSize - Num);
158 Context->buf[Num] = Context->pad;
159 Context->buf[BlockSize - 1] |= 0x80;
161 (void)
SHA3_absorb (Context->A, Context->buf, BlockSize, BlockSize);
163 SHA3_squeeze (Context->A, MessageDigest, Context->md_size, BlockSize);
void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r)
size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, size_t r)
UINT8 EFIAPI KeccakInit(OUT Keccak1600_Ctx *Context, IN UINT8 Pad, IN UINTN BlockSize, IN UINTN MessageDigestLen)
UINT8 EFIAPI Sha3Final(IN OUT Keccak1600_Ctx *Context, OUT UINT8 *MessageDigest)
UINT8 EFIAPI Sha3Update(IN OUT Keccak1600_Ctx *Context, IN const VOID *Data, IN UINTN DataSize)