| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 195f103 commit 6e30204
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2250,11 +2250,16 @@ added: v25.9.0 | |||
| 2250 | 2250 | ||
| 2251 | 2251 | <!-- YAML | |
| 2252 | 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. | ||
| 2253 | 2257 | --> | |
| 2254 | 2258 | ||
| 2255 | 2259 | * Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined} | |
| 2256 | 2260 | ||
| 2257 | - The optional customization string for KangarooTwelve. | ||
| 2261 | + The optional customization string for KangarooTwelve. It must not exceed 512 | ||
| 2262 | + bytes. | ||
| 2258 | 2263 | ||
| 2259 | 2264 | #### `kangarooTwelveParams.name` | |
| 2260 | 2265 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,10 +296,6 @@ function validateCShakeFunctionName(V) { | |||
| 296 | 296 | 'NotSupportedError'); | |
| 297 | 297 | } | |
| 298 | 298 | ||
| 299 | - function validateCShakeCustomization(V) { | ||
| 300 | - validateMaxBufferLength(V, 'CShakeParams.customization', 512); | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | 299 | converters.RsaPssParams = createDictionaryConverter( | |
| 304 | 300 | 'RsaPssParams', [ | |
| 305 | 301 | 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 | 452 | }, | |
| 457 | 453 | ], | |
| 458 | 454 | ]); | |
@@ -774,6 +770,7 @@ converters.KangarooTwelveParams = createDictionaryConverter( | |||
| 774 | 770 | { | |
| 775 | 771 | key: 'customization', | |
| 776 | 772 | converter: converters.BufferSource, | |
| 773 | + validator: (V, opts) => validateMaxBufferLength(V, 'KangarooTwelveParams.customization', 512), | ||
| 777 | 774 | }, | |
| 778 | 775 | ], | |
| 779 | 776 | ]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,11 +48,15 @@ export const vectors = { | |||
| 48 | 48 | [false, 'KT128'], | |
| 49 | 49 | [true, { name: 'KT128', outputLength: 128 }], | |
| 50 | 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) }], | ||
| 51 | 53 | [false, { name: 'KT128', outputLength: 0 }], | |
| 52 | 54 | [false, { name: 'KT128', outputLength: 127 }], | |
| 53 | 55 | [false, 'KT256'], | |
| 54 | 56 | [true, { name: 'KT256', outputLength: 256 }], | |
| 55 | 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) }], | ||
| 56 | 60 | [false, { name: 'KT256', outputLength: 0 }], | |
| 57 | 61 | [false, { name: 'KT256', outputLength: 255 }], | |
| 58 | 62 | ], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -326,6 +326,15 @@ async function checkDigest(name, vectors) { | |||
| 326 | 326 | else | |
| 327 | 327 | algorithm.domainSeparation = rest[0]; | |
| 328 | 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 | + | ||
| 329 | 338 | const result = await subtle.digest(algorithm, input); | |
| 330 | 339 | assert.deepStrictEqual( | |
| 331 | 340 | Buffer.from(result).toString('hex'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,11 +155,22 @@ async function testDigest(size, alg) { | |||
| 155 | 155 | ||
| 156 | 156 | // KT128 with customization string | |
| 157 | 157 | (async () => { | |
| 158 | - const digest = await subtle.digest( | ||
| 159 | - { name: 'KT128', outputLength: 256, customization: Buffer.from('test') }, | ||
| 160 | - Buffer.from('hello')); | ||
| 158 | + const digest = await subtle.digest({ | ||
| 159 | + name: 'KT128', | ||
| 160 | + outputLength: 256, | ||
| 161 | + customization: Buffer.alloc(512), | ||
| 162 | + }, Buffer.from('hello')); | ||
| 161 | 163 | assert(digest instanceof ArrayBuffer); | |
| 162 | 164 | assert.strictEqual(digest.byteLength, 32); | |
| 165 | + | ||
| 166 | + await assert.rejects(subtle.digest({ | ||
| 167 | + name: 'KT128', | ||
| 168 | + outputLength: 256, | ||
| 169 | + customization: Buffer.alloc(513), | ||
| 170 | + }, Buffer.from('hello')), { | ||
| 171 | + name: 'OperationError', | ||
| 172 | + message: 'KangarooTwelveParams.customization must be at most 512 bytes', | ||
| 173 | + }); | ||
| 163 | 174 | })().then(common.mustCall()); | |
| 164 | 175 | ||
| 165 | 176 | // TurboSHAKE domain separation out of range | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,6 +91,9 @@ if (process.features.openssl_is_boringssl) { | |||
| 91 | 91 | ['supports-modern.tentative.https.any.js', /ml-kem-512/i]); | |
| 92 | 92 | } | |
| 93 | 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 | + | ||
| 94 | 97 | function assertNoOverlap(fileSkips, subtestSkips) { | |
| 95 | 98 | const subtestSkipFiles = new Set(Object.keys(subtestSkips)); | |
| 96 | 99 | const overlap = Object.keys(fileSkips).filter((file) => subtestSkipFiles.has(file)); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments