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:
authorTobias Nießen <tniessen@tnie.de>2022-05-02 20:46:04 +0300
committerGitHub <noreply@github.com>2022-05-02 20:46:04 +0300
commit75dbb86c58d6abb1a0b1202381be019d8e8c5792 (patch)
tree6a2fbaace869b93ac59878edd9e15a3c8524f469 /lib
parent73a8a0ee3ceb3ea5d972375fb554b276e28777e1 (diff)
crypto: clean up parameter validation in HKDF
PR-URL: https://github.com/nodejs/node/pull/42924 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/crypto/hkdf.js9
-rw-r--r--lib/internal/crypto/util.js2
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/internal/crypto/hkdf.js b/lib/internal/crypto/hkdf.js
index fd274caf0b8..724217c08eb 100644
--- a/lib/internal/crypto/hkdf.js
+++ b/lib/internal/crypto/hkdf.js
@@ -53,13 +53,10 @@ const {
} = require('internal/errors');
const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
- key = prepareKey(key);
- salt = toBuf(salt);
- info = toBuf(info);
-
validateString(hash, 'digest');
- validateByteSource(salt, 'salt');
- validateByteSource(info, 'info');
+ key = prepareKey(key);
+ salt = validateByteSource(salt, 'salt');
+ info = validateByteSource(info, 'info');
validateInteger(length, 'length', 0, kMaxLength);
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js
index 854994277e5..4c1590ed9da 100644
--- a/lib/internal/crypto/util.js
+++ b/lib/internal/crypto/util.js
@@ -271,7 +271,7 @@ const validateByteSource = hideStackFrames((val, name) => {
val = toBuf(val);
if (isAnyArrayBuffer(val) || isArrayBufferView(val))
- return;
+ return val;
throw new ERR_INVALID_ARG_TYPE(
name,