We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a27fe21 commit 9568492Copy full SHA for 9568492
6 files changed
doc/api/webcrypto.md
@@ -2383,11 +2383,16 @@ added:
2383
added:
2384
- v25.9.0
2385
- v24.18.0
2386
+changes:
2387
+ - version: REPLACEME
2388
+ pr-url: https://github.com/nodejs/node/pull/00000
2389
+ description: Limit customization to 512 bytes.
2390
-->
2391
2392
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
2393
-The optional customization string for KangarooTwelve.
2394
+The optional customization string for KangarooTwelve. It must not exceed 512
2395
+bytes.
2396
2397
#### `kangarooTwelveParams.name`
2398
lib/internal/crypto/webidl.js
@@ -272,10 +272,6 @@ function validateCShakeFunctionName(V) {
272
'NotSupportedError');
273
}
274
275
-function validateCShakeCustomization(V) {
276
- validateMaxBufferLength(V, 'CShakeParams.customization', 512);
277
-}
278
-
279
converters.RsaPssParams = createDictionaryConverter(
280
'RsaPssParams', [
281
dictAlgorithm,
@@ -428,7 +424,7 @@ converters.CShakeParams = createDictionaryConverter(
428
424
{
429
425
key: 'customization',
430
426
converter: converters.BufferSource,
431
- validator: validateCShakeCustomization,
427
+ validator: (V, opts) => validateMaxBufferLength(V, 'CShakeParams.customization', 512),
432
},
433
],
434
]);
@@ -750,6 +746,7 @@ converters.KangarooTwelveParams = createDictionaryConverter(
750
746
751
747
752
748
749
+ validator: (V, opts) => validateMaxBufferLength(V, 'KangarooTwelveParams.customization', 512),
753
754
755
test/fixtures/webcrypto/supports-modern-algorithms.mjs
@@ -48,11 +48,15 @@ export const vectors = {
48
[false, 'KT128'],
49
[true, { name: 'KT128', outputLength: 128 }],
50
[true, { name: 'KT128', outputLength: 128, customization: Buffer.alloc(0) }],
51
+ [true, { name: 'KT128', outputLength: 128, customization: Buffer.alloc(512) }],
52
+ [false, { name: 'KT128', outputLength: 128, customization: Buffer.alloc(513) }],
53
[false, { name: 'KT128', outputLength: 0 }],
54
[false, { name: 'KT128', outputLength: 127 }],
55
[false, 'KT256'],
56
[true, { name: 'KT256', outputLength: 256 }],
57
[true, { name: 'KT256', outputLength: 256, customization: Buffer.alloc(0) }],
58
+ [true, { name: 'KT256', outputLength: 256, customization: Buffer.alloc(512) }],
59
+ [false, { name: 'KT256', outputLength: 256, customization: Buffer.alloc(513) }],
60
[false, { name: 'KT256', outputLength: 0 }],
61
[false, { name: 'KT256', outputLength: 255 }],
62
test/parallel/test-webcrypto-digest-turboshake-rfc.js
@@ -326,6 +326,15 @@ async function checkDigest(name, vectors) {
326
else
327
algorithm.domainSeparation = rest[0];
328
329
+
330
+ if (isKT && algorithm.customization?.byteLength > 512) {
331
+ await assert.rejects(subtle.digest(algorithm, input), {
332
+ name: 'OperationError',
333
+ message: 'KangarooTwelveParams.customization must be at most 512 bytes',
334
+ });
335
+ continue;
336
+ }
337
338
const result = await subtle.digest(algorithm, input);
339
assert.deepStrictEqual(
340
Buffer.from(result).toString('hex'),
test/parallel/test-webcrypto-digest-turboshake.js
@@ -155,11 +155,22 @@ async function testDigest(size, alg) {
155
156
// KT128 with customization string
157
(async () => {
158
- const digest = await subtle.digest(
159
- { name: 'KT128', outputLength: 256, customization: Buffer.from('test') },
160
- Buffer.from('hello'));
+ const digest = await subtle.digest({
+ name: 'KT128',
+ outputLength: 256,
161
+ customization: Buffer.alloc(512),
162
+ }, Buffer.from('hello'));
163
assert(digest instanceof ArrayBuffer);
164
assert.strictEqual(digest.byteLength, 32);
165
166
+ await assert.rejects(subtle.digest({
167
168
169
+ customization: Buffer.alloc(513),
170
+ }, Buffer.from('hello')), {
171
172
173
174
})().then(common.mustCall());
175
176
// TurboSHAKE domain separation out of range
test/wpt/status/WebCryptoAPI.cjs
@@ -91,6 +91,9 @@ if (process.features.openssl_is_boringssl) {
91
['supports-modern.tentative.https.any.js', /ml-kem-512/i]);
92
93
94
+skipSubtests(
95
+ ['digest/kangarootwelve.tentative.https.any.js', /C=(?:\d{4,}|5(?:1[3-9]|[2-9]\d)|[6-9]\d{2}) bytes/]);
96
97
function assertNoOverlap(fileSkips, subtestSkips) {
98
const subtestSkipFiles = new Set(Object.keys(subtestSkips));
99
const overlap = Object.keys(fileSkips).filter((file) => subtestSkipFiles.has(file));
0 commit comments