Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

fix authentication with promoteBuffers: true #430

Merged
merged 1 commit into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/auth/scram.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class ScramSHA extends AuthProvider {
return callback(tmpError, null);
}

const dict = parsePayload(r.payload.value());
const payload = Buffer.isBuffer(r.payload) ? new Binary(r.payload) : r.payload;
const dict = parsePayload(payload.value());
const iterations = parseInt(dict.i, 10);
const salt = dict.s;
const rnonce = dict.r;
Expand All @@ -198,7 +199,7 @@ class ScramSHA extends AuthProvider {

const clientKey = HMAC(cryptoMethod, saltedPassword, 'Client Key');
const storedKey = H(cryptoMethod, clientKey);
const authMessage = [firstBare, r.payload.value().toString('base64'), withoutProof].join(',');
const authMessage = [firstBare, payload.value().toString('base64'), withoutProof].join(',');

const clientSignature = HMAC(cryptoMethod, storedKey, authMessage);
const clientProof = `p=${xor(clientKey, clientSignature)}`;
Expand Down