Skip to content

Commit d32a684

Browse files
committed
Fix Encryption Response using RSA PKCSv1 padding.
1 parent 29d1772 commit d32a684

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/minecraft/connection.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ const initiateConnection = async (opts: ConnectionOptions) => {
196196
'-----BEGIN PUBLIC KEY-----\n' +
197197
publicKey.toString('base64') +
198198
'\n-----END PUBLIC KEY-----'
199-
const encryptedSharedSecret = publicEncrypt(pk, sharedSecret)
200-
const encryptedVerifyToken = publicEncrypt(pk, verifyToken)
199+
const ePrms = { key: pk, padding: 1 } // RSA_PKCS1_PADDING
200+
const encryptedSharedSecret = publicEncrypt(ePrms, sharedSecret)
201+
const encryptedVerifyToken = publicEncrypt(ePrms, verifyToken)
201202
// Send encryption response packet.
202203
await conn.writePacket(
203204
0x01,
@@ -212,7 +213,8 @@ const initiateConnection = async (opts: ConnectionOptions) => {
212213
const ss = sharedSecret
213214
conn.aesDecipher = createDecipheriv('aes-128-cfb8', ss, ss)
214215
conn.aesCipher = createCipheriv('aes-128-cfb8', ss, ss)
215-
})().catch(() => {
216+
})().catch(e => {
217+
console.error(e)
216218
conn.disconnectReason =
217219
'{"text":"Failed to authenticate with Mojang servers!"}'
218220
conn.close()

0 commit comments

Comments
 (0)