Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2395fc0

Browse filesBrowse files
panvaaduh95
authored andcommitted
crypto: rename CShakeParams and KmacParams length to outputLength
PR-URL: #61875 Backport-PR-URL: #62539 Refs: web-platform-tests/wpt#57802 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 541be3a commit 2395fc0
Copy full SHA for 2395fc0

10 files changed

+116-59Lines changed: 116 additions & 59 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/webcrypto.md‎

Copy file name to clipboardExpand all lines: doc/api/webcrypto.md
+29-21Lines changed: 29 additions & 21 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1868,19 +1868,27 @@ the message.
18681868
18691869
<!-- YAML
18701870
added: v24.7.0
1871+
changes:
1872+
- version: REPLACEME
1873+
pr-url: https://github.com/nodejs/node/pull/61875
1874+
description: Renamed `cShakeParams.length` to `cShakeParams.outputLength`.
18711875
-->
18721876
1873-
#### `cShakeParams.customization`
1877+
#### `cShakeParams.name`
18741878
18751879
<!-- YAML
18761880
added: v24.7.0
18771881
-->
18781882
1879-
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
1883+
* Type: {string} Must be `'cSHAKE128'`[^modern-algos] or `'cSHAKE256'`[^modern-algos]
18801884
1881-
The `customization` member represents the customization string.
1882-
The Node.js Web Crypto API implementation only supports zero-length customization
1883-
which is equivalent to not providing customization at all.
1885+
#### `cShakeParams.outputLength`
1886+
1887+
<!-- YAML
1888+
added: REPLACEME
1889+
-->
1890+
1891+
* Type: {number} represents the requested output length in bits.
18841892
18851893
#### `cShakeParams.functionName`
18861894
@@ -1895,21 +1903,17 @@ functions based on cSHAKE.
18951903
The Node.js Web Crypto API implementation only supports zero-length functionName
18961904
which is equivalent to not providing functionName at all.
18971905
1898-
#### `cShakeParams.length`
1906+
#### `cShakeParams.customization`
18991907
19001908
<!-- YAML
19011909
added: v24.7.0
19021910
-->
19031911
1904-
* Type: {number} represents the requested output length in bits.
1905-
1906-
#### `cShakeParams.name`
1907-
1908-
<!-- YAML
1909-
added: v24.7.0
1910-
-->
1912+
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
19111913
1912-
* Type: {string} Must be `'cSHAKE128'`[^modern-algos] or `'cSHAKE256'`[^modern-algos]
1914+
The `customization` member represents the customization string.
1915+
The Node.js Web Crypto API implementation only supports zero-length customization
1916+
which is equivalent to not providing customization at all.
19131917
19141918
### Class: `EcdhKeyDeriveParams`
19151919
@@ -2386,6 +2390,10 @@ added: v24.8.0
23862390
23872391
<!-- YAML
23882392
added: v24.8.0
2393+
changes:
2394+
- version: REPLACEME
2395+
pr-url: https://github.com/nodejs/node/pull/61875
2396+
description: Renamed `kmacParams.length` to `kmacParams.outputLength`.
23892397
-->
23902398
23912399
#### `kmacParams.algorithm`
@@ -2396,25 +2404,25 @@ added: v24.8.0
23962404
23972405
* Type: {string} Must be `'KMAC128'` or `'KMAC256'`.
23982406
2399-
#### `kmacParams.customization`
2407+
#### `kmacParams.outputLength`
24002408
24012409
<!-- YAML
2402-
added: v24.8.0
2410+
added: REPLACEME
24032411
-->
24042412
2405-
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
2413+
* Type: {number}
24062414
2407-
The `customization` member represents the optional customization string.
2415+
The length of the output in bytes. This must be a positive integer.
24082416
2409-
#### `kmacParams.length`
2417+
#### `kmacParams.customization`
24102418
24112419
<!-- YAML
24122420
added: v24.8.0
24132421
-->
24142422
2415-
* Type: {number}
2423+
* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}
24162424
2417-
The length of the output in bytes. This must be a positive integer.
2425+
The `customization` member represents the optional customization string.
24182426
24192427
### Class: `Pbkdf2Params`
24202428
Collapse file

‎lib/internal/crypto/hash.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/hash.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async function asyncDigest(algorithm, data) {
225225
kCryptoJobAsync,
226226
normalizeHashName(algorithm.name),
227227
data,
228-
algorithm.length));
228+
algorithm.outputLength));
229229
}
230230

