Skip to content

Commit

Permalink
client: fix implicit key hashing during rekey
Browse files Browse the repository at this point in the history
Fixes: #1404
  • Loading branch information
Ishan authored and mscdex committed Jul 23, 2024
1 parent f96c43e commit be9165b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit be9165b

Please sign in to comment.