Skip to content

Commit

Permalink
doc,lib,test: rename HKDF 'key' argument
Browse files Browse the repository at this point in the history
PR-URL: #39474
Refs: #39471
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
tniessen authored and targos committed Aug 2, 2021
1 parent e53ec68 commit 7a731ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -3839,14 +3839,14 @@ const {
console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
```

### `crypto.hkdf(digest, key, salt, info, keylen, callback)`
### `crypto.hkdf(digest, ikm, salt, info, keylen, callback)`
<!-- YAML
added: v15.0.0
-->

* `digest` {string} The digest algorithm to use.
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The secret
key. It must be at least one byte in length.
* `ikm` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The input
keying material. It must be at least one byte in length.
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must
be provided but can be zero-length.
* `info` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional info value.
Expand All @@ -3859,7 +3859,7 @@ added: v15.0.0
* `err` {Error}
* `derivedKey` {Buffer}

HKDF is a simple key derivation function defined in RFC 5869. The given `key`,
HKDF is a simple key derivation function defined in RFC 5869. The given `ikm`,
`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.

The supplied `callback` function is called with two arguments: `err` and
Expand Down Expand Up @@ -3892,14 +3892,14 @@ hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
});
```

### `crypto.hkdfSync(digest, key, salt, info, keylen)`
### `crypto.hkdfSync(digest, ikm, salt, info, keylen)`
<!-- YAML
added: v15.0.0
-->

* `digest` {string} The digest algorithm to use.
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The secret
key. It must be at least one byte in length.
* `ikm` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The input
keying material. It must be at least one byte in length.
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must
be provided but can be zero-length.
* `info` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional info value.
Expand All @@ -3911,7 +3911,7 @@ added: v15.0.0
* Returns: {ArrayBuffer}

Provides a synchronous HKDF key derivation function as defined in RFC 5869. The
given `key`, `salt` and `info` are used with the `digest` to derive a key of
given `ikm`, `salt` and `info` are used with the `digest` to derive a key of
`keylen` bytes.

The successfully generated `derivedKey` will be returned as an {ArrayBuffer}.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/hkdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function prepareKey(key) {

if (!isArrayBufferView(key)) {
throw new ERR_INVALID_ARG_TYPE(
'key',
'ikm',
[
'string',
'SecretKeyObject',
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-hkdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const {
[1, {}, [], false, Infinity].forEach((i) => {
assert.throws(() => hkdf('sha256', i), {
code: 'ERR_INVALID_ARG_TYPE',
message: /^The "key" argument must be /
message: /^The "ikm" argument must be /
});
assert.throws(() => hkdfSync('sha256', i), {
code: 'ERR_INVALID_ARG_TYPE',
message: /^The "key" argument must be /
message: /^The "ikm" argument must be /
});
});

Expand Down

0 comments on commit 7a731ef

Please sign in to comment.