231231
throw lazyDOMException('Unrecognized algorithm name', 'NotSupportedError');
Collapse file

‎lib/internal/crypto/mac.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/mac.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function kmacSignVerify(key, data, algorithm, signature) {
234234
key[kKeyObject][kHandle],
235235
algorithm.name,
236236
algorithm.customization,
237-
algorithm.length / 8,
237+
algorithm.outputLength / 8,
238238
data,
239239
signature));
240240
}
Collapse file

‎lib/internal/crypto/webidl.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/webidl.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,14 @@ converters.CShakeParams = createDictionaryConverter(
589589
'CShakeParams', [
590590
...new SafeArrayIterator(dictAlgorithm),
591591
{
592-
key: 'length',
592+
key: 'outputLength',
593593
converter: (V, opts) =>
594594
converters['unsigned long'](V, { ...opts, enforceRange: true }),
595595
validator: (V, opts) => {
596596
// The Web Crypto spec allows for SHAKE output length that are not multiples of
597597
// 8. We don't.
598598
if (V % 8)
599-
throw lazyDOMException('Unsupported CShakeParams length', 'NotSupportedError');
599+
throw lazyDOMException('Unsupported CShakeParams outputLength', 'NotSupportedError');
600600
},
601601
required: true,
602602
},
@@ -879,13 +879,13 @@ converters.KmacParams = createDictionaryConverter(
879879
'KmacParams', [
880880
...new SafeArrayIterator(dictAlgorithm),
881881
{
882-
key: 'length',
882+
key: 'outputLength',
883883
converter: (V, opts) =>
884884
converters['unsigned long'](V, { ...opts, enforceRange: true }),
885885
validator: (V, opts) => {
886886
// The Web Crypto spec allows for KMAC output length that are not multiples of 8. We don't.
887887
if (V % 8)
888-
throw lazyDOMException('Unsupported KmacParams length', 'NotSupportedError');
888+
throw lazyDOMException('Unsupported KmacParams outputLength', 'NotSupportedError');
889889
},
890890
required: true,
891891
},
Collapse file

‎test/fixtures/crypto/kmac.js‎

Copy file name to clipboardExpand all lines: test/fixtures/crypto/kmac.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function() {
1313
]),
1414
data: Buffer.from([0x00, 0x01, 0x02, 0x03]),
1515
customization: undefined,
16-
length: 256,
16+
outputLength: 256,
1717
expected: Buffer.from([
1818
0xe5, 0x78, 0x0b, 0x0d, 0x3e, 0xa6, 0xf7, 0xd3, 0xa4, 0x29, 0xc5, 0x70,
1919
0x6a, 0xa4, 0x3a, 0x00, 0xfa, 0xdb, 0xd7, 0xd4, 0x96, 0x28, 0x83, 0x9e,
@@ -30,7 +30,7 @@ module.exports = function() {
3030
]),
3131
data: Buffer.from([0x00, 0x01, 0x02, 0x03]),
3232
customization: Buffer.from('My Tagged Application'),
33-
length: 256,
33+
outputLength: 256,
3434
expected: Buffer.from([
3535
0x3b, 0x1f, 0xba, 0x96, 0x3c, 0xd8, 0xb0, 0xb5, 0x9e, 0x8c, 0x1a, 0x6d,
3636
0x71, 0x88, 0x8b, 0x71, 0x43, 0x65, 0x1a, 0xf8, 0xba, 0x0a, 0x70, 0x70,
@@ -47,7 +47,7 @@ module.exports = function() {
4747
]),
4848
data: Buffer.from(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7
4949
customization: Buffer.from('My Tagged Application'),
50-
length: 256,
50+
outputLength: 256,
5151
expected: Buffer.from([
5252
0x1f, 0x5b, 0x4e, 0x6c, 0xca, 0x02, 0x20, 0x9e, 0x0d, 0xcb, 0x5c, 0xa6,
5353
0x35, 0xb8, 0x9a, 0x15, 0xe2, 0x71, 0xec, 0xc7, 0x60, 0x07, 0x1d, 0xfd,
@@ -64,7 +64,7 @@ module.exports = function() {
6464
]),
6565
data: Buffer.from([0x00, 0x01, 0x02, 0x03]),
6666
customization: Buffer.from('My Tagged Application'),
67-
length: 512,
67+
outputLength: 512,
6868
expected: Buffer.from([
6969
0x20, 0xc5, 0x70, 0xc3, 0x13, 0x46, 0xf7, 0x03, 0xc9, 0xac, 0x36, 0xc6,
7070
0x1c, 0x03, 0xcb, 0x64, 0xc3, 0x97, 0x0d, 0x0c, 0xfc, 0x78, 0x7e, 0x9b,
@@ -84,7 +84,7 @@ module.exports = function() {
8484
]),
8585
data: Buffer.from(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7
8686
customization: undefined,
87-
length: 512,
87+
outputLength: 512,
8888
expected: Buffer.from([
8989
0x75, 0x35, 0x8c, 0xf3, 0x9e, 0x41, 0x49, 0x4e, 0x94, 0x97, 0x07, 0x92,
9090
0x7c, 0xee, 0x0a, 0xf2, 0x0a, 0x3f, 0xf5, 0x53, 0x90, 0x4c, 0x86, 0xb0,
@@ -104,7 +104,7 @@ module.exports = function() {
104104
]),
105105
data: Buffer.from(Array.from({ length: 200 }, (_, i) => i)), // 0x00-0xC7
106106
customization: Buffer.from('My Tagged Application'),
107-
length: 512,
107+
outputLength: 512,
108108
expected: Buffer.from([
109109
0xb5, 0x86, 0x18, 0xf7, 0x1f, 0x92, 0xe1, 0xd5, 0x6c, 0x1b, 0x8c, 0x55,
110110
0xdd, 0xd7, 0xcd, 0x18, 0x8b, 0x97, 0xb4, 0xca, 0x4d, 0x99, 0x83, 0x1e,
Collapse file

‎test/fixtures/webcrypto/supports-modern-algorithms.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/webcrypto/supports-modern-algorithms.mjs
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ const X25519 = await subtle.generateKey('X25519', false, ['deriveBits', 'deriveK
1717
export const vectors = {
1818
'digest': [
1919
[false, 'cSHAKE128'],
20-
[shake128, { name: 'cSHAKE128', length: 128 }],
21-
[shake128, { name: 'cSHAKE128', length: 128, functionName: Buffer.alloc(0), customization: Buffer.alloc(0) }],
22-
[false, { name: 'cSHAKE128', length: 128, functionName: Buffer.alloc(1) }],
23-
[false, { name: 'cSHAKE128', length: 128, customization: Buffer.alloc(1) }],
24-
[false, { name: 'cSHAKE128', length: 127 }],
20+
[shake128, { name: 'cSHAKE128', outputLength: 128 }],
21+
[shake128, { name: 'cSHAKE128', outputLength: 128, functionName: Buffer.alloc(0), customization: Buffer.alloc(0) }],
22+
[false, { name: 'cSHAKE128', outputLength: 128, functionName: Buffer.alloc(1) }],
23+
[false, { name: 'cSHAKE128', outputLength: 128, customization: Buffer.alloc(1) }],
24+
[false, { name: 'cSHAKE128', outputLength: 127 }],
2525
[false, 'cSHAKE256'],
26-
[shake256, { name: 'cSHAKE256', length: 256 }],
27-
[shake256, { name: 'cSHAKE256', length: 256, functionName: Buffer.alloc(0), customization: Buffer.alloc(0) }],
28-
[false, { name: 'cSHAKE256', length: 256, functionName: Buffer.alloc(1) }],
29-
[false, { name: 'cSHAKE256', length: 256, customization: Buffer.alloc(1) }],
30-
[false, { name: 'cSHAKE256', length: 255 }],
26+
[shake256, { name: 'cSHAKE256', outputLength: 256 }],
27+
[shake256, { name: 'cSHAKE256', outputLength: 256, functionName: Buffer.alloc(0), customization: Buffer.alloc(0) }],
28+
[false, { name: 'cSHAKE256', outputLength: 256, functionName: Buffer.alloc(1) }],
29+
[false, { name: 'cSHAKE256', outputLength: 256, customization: Buffer.alloc(1) }],
30+
[false, { name: 'cSHAKE256', outputLength: 255 }],
3131
],
3232
'sign': [
3333
[pqc, 'ML-DSA-44'],
@@ -44,8 +44,8 @@ export const vectors = {
4444
[false, 'Argon2id'],
4545
[false, 'KMAC128'],
4646
[false, 'KMAC256'],
47-
[kmac, { name: 'KMAC128', length: 256 }],
48-
[kmac, { name: 'KMAC256', length: 256 }],
47+
[kmac, { name: 'KMAC128', outputLength: 256 }],
48+
[kmac, { name: 'KMAC256', outputLength: 256 }],
4949
],
5050
'generateKey': [
5151
[pqc, 'ML-DSA-44'],
Collapse file

‎test/parallel/test-webcrypto-digest.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-digest.js
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const kTests = [
1919

2020
if (!process.features.openssl_is_boringssl) {
2121
kTests.push(
22-
[{ name: 'cSHAKE128', length: 256 }, ['shake128', { outputLength: 256 >> 3 }], 256],
23-
[{ name: 'cSHAKE256', length: 512 }, ['shake256', { outputLength: 512 >> 3 }], 512],
22+
[{ name: 'cSHAKE128', outputLength: 256 }, ['shake128', { outputLength: 256 >> 3 }], 256],
23+
[{ name: 'cSHAKE256', outputLength: 512 }, ['shake256', { outputLength: 512 >> 3 }], 512],
2424
['SHA3-256', ['sha3-256'], 256],
2525
['SHA3-384', ['sha3-384'], 384],
2626
['SHA3-512', ['sha3-512'], 512],
@@ -223,10 +223,10 @@ async function testDigest(size, alg) {
223223

224224
function applyXOF(name) {
225225
if (name.match(/cshake128/i)) {
226-
return { name, length: 256 };
226+
return { name, outputLength: 256 };
227227
}
228228
if (name.match(/cshake256/i)) {
229-
return { name, length: 512 };
229+
return { name, outputLength: 512 };
230230
}
231231
return name;
232232

@@ -259,13 +259,13 @@ function applyXOF(name) {
259259
if (getHashes().includes('shake128')) {
260260
(async () => {
261261
assert.deepStrictEqual(
262-
new Uint8Array(await subtle.digest({ name: 'cSHAKE128', length: 0 }, Buffer.alloc(1))),
262+
new Uint8Array(await subtle.digest({ name: 'cSHAKE128', outputLength: 0 }, Buffer.alloc(1))),
263263
new Uint8Array(0),
264264
);
265265

266-
await assert.rejects(subtle.digest({ name: 'cSHAKE128', length: 7 }, Buffer.alloc(1)), {
266+
await assert.rejects(subtle.digest({ name: 'cSHAKE128', outputLength: 7 }, Buffer.alloc(1)), {
267267
name: 'NotSupportedError',
268-
message: 'Unsupported CShakeParams length',
268+
message: 'Unsupported CShakeParams outputLength',
269269
});
270270
})().then(common.mustCall());
271271
}
Collapse file

‎test/parallel/test-webcrypto-sign-verify-kmac.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-sign-verify-kmac.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function testVerify({ algorithm,
1919
key,
2020
data,
2121
customization,
22-
length,
22+
outputLength,
2323
expected }) {
2424
const [
2525
verifyKey,
@@ -46,7 +46,7 @@ async function testVerify({ algorithm,
4646

4747
const signParams = {
4848
name: algorithm,
49-
length,
49+
outputLength,
5050
customization,
5151
};
5252

@@ -112,7 +112,7 @@ async function testVerify({ algorithm,
112112
{
113113
assert(!(await subtle.verify({
114114
...signParams,
115-
length: length === 256 ? 512 : 256,
115+
outputLength: outputLength === 256 ? 512 : 256,
116116
}, verifyKey, expected, data)));
117117
}
118118
}
@@ -121,7 +121,7 @@ async function testSign({ algorithm,
121121
key,
122122
data,
123123
customization,
124-
length,
124+
outputLength,
125125
expected }) {
126126
const [
127127
signKey,
@@ -148,7 +148,7 @@ async function testSign({ algorithm,
148148

149149
const signParams = {
150150
name: algorithm,
151-
length,
151+
outputLength,
152152
customization,
153153
};
154154

Collapse file

‎test/parallel/test-webcrypto-sign-verify.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-sign-verify.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ if (hasOpenSSL(3)) {
118118

119119
const signature = await subtle.sign({
120120
name,
121-
length: 256,
121+
outputLength: 256,
122122
}, key, ec.encode(data));
123123

124124
assert(await subtle.verify({
125125
name,
126-
length: 256,
126+
outputLength: 256,
127127
}, key, signature, ec.encode(data)));
128128
}
129129

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.