we (web engine): Experimental web browser project to understand the limits of Claude

SHA-2 hash functions: SHA-256, SHA-384, SHA-512 #46

open opened by pierrelf.com

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, Sha512 structs 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-crypto passes
  • cargo clippy -p we-crypto -- -D warnings clean
  • unsafe only for constant-time operations or assembly optimizations (if needed)
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgems4v4sa2k