Skip to content

crypto: improve argument validation and error messages - #64852

Closed
panva wants to merge 4 commits into
nodejs:mainfrom
panva:fixes-lib
Closed

crypto: improve argument validation and error messages#64852
panva wants to merge 4 commits into
nodejs:mainfrom
panva:fixes-lib

Conversation

@panva

Copy link
Copy Markdown
Member
  • Report the correct parameter name for invalid optional inputs in parseKeyEncoding.
  • Reject null options with ERR_INVALID_ARG_TYPE in generateKeyPair(Sync).
  • Avoid a second native call when reading the issuer certificate in X509Certificate.
  • Explain that a cipher is required when a passphrase is provided in parseKeyEncoding.

panva added 4 commits July 30, 2026 22:15
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva
panva requested review from anonrig and jasnellJuly 30, 2026 20:22
@panvapanva added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Jul 30, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-botnodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Jul 30, 2026
@panvapanva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 30, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 30, 2026
@nodejs-github-bot

This comment was marked as outdated.

@codecov

codecovBot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.16%. Comparing base (e7904d4) to head (3eebfb7).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #64852 +/- ##
==========================================
+ Coverage 90.14% 90.16% +0.02% 
==========================================
Files 746 746 Lines 242764 242762 -2 Branches 45739 45761 +22 ==========================================
+ Hits 218848 218895 +47 + Misses 15426 15332 -94 - Partials 8490 8535 +45 
Files with missing linesCoverage Δ
lib/internal/crypto/argon2.js98.70% <100.00%> (ø)
lib/internal/crypto/keygen.js93.49% <100.00%> (ø)
lib/internal/crypto/keys.js97.84% <100.00%> (+<0.01%)⬆️
lib/internal/crypto/x509.js91.70% <100.00%> (ø)

... and 49 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panvapanva added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 1, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 1, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in f9e21ae...276fe2b

nodejs-github-bot pushed a commit that referenced this pull request Aug 1, 2026
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
nodejs-github-bot pushed a commit that referenced this pull request Aug 1, 2026
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
nodejs-github-bot pushed a commit that referenced this pull request Aug 1, 2026
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
nodejs-github-bot pushed a commit that referenced this pull request Aug 1, 2026
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@panva
panva deleted the fixes-lib branch August 1, 2026 20:40
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 5, 2026
Report the correct parameter name for invalid optional inputs.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 5, 2026
Reject null options with ERR_INVALID_ARG_TYPE.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 5, 2026
Avoid a second native call when reading the issuer certificate.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 5, 2026
Explain that a cipher is required when a passphrase is provided.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.cryptoIssues and PRs related to the crypto subsystem.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@panva@nodejs-github-bot@jasnell@anonrig