From be9165bffd729fb52dac9393bafe1d2d6bf49053 Mon Sep 17 00:00:00 2001 From: Ishan Date: Mon, 22 Jul 2024 00:34:56 +0530 Subject: [PATCH] client: fix implicit key hashing during rekey Fixes: https://github.com/mscdex/ssh2/issues/1404 --- lib/client.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3e393e50..aa94ace0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -273,16 +273,14 @@ class Client extends EventEmitter { let hostVerifier; if (typeof cfg.hostVerifier === 'function') { const hashCb = cfg.hostVerifier; - let hasher; + let hashAlgo; if (HASHES.indexOf(cfg.hostHash) !== -1) { // Default to old behavior of hashing on user's behalf - hasher = createHash(cfg.hostHash); + hashAlgo = cfg.hostHash; } hostVerifier = (key, verify) => { - if (hasher) { - hasher.update(key); - key = hasher.digest('hex'); - } + if (hashAlgo) + key = createHash(hashAlgo).update(key).digest('hex'); const ret = hashCb(key, verify); if (ret !== undefined) verify(ret);