Registry Mirror
Skip to content

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

crypto.generateKeySync("aes"|"hmac", { length }) was rejected by the #463 unimplemented-API gate, even though everything behind it was already in place: the runtime (js_crypto_generate_key_sync), the codegen dispatch (expr/calls.rs), and the AES-192/256 KeyObject metadata (fixed by #3930). It was simply missing from the API manifest, so the HIR gate rejected the call before codegen ran. (Confirmed: with PERRY_ALLOW_UNIMPLEMENTED=1 the fixture already matched Node byte-for-byte.)

Fix

  • Added method("crypto", "generateKeySync", …) to the manifest so the dotted-form crypto.generateKeySync(...) passes the gate and reaches its dispatch.
  • Added a named-import lowering arm in expr_call/globals.rs (mirroring the existing createSecretKey arm) so the bare import { generateKeySync } from "node:crypto"; generateKeySync(...) shape rewrites to the dotted form too. (A first attempt via crypto.rs's is_crypto_method list broke the member form — generateKeySync is codegen-dispatched, not runtime-(module,method)-dispatched — so this is the correct spot.)

Testing

Flips node-suite/crypto/secret-key/generate-key-sync to green (AES-128/192/256 metadata + jwk export + hmac all match node --experimental-strip-types); the bare named-import form returns the key too. perry-api-manifest + perry-hir suites green; cargo fmt --check clean; API docs regenerated. The remaining node:crypto node-suite fails (cipher invalid-state #3873, fips-api, prime) are unrelated/pre-existing.

Closes #3927

Ralph Küpper added 2 commits June 1, 2026 18:00
The runtime (js_crypto_generate_key_sync) and codegen dispatch (expr/calls.rs)
were already complete, and the AES-192/256 KeyObject metadata was fixed by #3930
— but generateKeySync was missing from the API manifest, so the #463
unimplemented-API gate rejected crypto.generateKeySync(...) before codegen ran.
Added the manifest method row + a named-import lowering arm (mirroring
createSecretKey) so the bare import { generateKeySync } call shape also reaches
the dispatch. Flips node-suite/crypto/secret-key/generate-key-sync to green
(AES-128/192/256 + hmac all match Node). Remaining crypto fails (cipher state
@proggeramlug
proggeramlug merged commit 5ca70f1 into main Jun 1, 2026
@proggeramlug
proggeramlug deleted the cycle8 branch June 1, 2026 16:03
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: generateKeySync("aes") returns malformed KeyObject metadata for 192/256-bit keys

1 participant