Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc,lib,test: rename HKDF 'key' argument #39474

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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