Skip to content

Commit

Permalink
fixup! crypto: do not add undefined hash in webcrypto normalizeAlgorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 1, 2022
1 parent 5de34e7 commit baa826f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ function normalizeAlgorithm(algorithm) {
algorithm = { name: algorithm };

if (typeof algorithm === 'object') {
algorithm = { ...algorithm };
const { name } = algorithm;
if (typeof name !== 'string' ||
!ArrayPrototypeIncludes(
Expand All @@ -222,7 +221,7 @@ function normalizeAlgorithm(algorithm) {
}
algorithm.name = kAlgorithms[StringPrototypeToLowerCase(name)];
if (algorithm.hash !== undefined) {
const hash = normalizeAlgorithm(algorithm.hash, 'algorithm.hash');
const hash = normalizeAlgorithm(algorithm.hash);
if (!ArrayPrototypeIncludes(kHashTypes, hash.name))
throw lazyDOMException('Unrecognized name.', 'NotSupportedError');
algorithm.hash = hash;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/webcrypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,10 @@ async function unwrapKey(
extractable,
keyUsages) {
wrappedKey = getArrayBufferOrView(wrappedKey, 'wrappedKey');

unwrapAlgo = normalizeAlgorithm(unwrapAlgo)
let keyData = await cipherOrWrap(
kWebCryptoCipherDecrypt,
normalizeAlgorithm(unwrapAlgo),
unwrapAlgo,
unwrappingKey,
wrappedKey,
'unwrapKey');
Expand Down

0 comments on commit baa826f

Please sign in to comment.