GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: fix various edge cases by panva · Pull Request #66237 · nodejs/node

crypto: fix various edge cases #66237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
panva wants to merge 29 commits into nodejs:main from panva:webcrypto-findings
+2,129 −1,167
Closed

crypto: fix various edge cases #66237

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f82a804
crypto: use internal random buffer bounds
panva Sep 22, 2026
1cbd118
crypto: match algorithm names as ASCII
panva Sep 22, 2026
131cc41
crypto: reject short AES-KW inputs
panva Sep 22, 2026
0e286f0
crypto: isolate cipher job errors
panva Sep 22, 2026
5d64d76
crypto: convert getRandomValues views
panva Sep 22, 2026
bd27c23
crypto: validate normalized hash names
panva Sep 22, 2026
7129683
crypto: allow short AES-GCM IVs
panva Sep 22, 2026
3d8975b
crypto: allow unbound SubtleCrypto.supports
panva Sep 22, 2026
7f417a0
crypto: resolve supports overloads by type
panva Sep 22, 2026
9b6c75e
crypto: copy detached parameters as empty
panva Sep 22, 2026
a45414a
crypto: convert importKey data as a union
panva Sep 22, 2026
677404d
crypto: copy parameters without array species
panva Sep 22, 2026
4f7f16f
crypto: check RSA JWK alg with SHA-3 hashes
panva Sep 22, 2026
191d52a
crypto: reject duplicate unknown key usages
panva Sep 22, 2026
2ae6b20
crypto: handle PBKDF2 iteration limits
panva Sep 22, 2026
e937421
crypto: separate conversion from validation
panva Sep 22, 2026
36bb4f6
crypto: copy derived bits without species
panva Sep 22, 2026
716fc4e
crypto: minimize RSA public exponent metadata
panva Sep 22, 2026
02d6adf
crypto: create key usage arrays without species
panva Sep 22, 2026
6e9984c
crypto: derive Argon2 without worker threads
panva Sep 22, 2026
baaf5fc
crypto: report actual RSA modulus lengths
panva Sep 22, 2026
ac0931c
crypto: split hybrid keys without species
panva Sep 22, 2026
a95665b
crypto: use the public CryptoKey prototype
panva Sep 22, 2026
3e45b42
crypto: include EC public keys in PKCS8 exports
panva Sep 22, 2026
1f701b0
crypto: map JWK export failures to OperationError
panva Sep 22, 2026
36d932d
crypto: check EC coordinate conversion results
panva Sep 22, 2026
4a5c46f
benchmark: cover Web Crypto conversion costs
panva Sep 23, 2026
a216416
crypto: use backend cSHAKE and KMAC
panva Sep 23, 2026
4f26a35
crypto: verify empty KMAC outputs
panva Sep 23, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: minimize RSA public exponent metadata
Omit leading zero octets from generated CryptoKey publicExponent
values, matching the BigInteger representation.

Signed-off-by: Filip Skokan <[email protected]>
Assisted-by: Codex
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@panva
panva committed Sep 24, 2026
commit 716fc4e9d14f51fb4f68edb39aecc82cb1d52c75

There are no files selected for viewing

10 changes: 9 additions & 1 deletion 10 lib/internal/crypto/rsa.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const {
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetByteOffset,
TypedArrayPrototypeGetLength,
Uint8Array,
} = primordials;

Expand Down Expand Up @@ -113,11 +115,17 @@ function rsaKeyGenerate(
const usagesSet = validateKeyUsages(usages, allowedUsages.keygen, name);
validateAlgorithm(algorithm, 'generateKey');
const publicExponentConverted = bigIntArrayToUnsignedInt(publicExponent);
let firstNonzeroByte = 0;
while (publicExponent[firstNonzeroByte] === 0)
firstNonzeroByte++;

const keyAlgorithm = {
name,
modulusLength,
publicExponent,
publicExponent: new Uint8Array(
TypedArrayPrototypeGetBuffer(publicExponent),
TypedArrayPrototypeGetByteOffset(publicExponent) + firstNonzeroByte,
TypedArrayPrototypeGetLength(publicExponent) - firstNonzeroByte),
hash,
};

Expand Down
26 changes: 26 additions & 0 deletions 26 test/parallel/test-webcrypto-rsa-exponent-length.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const { getFips } = require('crypto');
const { subtle } = globalThis.crypto;

(async () => {
const exponents = getFips() ? [[1, 0, 1]] : [[3], [1, 0, 1]];
for (const name of ['RSA-PSS', 'RSASSA-PKCS1-v1_5', 'RSA-OAEP']) {
const usages = name === 'RSA-OAEP' ? ['encrypt', 'decrypt'] : ['sign', 'verify'];
for (const exponent of exponents) {
const publicExponent = new Uint8Array([0, 0, 0, 0, ...exponent]);
const pair = await subtle.generateKey({
name, modulusLength: 2048, publicExponent, hash: 'SHA-256',
}, true, usages);
for (const key of [pair.publicKey, pair.privateKey]) {
assert.deepStrictEqual(key.algorithm.publicExponent, new Uint8Array(exponent));
}
assert.deepStrictEqual(publicExponent, new Uint8Array([0, 0, 0, 0, ...exponent]));
}
}
})().then(common.mustCall());
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.