Skip to content

[codex] add crypto Hash and Hmac stream methods#4138

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-crypto-hash-hmac-streams
Jun 2, 2026
Merged

[codex] add crypto Hash and Hmac stream methods#4138
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-crypto-hash-hmac-streams

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Fixes #2479 for the first Hash/Hmac stream-method slice.

Summary

  • Expose stream-style methods on crypto.createHash() / Hash and crypto.createHmac() / Hmac: write, end, on/once/addListener, pipe, and setEncoding.
  • Queue final digest data, then end/finish/close, through the existing stdlib event pump.
  • Add a narrow runtime pipe bridge so Readable.from(...).pipe(createHash(...)) and Readable.from(...).pipe(createHmac(...)) call native-handle .write() / .end().
  • Add parity fixtures for direct writable use, inbound Readable.pipe(), and outbound hash.pipe(PassThrough) digest forwarding.

Non-goals in this PR

  • Cipher/Decipher transform streams.
  • Sign/Verify writable-stream behavior.
  • Full Node stream inheritance, backpressure, and exact lifecycle/error edge cases beyond this first Hash/Hmac digest-stream surface.

Tests

  • Baseline before implementation: NODE25_DIR=$(dirname "$(npx -y node@25 -p 'process.execPath')"); PATH="$NODE25_DIR:$PATH" PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module crypto --filter stream-methods failed because hash.write / hmac.write were undefined (parity_report_20260602_171358.json).
  • cargo check -p perry-runtime -p perry-stdlib -p perry-api-manifest
  • NODE25_DIR=$(dirname "$(npx -y node@25 -p 'process.execPath')"); PATH="$NODE25_DIR:$PATH" PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module crypto --filter stream-methods -> 2 pass, 0 fail (parity_report_20260602_173748.json)
  • NODE25_DIR=$(dirname "$(npx -y node@25 -p 'process.execPath')"); PATH="$NODE25_DIR:$PATH" PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module crypto --filter hmac -> 19 pass, 0 fail (parity_report_20260602_173816.json)
  • NODE25_DIR=$(dirname "$(npx -y node@25 -p 'process.execPath')"); PATH="$NODE25_DIR:$PATH" PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module crypto --filter hash -> 15 pass, 1 existing unrelated node-suite/crypto/hash/unicode-input mismatch (parity_report_20260602_173918.json)
  • NODE25_DIR=$(dirname "$(npx -y node@25 -p 'process.execPath')"); PATH="$NODE25_DIR:$PATH" PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module zlib --filter streams -> 4 pass, 0 fail (parity_report_20260602_174013.json)
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh

@proggeramlug proggeramlug marked this pull request as ready for review June 2, 2026 18:56
@proggeramlug proggeramlug merged commit ed9f6b4 into PerryTS:main Jun 2, 2026
11 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.

node:crypto: implement stream-backed crypto transform semantics

2 participants