Skip to content

Commit eeb77d2

Browse files
panvaaduh95
authored andcommitted
doc,lib: align WebCrypto names with spec
Rename WebCrypto operation parameters and local variables to match the spec terminology. Use operation, algorithm, and key names consistently between the docs and implementation. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #63518 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8c479f2 commit eeb77d2

10 files changed

Lines changed: 327 additions & 226 deletions

File tree

‎doc/api/webcrypto.md‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ The algorithms currently supported include:
849849
* `'ML-KEM-768'`[^modern-algos]
850850
* `'ML-KEM-1024'`[^modern-algos]
851851
852-
### `subtle.decapsulateKey(decapsulationAlgorithm, decapsulationKey, ciphertext, sharedKeyAlgorithm, extractable, usages)`
852+
### `subtle.decapsulateKey(decapsulationAlgorithm, decapsulationKey, ciphertext, sharedKeyAlgorithm, extractable, keyUsages)`
853853
854854
<!-- YAML
855855
added: v24.7.0
@@ -862,7 +862,7 @@ added: v24.7.0
862862
* `ciphertext` {ArrayBuffer|TypedArray|DataView|Buffer}
863863
* `sharedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
864864
* `extractable` {boolean}
865-
* `usages` {string\[]} See [Key usages][].
865+
* `keyUsages` {string\[]} See [Key usages][].
866866
* Returns: {Promise} Fulfills with {CryptoKey} upon success.
867867
868868
A message recipient uses their asymmetric private key to decrypt an
@@ -960,7 +960,7 @@ The algorithms currently supported include:
960960
* `'X25519'`
961961
* `'X448'`[^secure-curves]
962962
963-
### `subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)`
963+
### `subtle.deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)`
964964
965965
<!-- YAML
966966
added: v15.0.0
@@ -979,7 +979,7 @@ changes:
979979
980980
* `algorithm` {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params|Argon2Params}
981981
* `baseKey` {CryptoKey}
982-
* `derivedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
982+
* `derivedKeyType` {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
983983
* `extractable` {boolean}
984984
* `keyUsages` {string\[]} See [Key usages][].
985985
* Returns: {Promise} Fulfills with a {CryptoKey} upon success.
@@ -988,11 +988,11 @@ changes:
988988
989989
Using the method and parameters specified in `algorithm`, and the keying
990990
material provided by `baseKey`, this method attempts to generate
991-
a new {CryptoKey} based on the method and parameters in `derivedKeyAlgorithm`.
991+
a new {CryptoKey} based on the method and parameters in `derivedKeyType`.
992992
993993
Calling this method is equivalent to calling [`subtle.deriveBits()`][] to
994994
generate raw keying material, then passing the result into the
995-
[`subtle.importKey()`][] method using the `derivedKeyAlgorithm`, `extractable`, and
995+
[`subtle.importKey()`][] method using the `derivedKeyType`, `extractable`, and
996996
`keyUsages` parameters as input.
997997
998998
The algorithms currently supported include:
@@ -1071,7 +1071,7 @@ The algorithms currently supported include:
10711071
* `'ML-KEM-768'`[^modern-algos]
10721072
* `'ML-KEM-1024'`[^modern-algos]
10731073
1074-
### `subtle.encapsulateKey(encapsulationAlgorithm, encapsulationKey, sharedKeyAlgorithm, extractable, usages)`
1074+
### `subtle.encapsulateKey(encapsulationAlgorithm, encapsulationKey, sharedKeyAlgorithm, extractable, keyUsages)`
10751075
10761076
<!-- YAML
10771077
added: v24.7.0
@@ -1083,7 +1083,7 @@ added: v24.7.0
10831083
* `encapsulationKey` {CryptoKey}
10841084
* `sharedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
10851085
* `extractable` {boolean}
1086-
* `usages` {string\[]} See [Key usages][].
1086+
* `keyUsages` {string\[]} See [Key usages][].
10871087
* Returns: {Promise} Fulfills with {EncapsulatedKey} upon success.
10881088
10891089
Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
@@ -1415,7 +1415,7 @@ The algorithms currently supported include:
14151415
* `'RSA-PSS'`
14161416
* `'RSASSA-PKCS1-v1_5'`
14171417
1418-
### `subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)`
1418+
### `subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)`
14191419
14201420
<!-- YAML
14211421
added: v15.0.0
@@ -1435,8 +1435,8 @@ changes:
14351435
14361436
<!--lint disable maximum-line-length remark-lint-->
14371437
1438-
* `unwrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
1439-
* `unwrappedKeyAlgo` {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams|KmacImportParams}
1438+
* `unwrapAlgorithm` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
1439+
* `unwrappedKeyAlgorithm` {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams|KmacImportParams}
14401440
14411441
<!--lint enable maximum-line-length remark-lint-->
14421442
@@ -1448,8 +1448,8 @@ In cryptography, "wrapping a key" refers to exporting and then encrypting the
14481448
keying material. This method attempts to decrypt a wrapped
14491449
key and create a {CryptoKey} instance. It is equivalent to calling
14501450
[`subtle.decrypt()`][] first on the encrypted key data (using the `wrappedKey`,
1451-
`unwrapAlgo`, and `unwrappingKey` arguments as input) then passing the results
1452-
to the [`subtle.importKey()`][] method using the `unwrappedKeyAlgo`,
1451+
`unwrapAlgorithm`, and `unwrappingKey` arguments as input) then passing the results
1452+
to the [`subtle.importKey()`][] method using the `unwrappedKeyAlgorithm`,
14531453
`extractable`, and `keyUsages` arguments as inputs. If successful, the returned
14541454
promise is resolved with a {CryptoKey} object.
14551455
@@ -1537,7 +1537,7 @@ The algorithms currently supported include:
15371537
* `'RSA-PSS'`
15381538
* `'RSASSA-PKCS1-v1_5'`
15391539
1540-
### `subtle.wrapKey(format, key, wrappingKey, wrapAlgo)`
1540+
### `subtle.wrapKey(format, key, wrappingKey, wrapAlgorithm)`
15411541
15421542
<!-- YAML
15431543
added: v15.0.0
@@ -1556,18 +1556,18 @@ changes:
15561556
`'raw-public'`[^modern-algos], or `'raw-seed'`[^modern-algos].
15571557
* `key` {CryptoKey}
15581558
* `wrappingKey` {CryptoKey}
1559-
* `wrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
1559+
* `wrapAlgorithm` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
15601560
* Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.
15611561
15621562
<!--lint enable maximum-line-length remark-lint-->
15631563
15641564
In cryptography, "wrapping a key" refers to exporting and then encrypting the
15651565
keying material. This method exports the keying material into
15661566
the format identified by `format`, then encrypts it using the method and
1567-
parameters specified by `wrapAlgo` and the keying material provided by
1567+
parameters specified by `wrapAlgorithm` and the keying material provided by
15681568
`wrappingKey`. It is the equivalent to calling [`subtle.exportKey()`][] using
15691569
`format` and `key` as the arguments, then passing the result to the
1570-
[`subtle.encrypt()`][] method using `wrappingKey` and `wrapAlgo` as inputs. If
1570+
[`subtle.encrypt()`][] method using `wrappingKey` and `wrapAlgorithm` as inputs. If
15711571
successful, the returned promise will be resolved with an {ArrayBuffer}
15721572
containing the encrypted key data.
15731573
@@ -2795,19 +2795,19 @@ added: v25.9.0
27952795
[Web Crypto API]: https://www.w3.org/TR/WebCryptoAPI/
27962796
[`SubtleCrypto.supports()`]: #static-method-subtlecryptosupportsoperation-algorithm-lengthoradditionalalgorithm
27972797
[`subtle.decapsulateBits()`]: #subtledecapsulatebitsdecapsulationalgorithm-decapsulationkey-ciphertext
2798-
[`subtle.decapsulateKey()`]: #subtledecapsulatekeydecapsulationalgorithm-decapsulationkey-ciphertext-sharedkeyalgorithm-extractable-usages
2798+
[`subtle.decapsulateKey()`]: #subtledecapsulatekeydecapsulationalgorithm-decapsulationkey-ciphertext-sharedkeyalgorithm-extractable-keyusages
27992799
[`subtle.decrypt()`]: #subtledecryptalgorithm-key-data
28002800
[`subtle.deriveBits()`]: #subtlederivebitsalgorithm-basekey-length
2801-
[`subtle.deriveKey()`]: #subtlederivekeyalgorithm-basekey-derivedkeyalgorithm-extractable-keyusages
2801+
[`subtle.deriveKey()`]: #subtlederivekeyalgorithm-basekey-derivedkeytype-extractable-keyusages
28022802
[`subtle.digest()`]: #subtledigestalgorithm-data
28032803
[`subtle.encapsulateBits()`]: #subtleencapsulatebitsencapsulationalgorithm-encapsulationkey
2804-
[`subtle.encapsulateKey()`]: #subtleencapsulatekeyencapsulationalgorithm-encapsulationkey-sharedkeyalgorithm-extractable-usages
2804+
[`subtle.encapsulateKey()`]: #subtleencapsulatekeyencapsulationalgorithm-encapsulationkey-sharedkeyalgorithm-extractable-keyusages
28052805
[`subtle.encrypt()`]: #subtleencryptalgorithm-key-data
28062806
[`subtle.exportKey()`]: #subtleexportkeyformat-key
28072807
[`subtle.generateKey()`]: #subtlegeneratekeyalgorithm-extractable-keyusages
28082808
[`subtle.getPublicKey()`]: #subtlegetpublickeykey-keyusages
28092809
[`subtle.importKey()`]: #subtleimportkeyformat-keydata-algorithm-extractable-keyusages
28102810
[`subtle.sign()`]: #subtlesignalgorithm-key-data
2811-
[`subtle.unwrapKey()`]: #subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgo-unwrappedkeyalgo-extractable-keyusages
2811+
[`subtle.unwrapKey()`]: #subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgorithm-unwrappedkeyalgorithm-extractable-keyusages
28122812
[`subtle.verify()`]: #subtleverifyalgorithm-key-signature-data
2813-
[`subtle.wrapKey()`]: #subtlewrapkeyformat-key-wrappingkey-wrapalgo
2813+
[`subtle.wrapKey()`]: #subtlewrapkeyformat-key-wrappingkey-wrapalgorithm

‎lib/internal/crypto/aes.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ function aesCipher(mode, key, data, algorithm) {
175175
}
176176
}
177177

178-
functionaesGenerateKey(algorithm,extractable,keyUsages){
178+
functionaesGenerateKey(algorithm,extractable,usages){
179179
const{ name, length }=algorithm;
180180

181181
constcheckUsages=['wrapKey','unwrapKey'];
182182
if(name!=='AES-KW')
183183
ArrayPrototypePush(checkUsages,'encrypt','decrypt');
184184

185-
constusagesSet=newSafeSet(keyUsages);
185+
constusagesSet=newSafeSet(usages);
186186
if(hasAnyNotIn(usagesSet,checkUsages)){
187187
throwlazyDOMException(
188188
'Unsupported key usage for an AES key',
@@ -207,13 +207,13 @@ function aesImportKey(
207207
format,
208208
keyData,
209209
extractable,
210-
keyUsages){
210+
usages){
211211
const{ name }=algorithm;
212212
constcheckUsages=['wrapKey','unwrapKey'];
213213
if(name!=='AES-KW')
214214
ArrayPrototypePush(checkUsages,'encrypt','decrypt');
215215

216-
constusagesSet=newSafeSet(keyUsages);
216+
constusagesSet=newSafeSet(usages);
217217
if(hasAnyNotIn(usagesSet,checkUsages)){
218218
throwlazyDOMException(
219219
'Unsupported key usage for an AES key',

‎lib/internal/crypto/cfrg.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ function verifyAcceptableCfrgKeyUse(name, isPublic, usages) {
7373
}
7474
}
7575

76-
functioncfrgGenerateKey(algorithm,extractable,keyUsages){
76+
functioncfrgGenerateKey(algorithm,extractable,usages){
7777
const{ name }=algorithm;
7878

79-
constusageSet=newSafeSet(keyUsages);
79+
constusageSet=newSafeSet(usages);
8080
switch(name){
8181
case'Ed25519':
8282
// Fall through
@@ -170,11 +170,11 @@ function cfrgImportKey(
170170
keyData,
171171
algorithm,
172172
extractable,
173-
keyUsages){
173+
usages){
174174

175175
const{ name }=algorithm;
176176
lethandle;
177-
constusagesSet=newSafeSet(keyUsages);
177+
constusagesSet=newSafeSet(usages);
178178
switch(format){
179179
case'KeyObject': {
180180
verifyAcceptableCfrgKeyUse(

‎lib/internal/crypto/chacha20_poly1305.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ function c20pCipher(mode, key, data, algorithm) {
4747
algorithm.additionalData));
4848
}
4949

50-
functionc20pGenerateKey(algorithm,extractable,keyUsages){
50+
functionc20pGenerateKey(algorithm,extractable,usages){
5151
const{ name }=algorithm;
5252

5353
constcheckUsages=['encrypt','decrypt','wrapKey','unwrapKey'];
5454

55-
constusagesSet=newSafeSet(keyUsages);
55+
constusagesSet=newSafeSet(usages);
5656
if(hasAnyNotIn(usagesSet,checkUsages)){
5757
throwlazyDOMException(
5858
`Unsupported key usage for a ${algorithm.name} key`,
@@ -77,11 +77,11 @@ function c20pImportKey(
7777
format,
7878
keyData,
7979
extractable,
80-
keyUsages){
80+
usages){
8181
const{ name }=algorithm;
8282
constcheckUsages=['encrypt','decrypt','wrapKey','unwrapKey'];
8383

84-
constusagesSet=newSafeSet(keyUsages);
84+
constusagesSet=newSafeSet(usages);
8585
if(hasAnyNotIn(usagesSet,checkUsages)){
8686
throwlazyDOMException(
8787
`Unsupported key usage for a ${algorithm.name} key`,

‎lib/internal/crypto/ec.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ function verifyAcceptableEcKeyUse(name, isPublic, usages) {
7777
}
7878
}
7979

80-
functionecGenerateKey(algorithm,extractable,keyUsages){
80+
functionecGenerateKey(algorithm,extractable,usages){
8181
const{ name, namedCurve }=algorithm;
8282

83-
constusageSet=newSafeSet(keyUsages);
83+
constusageSet=newSafeSet(usages);
8484
switch(name){
8585
case'ECDSA':
8686
if(hasAnyNotIn(usageSet,['sign','verify'])){
@@ -178,12 +178,12 @@ function ecImportKey(
178178
keyData,
179179
algorithm,
180180
extractable,
181-
keyUsages,
181+
usages,
182182
){
183183
const{ name, namedCurve }=algorithm;
184184

185185
lethandle;
186-
constusagesSet=newSafeSet(keyUsages);
186+
constusagesSet=newSafeSet(usages);
187187
switch(format){
188188
case'KeyObject': {
189189
verifyAcceptableEcKeyUse(

‎lib/internal/crypto/mac.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ const {
4040
validateJwk,
4141
}=require('internal/crypto/webcrypto_util');
4242

43-
functionhmacGenerateKey(algorithm,extractable,keyUsages){
43+
functionhmacGenerateKey(algorithm,extractable,usages){
4444
const{
4545
hash,
4646
name,
4747
length =getBlockSize(hash.name),
4848
}=algorithm;
4949

50-
constusageSet=newSafeSet(keyUsages);
50+
constusageSet=newSafeSet(usages);
5151
if(hasAnyNotIn(usageSet,['sign','verify'])){
5252
throwlazyDOMException(
5353
'Unsupported key usage for an HMAC key',
@@ -67,7 +67,7 @@ function hmacGenerateKey(algorithm, extractable, keyUsages) {
6767
extractable));
6868
}
6969

70-
functionkmacGenerateKey(algorithm,extractable,keyUsages){
70+
functionkmacGenerateKey(algorithm,extractable,usages){
7171
const{
7272
name,
7373
length ={
@@ -77,7 +77,7 @@ function kmacGenerateKey(algorithm, extractable, keyUsages) {
7777
}[name],
7878
}=algorithm;
7979

80-
constusageSet=newSafeSet(keyUsages);
80+
constusageSet=newSafeSet(usages);
8181
if(hasAnyNotIn(usageSet,['sign','verify'])){
8282
throwlazyDOMException(
8383
`Unsupported key usage for ${name} key`,
@@ -102,10 +102,10 @@ function macImportKey(
102102
keyData,
103103
algorithm,
104104
extractable,
105-
keyUsages,
105+
usages,
106106
){
107107
constisHmac=algorithm.name==='HMAC';
108-
constusagesSet=newSafeSet(keyUsages);
108+
constusagesSet=newSafeSet(usages);
109109
if(hasAnyNotIn(usagesSet,['sign','verify'])){
110110
throwlazyDOMException(
111111
`Unsupported key usage for ${algorithm.name} key`,

‎lib/internal/crypto/ml_dsa.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ function verifyAcceptableMlDsaKeyUse(name, isPublic, usages) {
5959
}
6060
}
6161

62-
functionmlDsaGenerateKey(algorithm,extractable,keyUsages){
62+
functionmlDsaGenerateKey(algorithm,extractable,usages){
6363
const{ name }=algorithm;
6464

65-
constusageSet=newSafeSet(keyUsages);
65+
constusageSet=newSafeSet(usages);
6666
if(hasAnyNotIn(usageSet,['sign','verify'])){
6767
throwlazyDOMException(
6868
`Unsupported key usage for an ${name} key`,
@@ -136,11 +136,11 @@ function mlDsaImportKey(
136136
keyData,
137137
algorithm,
138138
extractable,
139-
keyUsages){
139+
usages){
140140

141141
const{ name }=algorithm;
142142
lethandle;
143-
constusagesSet=newSafeSet(keyUsages);
143+
constusagesSet=newSafeSet(usages);
144144
switch(format){
145145
case'KeyObject': {
146146
verifyAcceptableMlDsaKeyUse(

‎lib/internal/crypto/ml_kem.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ const {
4949
validateJwk,
5050
}=require('internal/crypto/webcrypto_util');
5151

52-
functionmlKemGenerateKey(algorithm,extractable,keyUsages){
52+
functionmlKemGenerateKey(algorithm,extractable,usages){
5353
const{ name }=algorithm;
5454

55-
constusageSet=newSafeSet(keyUsages);
55+
constusageSet=newSafeSet(usages);
5656
if(hasAnyNotIn(usageSet,['encapsulateKey','encapsulateBits','decapsulateKey','decapsulateBits'])){
5757
throwlazyDOMException(
5858
`Unsupported key usage for an ${name} key`,
@@ -137,11 +137,11 @@ function mlKemImportKey(
137137
keyData,
138138
algorithm,
139139
extractable,
140-
keyUsages){
140+
usages){
141141

142142
const{ name }=algorithm;
143143
lethandle;
144-
constusagesSet=newSafeSet(keyUsages);
144+
constusagesSet=newSafeSet(usages);
145145
switch(format){
146146
case'KeyObject': {
147147
verifyAcceptableMlKemKeyUse(

0 commit comments

Comments
 (0)