feat(crypto): KDF primitives (HKDF-SHA256, Argon2id)#1298
Merged
Conversation
3a70e32 to
ba0a137
Compare
…-crypto-hashing Add key derivation functions to the hashing crate, filling a gap in the crypto primitives ecosystem. Blueprint authors currently resort to raw hashing (Keccak256, SHA256) for key derivation, which lacks domain separation and is unsuitable for low-entropy inputs. New functions: - `hkdf_sha256<N>(ikm, salt, info)` — RFC 5869 HKDF for high-entropy secrets (DH shared secrets, random keys). Generic over output length. - `argon2id_derive<N>(password, salt)` — RFC 9106 Argon2id for passwords and low-entropy secrets. OWASP-recommended parameters (19 MiB, t=2, p=1). Both are feature-gated (`kdf-hkdf`, `kdf-argon2`) and included in the default `hashing` feature. Accessible via `blueprint_sdk::crypto::hashing::kdf::*`. Includes RFC 5869 test vector validation and property tests.
ba0a137 to
3e250e9
Compare
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
kdfmodule toblueprint-crypto-hashingwith two key derivation functionshkdf_sha256(RFC 5869): For deriving keys from high-entropy secrets (DH shared secrets, random tokens). ReturnsResultwith typed error.argon2id_derive/argon2id_derive_with(RFC 9106): For deriving keys from passwords/low-entropy secrets. Configurable params viaArgon2idConfig(defaults to OWASP-recommended minimums).kdf-hkdfandkdf-argon2, included in the defaulthashingfeatureblueprint_sdk::crypto::hashing::kdf::*Motivation
Blueprint authors currently use raw hashing (Keccak256, SHA256) for key derivation, which lacks domain separation and is unsuitable for low-entropy inputs. This came up while hardening session auth in the sandbox blueprint — the PASETO symmetric key was derived via
keccak256(secret)which is a common anti-pattern.Test plan
cargo test -p blueprint-crypto-hashing— 9 KDF tests pass (including RFC 5869 Test Case 1)cargo check -p blueprint-crypto— metapackage compiles with new features