Skip to content

Comments

feat(crypto): KDF primitives (HKDF-SHA256, Argon2id)#1298

Merged
drewstone merged 1 commit intomainfrom
feat/crypto-kdf-primitives
Feb 18, 2026
Merged

feat(crypto): KDF primitives (HKDF-SHA256, Argon2id)#1298
drewstone merged 1 commit intomainfrom
feat/crypto-kdf-primitives

Conversation

@drewstone
Copy link
Contributor

Summary

  • Add kdf module to blueprint-crypto-hashing with two key derivation functions
  • hkdf_sha256 (RFC 5869): For deriving keys from high-entropy secrets (DH shared secrets, random tokens). Returns Result with typed error.
  • argon2id_derive / argon2id_derive_with (RFC 9106): For deriving keys from passwords/low-entropy secrets. Configurable params via Argon2idConfig (defaults to OWASP-recommended minimums).
  • Feature-gated: kdf-hkdf and kdf-argon2, included in the default hashing feature
  • Accessible via blueprint_sdk::crypto::hashing::kdf::*
  • 9 tests including RFC 5869 test vector validation

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
  • Feature isolation: each KDF works independently with its own feature flag

@drewstone drewstone force-pushed the feat/crypto-kdf-primitives branch 2 times, most recently from 3a70e32 to ba0a137 Compare February 18, 2026 20:54
…-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.
@drewstone drewstone force-pushed the feat/crypto-kdf-primitives branch from ba0a137 to 3e250e9 Compare February 18, 2026 23:05
@drewstone drewstone merged commit f9326bd into main Feb 18, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant