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: isolate cipher job errors
Use only errors captured by the cipher job when converting its result.
Unrelated errors on the event loop thread must not turn a successful
operation into a failure or trigger an assertion.

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 0e286f02553e077eba5f9686079b01f804329ae8

There are no files selected for viewing

7 changes: 2 additions & 5 deletions 7 src/crypto/crypto_cipher.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class CipherJob final : public CryptoJob<CipherTraits> {
WebCryptoCipherMode cipher_mode() const { return cipher_mode_; }

void DoThreadPoolWork() override {
ncrypto::ClearErrorOnReturn clear_error_on_return;
const WebCryptoCipherStatus status =
CipherTraits::DoCipher(
AsyncWrap::env(),
Expand Down Expand Up @@ -253,11 +254,7 @@ class CipherJob final : public CryptoJob<CipherTraits> {
Environment* env = AsyncWrap::env();
CryptoErrorStore* errors = CryptoJob<CipherTraits>::errors();

if (errors->Empty())
errors->Capture();

if (out_.size() > 0 || errors->Empty()) {
CHECK(errors->Empty());
if (errors->Empty()) {
*err = v8::Undefined(env->isolate());
*result = out_.ToArrayBuffer(env);
if (result->IsEmpty()) {
Expand Down
45 changes: 45 additions & 0 deletions 45 test/parallel/test-webcrypto-cipher-unrelated-errors.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const { scrypt, scryptSync } = require('crypto');
const { subtle } = globalThis.crypto;

if (typeof scryptSync !== 'function')
common.skip('no scrypt support');

function failScrypt(sync) {
// The failed parameter check leaves an error on the main thread's
// OpenSSL error queue. Cipher jobs must only use their own errors.
assert.throws(() => {
if (sync) {
scryptSync('password', 'salt', 64, { N: 2 ** 17 });
} else {
scrypt('password', 'salt', 64, { N: 2 ** 17 }, common.mustNotCall());
}
}, { code: 'ERR_CRYPTO_INVALID_SCRYPT_PARAMS' });
}

(async () => {
const key = await subtle.importKey(
'raw', new Uint8Array(16), 'AES-GCM', false, ['encrypt', 'decrypt']);
const algorithm = { name: 'AES-GCM', iv: new Uint8Array(12) };

for (const sync of [true, false]) {
for (const byteLength of [0, 16]) {
const plaintext = new Uint8Array(byteLength);
failScrypt(sync);
const ciphertext = await subtle.encrypt(algorithm, key, plaintext);
assert.strictEqual(ciphertext.byteLength, byteLength + 16);

failScrypt(sync);
assert.deepStrictEqual(
new Uint8Array(await subtle.decrypt(algorithm, key, ciphertext)),
plaintext);
}
}
})().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.