There was an error while loading. Please reload this page.
1 parent 195f103 commit 6e30204Copy full SHA for 6e30204
6 files changed
doc/api/webcrypto.md
@@ -2250,11 +2250,16 @@ added: v25.9.0
2250
2251
<!-- YAML
2252
added: v25.9.0
2253
+changes:
2254
+ - version: REPLACEME
2255
+ pr-url: https://github.com/nodejs/node/pull/64557
2256
+ description: Limit customization to 512 bytes.
2257
-->
2258
2259
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
2260
-The optional customization string for KangarooTwelve.
2261
+The optional customization string for KangarooTwelve. It must not exceed 512
2262
+bytes.
2263
2264
#### `kangarooTwelveParams.name`
2265
lib/internal/crypto/webidl.js
@@ -296,10 +296,6 @@ function validateCShakeFunctionName(V) {
296
'NotSupportedError');
297
}
298
299
-function validateCShakeCustomization(V) {
300
- validateMaxBufferLength(V, 'CShakeParams.customization', 512);
301
-}
302
-
303
converters.RsaPssParams = createDictionaryConverter(
304
'RsaPssParams', [
305
dictAlgorithm,
@@ -452,7 +448,7 @@ converters.CShakeParams = createDictionaryConverter(
452
448
{
453
449
key: 'customization',
454
450
converter: converters.BufferSource,
455
- validator: validateCShakeCustomization,
451
+ validator: (V, opts) => validateMaxBufferLength(V, 'CShakeParams.customization', 512),
456
},
457
],
458
]);
@@ -774,6 +770,7 @@ converters.KangarooTwelveParams = createDictionaryConverter(
774
770
775
771
776
772
773
+ validator: (V, opts) => validateMaxBufferLength(V, 'KangarooTwelveParams.customization', 512),
777
778
779
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