Phase 5: Pure Rust Crypto#
Implement the SHA-2 family of cryptographic hash functions in the crypto crate per FIPS 180-4.
Requirements#
- SHA-256: 256-bit digest, 64-byte block size
- SHA-384: 384-bit digest, 128-byte block size (truncated SHA-512)
- SHA-512: 512-bit digest, 128-byte block size
- Streaming API:
new(),update(&[u8]),finalize() -> [u8; N] - One-shot convenience:
sha256(data) -> [u8; 32], etc. - Message padding per FIPS 180-4 ยง5.1
- Correct round constants and initial hash values
Acceptance Criteria#
-
Sha256,Sha384,Sha512structs with streaming and one-shot APIs - Pass NIST test vectors (empty string, "abc", 448-bit message, 896-bit message)
- Pass long message test vectors (1 million "a" characters)
-
cargo test -p we-cryptopasses -
cargo clippy -p we-crypto -- -D warningsclean -
unsafeonly for constant-time operations or assembly optimizations (if needed)