Expose XOFs like SHAKE128 and SHAKE256
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 领域
- cryptography
调研方向
首先跟踪 EVP_MD_CTX_size 附近的 OpenSSL::Digest 处理以及 digest 方法,然后检查 EVP_DigestSqueeze 如何适配提议的 API。确认 SHAKE128 和 SHAKE256 的预期行为,包括 digest(length);完成的标准是可变长度输出能够正常工作,同时不破坏固定长度 digest,并且有测试覆盖。
由索引模型根据 Issue 内容生成。
描述
SHAKE is a XOF from the Keccak family of algorithms. Loosely, you can consider them a digest. The thing that sets them apart though is that they have no fixed output size, instead callers indicate "How much data do you want from it?" The 128 and 256 are secure strengths, not output sizes like SHA-2-256.
Even though SHAKE is an EVP-MD, the ruby/openssl project assumes that all digests have a fixed length output.
digest = OpenSSL::Digest.new("SHAKE256") # Works
digest << "hello world" # Works
digest.digest # Fail: ArgumentError: negative string size (or size too big)
Largely because the gem is attempting to ask the EVP_MD how big the digest is using EVP_MD_CTX_size, which returns -1, which is where the ArgumentError comes from.
A small suggestion would be to recognize that when EVP_MD_CTX_size return -1, a length must be supplied to digest
digest = OpenSSL::Digest.new("SHAKE256")
digest << "hello world"
digest.digest(64)
This will allow using the SHAKE XOF.
As a further property of XOFs is "squeeze", exposed by OpenSSL's EVP_DigestSqueeze.
One could imagine doing something like
digest = OpenSSL::Digest.new("SHAKE256")
digest << "hello world"
digest.squeeze(32) + digest.squeeze(32) # Equivalent to digest(64)
Squeeze allows someone to "read" from the XOF in pieces, instead of reading it all out at at once with digest.
Why is this useful?
SHAKE-256 is used to compute the message representative, or mu, when using ML-DSA in external mu. Ruby's ML-DSA does support signing mu instead of the message, but the lack of SHAKE makes it difficult to compute mu. For example, using a made-up mu:
key = OpenSSL::PKey.generate_key("ML-DSA-65")
mu = "\x00" * 64 # This should actually be computed with SHAKE-256
signature = key.sign(nil, mu, "mu" => "1")
Because SHAKE-256 can absorb very large amounts of data, it works like signing a hash with combined with external mu. This is how you can sign very large amounts of data, like a file, without putting the whole file in memory.
This is distinct, and different than HashML-DSA which has largely failed to gain traction in many other standards, and instead recommend using external-mu.
For the purposes of external mu, the digest.squeeze functionality is not needed with EVP_DigestSqueeze, but having some means digest(64) is needed.
I will offer my time to contribute the work, however I would like to better understand what the maintainers would want this to look like before getting started.
- 主要语言
- C
- 星标
- 276
- 派生
- 201
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/openssl 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
Unchecked *_set_* calls可能已有人在做 @ndossche 于 166 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
Add a method OpenSSL::PKey#size可能已有人在做 @herwinw 于 292 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
docs: AGENTS.md has no rule against running deploy scripts into the owner's game install可能已有人在做 @thesprockee 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
EchoTools/nevr-runtime#524 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 74/100
Genymobile/scrcpy#7097 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
-
type: feature
难度 1/5 1 小时以内 新手友好度 77/100
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复