Skip to content
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
9 changes: 9 additions & 0 deletions lib/auth_plugins/sha256_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const PLUGIN_NAME = 'sha256_password';
const crypto = require('crypto');
const { xorRotating } = require('../auth_41');
const Tls = require('tls');

const REQUEST_SERVER_KEY_PACKET = Buffer.from([1]);

Expand Down Expand Up @@ -32,6 +33,14 @@ module.exports =
return (data) => {
switch (state) {
case STATE_INITIAL:
if (
connection.stream instanceof Tls.TLSSocket &&
connection.stream.encrypted === true
) {
// We don't need to encrypt passwords over TLS connection
return Buffer.from(`${password}\0`, 'utf8');
}

scramble = data.slice(0, 20);
// if client provides key we can save one extra roundrip on first connection
if (pluginOptions.serverPublicKey) {
Expand Down