Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFilip Skokan <panva.ip@gmail.com>2022-08-11 12:53:00 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:30 +0300
commit317cd051ce9b6606a2459afbffc566b52689b0ef (patch)
tree55e7ce92db3ad08d3a08c6616409e93b132e144c /lib
parente5c9975f1139b4d465e67c6a81fa5fcd1a268cf2 (diff)
crypto: allow zero-length IKM in HKDF and in webcrypto PBKDF2
PR-URL: https://github.com/nodejs/node/pull/44201 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Backport-PR-URL: https://github.com/nodejs/node/pull/44872
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/crypto/hkdf.js4
-rw-r--r--lib/internal/crypto/webcrypto.js3
2 files changed, 1 insertions, 6 deletions
diff --git a/lib/internal/crypto/hkdf.js b/lib/internal/crypto/hkdf.js
index 9dd49d12dd3..635e07dd594 100644
--- a/lib/internal/crypto/hkdf.js
+++ b/lib/internal/crypto/hkdf.js
@@ -3,7 +3,6 @@
const {
FunctionPrototypeCall,
Promise,
- Uint8Array,
} = primordials;
const {
@@ -80,9 +79,8 @@ function prepareKey(key) {
if (isKeyObject(key))
return key;
- // TODO(@jasnell): createSecretKey should allow using an ArrayBuffer
if (isAnyArrayBuffer(key))
- return createSecretKey(new Uint8Array(key));
+ return createSecretKey(key);
key = toBuf(key);
diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js
index b7760efaa23..df4bb072043 100644
--- a/lib/internal/crypto/webcrypto.js
+++ b/lib/internal/crypto/webcrypto.js
@@ -494,9 +494,6 @@ async function importGenericSecretKey(
const checkLength = keyData.byteLength * 8;
- if (checkLength === 0 || length === 0)
- throw lazyDOMException('Zero-length key is not supported', 'DataError');
-
// The Web Crypto spec allows for key lengths that are not multiples of
// 8. We don't. Our check here is stricter than that defined by the spec
// in that we require that algorithm.length match keyData.length * 8 if