Skip to content

Commit 13b4ef1

Browse files
authored
Update sha256_password.js
In short, replacing `xor` for `xorRotating` when authenticating passwords that are greater than 20 characters in length. The original issue was first spotted in the auth_plugin `caching_sha2_password` but is also present in the `sha256_password` auth_plugin as well. The link to the original issue (and fix) can be found here: sidorares#1044
1 parent ab3feb7 commit 13b4ef1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/auth_plugins/sha256_password.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const PLUGIN_NAME = 'sha256_password';
44
const crypto = require('crypto');
5-
const { xor } = require('../auth_41');
5+
const { xorRotating } = require('../auth_41');
66

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

@@ -11,7 +11,7 @@ const STATE_WAIT_SERVER_KEY = 1;
1111
const STATE_FINAL = -1;
1212

1313
function encrypt(password, scramble, key) {
14-
const stage1 = xor(
14+
const stage1 = xorRotating(
1515
Buffer.from(`${password}\0`, 'utf8').toString('binary'),
1616
scramble.toString('binary')
1717
);

0 commit comments

Comments
 (0)