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

crypto: deprecate KeyObject.from but support CryptoKeys in create*Key #37240

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
fixup! crypto: allow CryptoKeys in create*Key
  • Loading branch information
tniessen committed Feb 6, 2021
commit 27a268f660bbdf002f8144a46bb4c0562910c426
6 changes: 5 additions & 1 deletion lib/internal/crypto/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ function prepareSecretKey(key, encoding, bufferOnly = false) {
}

function createSecretKey(key, encoding) {
key = prepareSecretKey(key, encoding, false);
// TODO(tniessen): This doesn't really work.
if (isCryptoKey(key))
return key[kKeyObject];

key = prepareSecretKey(key, encoding, true);
if (key.byteLength === 0)
throw new ERR_OUT_OF_RANGE('key.byteLength', '> 0', key.byteLength);
const handle = new KeyObjectHandle();
Expand Down