You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow shake128/256 to produce outputs of unlimited length #54406
SHAKE128 is essentially a hash algorithm that can output an infinite-length stream. Rather than being just a hash algorithm, it's more like a stream cipher such as RC4. Support for SHAKE128/256 is currently available, but the implementation requires specifying an outputSize in advance, which is fixed and limited. This doesn't meet my needs, so I have to rely on third-party libraries.
What is the feature you are proposing to solve the problem?
Support for SHAKE was first introduced in 2019, but I believe this support is incomplete.
Allowing the digest method to be called multiple times in certain situations could be an option, such as adding a {streamMode: true} option. This approach seems clunky, but it could solve the problem.
Alternatively, a new method like digestAsStream(length: number) could be added. This method would represent a streaming hash, with the length parameter specifying the desired output length. It could be called an unlimited number of times.
I don't think there's much we can do here until EVP_DigestSqueeze() becomes available in the OpenSSL version that we are linking against, which might take a while.
I'm actually writing a Node.js version of the Xray-core library, which is an encryption proxy tool. Living in mainland China, it's an important tool for me. The library is poorly written; it implements a proxy protocol called VMess. In one part, it uses SHAKE128 to generate an infinite byte stream and XORs this stream with plaintext data to transmit over the network. This is definitely a misuse, as it incorrectly applies a hash algorithm as a stream cipher. However, I'm just replicating the existing protocol and need to find a function that supports this usage.
This is definitely a misuse, as it incorrectly applies a hash algorithm as a stream cipher.
Side note: it's not an approved usage of an XOF, but it's not known to be vulnerable in Keccak's sponge construction either. It even was suggested in the 2011 paper on sponge function but has not been approved so far. In many ways, SHAKE is not a hash function but rather an XOF.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
Activity
tianxiadys commentedon Aug 16, 2024
Allowing the
digestmethod to be called multiple times in certain situations could be an option, such as adding a{streamMode: true}option. This approach seems clunky, but it could solve the problem.tianxiadys commentedon Aug 16, 2024
Alternatively, a new method like
digestAsStream(length: number)could be added. This method would represent a streaming hash, with thelengthparameter specifying the desired output length. It could be called an unlimited number of times.avivkeller commentedon Aug 16, 2024
Hi! Could you provide some example code of what it is that you are looking for?
tniessen commentedon Aug 17, 2024
I don't think there's much we can do here until
EVP_DigestSqueeze()becomes available in the OpenSSL version that we are linking against, which might take a while.tianxiadys commentedon Aug 17, 2024
I'm actually writing a Node.js version of the Xray-core library, which is an encryption proxy tool. Living in mainland China, it's an important tool for me. The library is poorly written; it implements a proxy protocol called VMess. In one part, it uses SHAKE128 to generate an infinite byte stream and XORs this stream with plaintext data to transmit over the network. This is definitely a misuse, as it incorrectly applies a hash algorithm as a stream cipher. However, I'm just replicating the existing protocol and need to find a function that supports this usage.
This is a quote from the original code.
https://github.com/XTLS/Xray-core/blob/main/proxy/vmess/encoding/auth.go
tniessen commentedon Aug 17, 2024
Side note: it's not an approved usage of an XOF, but it's not known to be vulnerable in Keccak's sponge construction either. It even was suggested in the 2011 paper on sponge function but has not been approved so far. In many ways, SHAKE is not a hash function but rather an XOF.
github-actions commentedon Feb 14, 2025
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-staleIssues and PRs exempt from automated stale handling.
label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.