add blake2b and argon2id password hashing primitives to the runtime - #629
Merged
Conversation
blake2b follows rfc 7693 (keyed and unkeyed, digests up to 64 bytes) and is pinned by the rfc appendix vector plus official kat values. argon2id follows rfc 9106; the core supports all three variants so the rfc's argon2d, argon2i, and argon2id vectors can each pin the indexing logic, but only argon2id is meant for use. the memory cost is capped at 1 GiB and allocation failures return an error instead of aborting.
crypto_blake2b and crypto_argon2id follow the existing crypto entries: bytes handles in, a bytes handle out, and 0 on any invalid input. the checker-side declarations that make these callable from pith land separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
cranelift/runtime/src/blake2b.rs: keyed and unkeyed, digest lengths 1 to 64 bytes, incremental state plus a one-shot helpercranelift/runtime/src/argon2.rs: the full memory-filling function with configurable time cost, memory cost, parallelism, salt, and output length. no new crate dependencies — ring offers neither primitive, and argon2id is defined in terms of blake2btry_reserve_exact, returning an error instead of taking down the process on an oversized valuecrypto_blake2bandcrypto_argon2id, following the existing crypto entries: bytes handles in, a bytes handle out, 0 on any invalid inputthis is the primitive layer for a
std.crypto.passwordmodule. making the two entries callable from pith needs builtin declarations in the self-hosted checker plus a bootstrap seed refresh, so that wiring is left for a follow-up rather than colliding with the seed change already in review.what was tested
cargo test --release --workspace --locked: all suites greenmake testgreen (289/289 regressions), regression corpus also green underPITH_GREEN=0notes
the memory fill is single-threaded.
lanesstill changes the output exactly as the rfc requires; it just does not fan out across os threads. that keeps the code simple, and on this class of host the owasp-recommended parameters (19 MiB, t=2, p=1) land around 45 ms per hash, which is where the std module's defaults should sit.