2 ParallelHash related function and type declaration.
4 Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
7 Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
8 Licensed under the OpenSSL license (the "License"). You may not use
9 this file except in compliance with the License. You can obtain a copy
10 in the file LICENSE in the source distribution or at
11 https://www.openssl.org/source/license.html
13 Copyright 2022 The eXtended Keccak Code Package (XKCP)
14 https://github.com/XKCP/XKCP
15 Keccak, designed by Guido Bertoni, Joan Daemen, Michael Peeters and Gilles Van Assche.
16 Implementation by the designers, hereby denoted as "the implementer".
17 For more information, feedback or questions, please refer to the Keccak Team website:
19 To the extent possible under law, the implementer has waived all copyright
20 and related or neighboring rights to the source code in this file.
21 http://creativecommons.org/publicdomain/zero/1.0/
24 #include "InternalCryptLib.h"
26 #define KECCAK1600_WIDTH 1600
29 // This struct referring to m_sha3.c from opessl and modified its type name.
33 size_t block_size
; /* cached ctx->digest->block_size */
34 size_t md_size
; /* output length, variable in XOF */
35 size_t num
; /* used bytes in below buffer */
36 unsigned char buf
[KECCAK1600_WIDTH
/ 8 - 32];
41 SHA3_absorb can be called multiple times, but at each invocation
42 largest multiple of |r| out of |len| bytes are processed. Then
43 remaining amount of bytes is returned. This is done to spare caller
44 trouble of calculating the largest multiple of |r|. |r| can be viewed
45 as blocksize. It is commonly (1600 - 256*n)/8, e.g. 168, 136, 104,
46 72, but can also be (1600 - 448)/8 = 144. All this means that message
47 padding and intermediate sub-block buffering, byte- or bitwise, is
48 caller's responsibility.
53 const unsigned char *inp
,
59 SHA3_squeeze is called once at the end to generate |out| hash value
71 Encode function from XKCP.
73 Encodes the input as a byte string in a way that can be unambiguously parsed
74 from the beginning of the string by inserting the length of the byte string
75 before the byte string representation of input.
77 @param[out] EncBuf Result of left encode.
78 @param[in] Value Input of left encode.
80 @retval EncLen Size of encode result in bytes.
90 Encode function from XKCP.
92 Encodes the input as a byte string in a way that can be unambiguously parsed
93 from the end of the string by inserting the length of the byte string after
94 the byte string representation of input.
96 @param[out] EncBuf Result of right encode.
97 @param[in] Value Input of right encode.
99 @retval EncLen Size of encode result in bytes.
109 Keccak initial fuction.
111 Set up state with specified capacity.
113 @param[out] Context Pointer to the context being initialized.
114 @param[in] Pad Delimited Suffix.
115 @param[in] BlockSize Size of context block.
116 @param[in] MessageDigestLen Size of message digest in bytes.
118 @retval 1 Initialize successfully.
119 @retval 0 Fail to initialize.
124 OUT Keccak1600_Ctx
*Context
,
127 IN UINTN MessageDigstLen
133 This function performs Sha3 digest on a data buffer of the specified size.
134 It can be called multiple times to compute the digest of long or discontinuous data streams.
136 @param[in,out] Context Pointer to the Keccak context.
137 @param[in] Data Pointer to the buffer containing the data to be hashed.
138 @param[in] DataSize Size of Data buffer in bytes.
140 @retval 1 Update successfully.
145 IN OUT Keccak1600_Ctx
*Context
,
151 Completes computation of Sha3 message digest.
153 This function completes sha3 hash computation and retrieves the digest value into
154 the specified memory. After this function has been called, the keccak context cannot
157 @param[in, out] Context Pointer to the keccak context.
158 @param[out] MessageDigest Pointer to a buffer that receives the message digest.
160 @retval 1 Meaasge digest computation succeeded.
165 IN OUT Keccak1600_Ctx
*Context
,
166 OUT UINT8
*MessageDigest
170 Computes the CSHAKE-256 message digest of a input data buffer.
172 This function performs the CSHAKE-256 message digest of a given data buffer, and places
173 the digest value into the specified memory.
175 @param[in] Data Pointer to the buffer containing the data to be hashed.
176 @param[in] DataSize Size of Data buffer in bytes.
177 @param[in] OutputLen Size of output in bytes.
178 @param[in] Name Pointer to the function name string.
179 @param[in] NameLen Size of the function name in bytes.
180 @param[in] Customization Pointer to the customization string.
181 @param[in] CustomizationLen Size of the customization string in bytes.
182 @param[out] HashValue Pointer to a buffer that receives the CSHAKE-256 digest
185 @retval TRUE CSHAKE-256 digest computation succeeded.
186 @retval FALSE CSHAKE-256 digest computation failed.
187 @retval FALSE This interface is not supported.
198 IN CONST VOID
*Customization
,
199 IN UINTN CustomizationLen
,