Skip to content

chore: audit implementation coverage and fix ECDH deriveBits#910

Merged
boorad merged 2 commits into
mainfrom
chore/impl-audit
Feb 10, 2026
Merged

chore: audit implementation coverage and fix ECDH deriveBits#910
boorad merged 2 commits into
mainfrom
chore/impl-audit

Conversation

@boorad
Copy link
Copy Markdown
Collaborator

@boorad boorad commented Feb 10, 2026

Summary

Audits implementation-coverage.md and docs/data/coverage.ts against the actual codebase, correcting 10+ items that were marked as missing but are actually implemented. Also fixes ECDH subtle.deriveBits() which was broken for P-256/P-384/P-521, and adds new test cases.

Coverage Audit

Found and corrected status for:

  • crypto.diffieHellman(options) — fully implemented in ed.ts
  • subtle.deriveBits ECDH — ecDeriveBits() exists
  • subtle.generateKey X25519, X448, AES-KW, ChaCha20-Poly1305
  • subtle.exportKey Ed25519/Ed448 raw, ChaCha20-Poly1305 jwk/raw
  • subtle.importKey ChaCha20-Poly1305 jwk/raw
  • coverage.ts: createDiffieHellman, getDiffieHellman, createECDH

Adds a quick-wins plan for follow-on work (crypto.hash oneshot, subtle.deriveKey ECDH, getCurves, Ed25519 JWK, etc).

ECDH deriveBits Fix

All 6 ECDH deriveBits tests were failing with "PrivateKey export for jwk is not implemented":

  • ecDeriveBits was calling keyObject.export({ format: 'jwk' }) which throws at the TS layer
  • Changed to use handle.exportJwk() directly (the C++ impl is complete, matching the pattern in subtle.ts)
  • Also fixed passing WebCrypto curve name (P-256) vs OpenSSL alias (prime256v1) to the ECDH constructor

Other Changes

  • Add public property to SubtleAlgorithm type, removing unsafe casts in ecDeriveBits and xDeriveBits
  • Add ECDH deriveBits tests (P-256, P-384, P-521 with symmetry checks)
  • Add EC JWK and raw format import/export tests

Testing

Run the subtle.deriveBits test suite in the example app — all ECDH tests should now pass.

Closes #907

Update implementation-coverage.md and docs/data/coverage.ts to reflect
actual implementation status. Found 10+ items marked as missing that are
actually implemented:

- crypto.diffieHellman(options) — fully implemented in ed.ts
- subtle.deriveBits ECDH — ecDeriveBits() exists
- subtle.generateKey X25519, X448, AES-KW, ChaCha20-Poly1305
- subtle.exportKey Ed25519/Ed448 raw, ChaCha20-Poly1305 jwk/raw
- subtle.importKey ChaCha20-Poly1305 jwk/raw
- coverage.ts: createDiffieHellman, getDiffieHellman, createECDH

Also adds quick-wins plan for follow-on work (crypto.hash oneshot,
subtle.deriveKey ECDH, getCurves, Ed25519 JWK, etc).
ecDeriveBits was calling keyObject.export({ format: 'jwk' }) which throws
at the TypeScript layer since JWK export isn't wired through the export()
method. The C++ exportJwk() on the native handle works fine — use it
directly, matching the pattern already used in subtle.ts exportKeyJWK.

Also adds 'public' property to SubtleAlgorithm type to remove casting,
applies the same cleanup in ed.ts xDeriveBits, and adds ECDH deriveBits
and import/export test cases.
@boorad boorad self-assigned this Feb 10, 2026
@boorad boorad changed the title fix: ECDH deriveBits and implementation audit fixes chore: audit implementation coverage and fix ECDH deriveBits Feb 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 10, 2026

🤖 End-to-End Test Results - Android

Status: ✅ Passed
Platform: Android
Run: 21852405581

📸 Final Test Screenshot

Maestro Test Results - android

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 End-to-End Test Results - iOS

Status: ✅ Passed
Platform: iOS
Run: 21852405577

📸 Final Test Screenshot

Maestro Test Results - ios

Screenshot automatically captured from End-to-End tests and will expire in 30 days


This comment is automatically updated on each test run.

@boorad boorad merged commit 90d0f4d into main Feb 10, 2026
4 of 5 checks passed
@boorad boorad deleted the chore/impl-audit branch February 10, 2026 05:35
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.

Audit implementation-coverage.md against actual implementation status

1 participant