Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! crypto: read WebCrypto inputs through primordials
  • Loading branch information
panva committed Aug 7, 2026
commit e0ce1358a90d7706ae72ad510c61a7a5cd6a2af8
33 changes: 18 additions & 15 deletions test/parallel/test-webcrypto-prototype-pollution.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if (!common.hasCrypto) common.skip('missing crypto');
const require = createRequire(import.meta.url);
const { kSupportedAlgorithms } = require('internal/crypto/util');
const { getFips } = require('node:crypto');
const { hasOpenSSL } = require('../common/crypto');
const { subtle } = globalThis.crypto;

const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
Expand Down Expand Up @@ -135,21 +136,23 @@ if (supports('digest', 'cSHAKE128')) {

// asyncDigest() picks the cSHAKE job over plain SHAKE on a non-empty
// customization.
const algorithm = {
name: 'cSHAKE128',
outputLength: 256,
customization: new Uint8Array([1, 2, 3]),
};
const expected = new Uint8Array(await subtle.digest(algorithm, data));
const plain = new Uint8Array(
await subtle.digest({ name: 'cSHAKE128', outputLength: 256 }, data));
assert.notDeepStrictEqual(expected, plain);
await withPoisoned(poisonTypedArrayByteLength(0),
common.mustCall(async () => {
assert.deepStrictEqual(
new Uint8Array(await subtle.digest(algorithm, data)),
expected);
}));
if (hasOpenSSL(3)) {
const algorithm = {
name: 'cSHAKE128',
outputLength: 256,
customization: new Uint8Array([1, 2, 3]),
};
const expected = new Uint8Array(await subtle.digest(algorithm, data));
const plain = new Uint8Array(
await subtle.digest({ name: 'cSHAKE128', outputLength: 256 }, data));
assert.notDeepStrictEqual(expected, plain);
await withPoisoned(poisonTypedArrayByteLength(0),
common.mustCall(async () => {
assert.deepStrictEqual(
new Uint8Array(await subtle.digest(algorithm, data)),
expected);
}));
}
}

// AeadParams: AES-OCB caps the iv at 15 bytes.
Expand Down
Loading