0x01 S01PacketEncryptionRequest

Requests the client to enable encryption by sending the server's RSA public key, a verify token (random challenge), and server ID for Mojang session auth.

Clientbound (Server → Client) · LOGIN · net/minecraft/network/login/server/S01PacketEncryptionRequest.java

Published 2026-06-18 · Updated 2026-10-14

loginauthenticationencryptionsecurity
Comprehensive 8/8

Fields

FieldTypeDescription
serverIdStringServer ID for Mojang session auth (empty string in 1.8.9)
publicKeybyte[] (DER-encoded)Server's RSA public key for encrypting the shared secret
verifyTokenbyte[] (4 random bytes)Random challenge bytes the client must encrypt and return

Wire Encoding

FieldTypeNotes
Server IDStringUsually empty for auth
Public Key LengthVarIntLength of DER-encoded RSA public key
Public Keybyte[]Server's RSA public key in DER format
Verify Token LengthVarIntLength of verify token
Verify Tokenbyte[]4 random bytes for challenge-response

MCP References

MCPNetHandlerLoginClient.handleEncryptionRequest()

Handler Interface

HNDINetHandlerLoginClient

Notes

After receiving this, the client generates a random AES shared secret, encrypts it + the verify token with the server's public key, and sends them back in C01PacketEncryptionResponse. Also authenticates with Mojang's session server using the serverId hash.

Vanilla Source

S01PacketEncryptionRequest.java69 lines · MCP 1.8.9Original ↗
1
package net.minecraft.network.login.server;
2
3
import java.io.IOException;
4
import java.security.PublicKey;
5
import net.minecraft.network.Packet;
6
import net.minecraft.network.PacketBuffer;
7
import net.minecraft.network.login.INetHandlerLoginClient;
8
import net.minecraft.util.CryptManager;
9
10
public class S01PacketEncryptionRequest implements Packet<INetHandlerLoginClient>
11
{
12
    private String hashedServerId;
13
    private PublicKey publicKey;
14
    private byte[] verifyToken;
15
16
    public S01PacketEncryptionRequest()
17
    {
18
    }
19
20
    public S01PacketEncryptionRequest(String serverId, PublicKey key, byte[] verifyToken)
21
    {
22
        this.hashedServerId = serverId;
23
        this.publicKey = key;
24
        this.verifyToken = verifyToken;
25
    }
26
27
    /**
28
     * Reads the raw packet data from the data stream.
29
     */
30
    public void readPacketData(PacketBuffer buf) throws IOException
31
    {
32
        this.hashedServerId = buf.readStringFromBuffer(20);
33
        this.publicKey = CryptManager.decodePublicKey(buf.readByteArray());
34
        this.verifyToken = buf.readByteArray();
35
    }
36
37
    /**
38
     * Writes the raw packet data to the data stream.
39
     */
40
    public void writePacketData(PacketBuffer buf) throws IOException
41
    {
42
        buf.writeString(this.hashedServerId);
43
        buf.writeByteArray(this.publicKey.getEncoded());
44
        buf.writeByteArray(this.verifyToken);
45
    }
46
47
    /**
48
     * Passes this Packet on to the NetHandler for processing.
49
     */
50
    public void processPacket(INetHandlerLoginClient handler)
51
    {
52
        handler.handleEncryptionRequest(this);
53
    }
54
55
    public String getServerId()
56
    {
57
        return this.hashedServerId;
58
    }
59
60
    public PublicKey getPublicKey()
61
    {
62
        return this.publicKey;
63
    }
64
65
    public byte[] getVerifyToken()
66
    {
67
        return this.verifyToken;
68
    }
69
}

Deobfuscated MCP 1.8.9 source of S01PacketEncryptionRequest, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/login/server/S01PacketEncryptionRequest.java) at build time and verified present.

Deep Dive

Role in the protocol

The LOGIN-state RSA challenge. NetHandlerLoginServer sends it once the client has identified itself with C00PacketLoginStart: new S01PacketEncryptionRequest(this.serverId, this.server.getKeyPair().getPublic(), this.field_147330_e). It carries the server's DER-encoded RSA public key, a random 4-byte verify token, and a server id that is empty in 1.8.9 because authentication hashes the key material itself. Receiving it is the client's first proof that the server runs online mode; offline-mode servers skip encryption and go straight to S02PacketLoginSuccess.

Vanilla handling

NetHandlerLoginClient.handleEncryptionRequest generates a fresh AES secret (CryptManager.createNewSharedKey()), computes the server-hash sha1(serverId + DER key + secret) as a hex BigInteger, and calls the session service's joinServer with the profile, token, and hash. On success it replies with C01PacketEncryptionResponse(secret, key, token) and, via the packet's GenericFutureListener, calls networkManager.enableEncryption(secret) so the stream switches to AES/CFB8 on flush. Failure paths close the channel with disconnect.loginFailedInfo variants.

Why clients touch it

No module in the original 8 clients references it; their full corpus for S01PacketEncryptionRequest is vanilla login plumbing: NetHandlerLoginClient, EnumConnectionState registration, INetHandlerLoginClient, the packet class, and NetHandlerLoginServer. LiquidSense Dev breaks that: MixinNetHandlerLoginClient intercepts handleEncryptionRequest and, when an MCLeaks alt session is active, replaces the Mojang session-server join with the mcleaks.net join-server API, then completes the handshake through ClientUtils.sendEncryption. November Recode 2.0 ships the stock handler with no corpus hit, consistent with a vanilla login path.

Exploit surface

The crypto handshake is where session security lives, and it is unauthenticated: 1.8.9 validates neither the certificate chain nor key size, so a MITM proxy that terminates TLS and re-encrypts with its own key can read and rewrite everything, including harvesting the joinServer call. The verify token exists to prove the server holds the private key matching the public key it sent; a proxy must replay it. Server-side, a malicious server can only force a client to do a session-server round trip per join. No client-side abuse is present in the corpus. No client-side abuse is present in the original 8 clients; LiquidSense Dev's MCLeaks integration is the one client-side alteration, substituting the mcleaks.net auth endpoint for the Mojang session server on alt sessions.

Server-Side Handling

NetHandlerLoginServer.func_147326_c runs the handshake: if the server is online-mode and the connection is not already local, it stores the verify token and sends S01PacketEncryptionRequest. The login state has a timeout; a client that never answers with C01PacketEncryptionResponse is dropped by the network read timeout. After processing the response, the server decrypts with its private key, verifies the token, joins the session server with the hashed server id, and only then proceeds to compression and S02PacketLoginSuccess.

Protocol Analysis

Wire layout: String serverId, then VarInt length + RSA public key bytes (X.509 DER), then VarInt length + verify token bytes (4 random bytes). The client's reply C01PacketEncryptionResponse carries the same key and token encrypted with the server's public key plus the AES secret encrypted the same way. Encryption starts after the response flushes, so the first encrypted frame is the next packet after C01. Compression, when enabled, is negotiated separately in login state via S03PacketEnableCompression.

Anti-Cheat Landscape

None. This packet predates world state and is identical for every legitimate client; the only players here are the session server and the Mojang account backend. For cracked servers the whole exchange disappears. The realistic threat model is impersonation of the server (unvalidated public key), which is a network-level problem, not a module-level one.

implementation Implementation Cases

The LOGIN-state encryption challenge. Zero module hits in the original 8 clients; LiquidSense Dev instruments the handshake for MCLeaks alt accounts (MixinNetHandlerLoginClient plus ClientUtils.sendEncryption), and November Recode 2.0 has no corpus hit. Online-mode detection in the other clients is implicit (the packet simply never arrives on cracked servers) and happens in the vanilla handler, not in module code.

MixinNetHandlerLoginClient (MCLeaks login) (LiquidSense Dev)

Authenticate MCLeaks alt sessions during the login handshake by substituting the mcleaks.net join-server API for the Mojang session server.

@Inject on handleEncryptionRequest HEAD, cancellable, active only when MCLeaks.isAltActive(): generate a fresh AES secret, compute the server hash from serverId + public key + secret, POST {session, mcname, serverhash, server} to https://auth.mcleaks.net/v1/joinserver, close the channel on any failure, and on success call ClientUtils.sendEncryption and cancel the vanilla handler.

Source: LiquidSense Dev, net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerLoginClient.java

Vanilla hook: @Inject on NetHandlerLoginClient.handleEncryptionRequest; networkManager.closeChannel for failures.
Server-side this looks like a normal online-mode login because the S01/C01 exchange still happens; only the auth backend differs. Cracked servers never see it because they skip encryption entirely.
Variations: Part of the MCLeaks (mcleaks.net) integration; the sendEncryption step is factored into ClientUtils.
ClientUtils (sendEncryption helper) (LiquidSense Dev)

Send the C01PacketEncryptionResponse and enable AES stream encryption after the S01 challenge is handled.

sendEncryption(networkManager, secretKey, publicKey, encryptionRequest) builds C01PacketEncryptionResponse(secretKey, publicKey, encryptionRequest.getVerifyToken()) and sends it with a GenericFutureListener that calls networkManager.enableEncryption(secretKey) on completion, mirroring the vanilla handler's flow.

Source: LiquidSense Dev, net/ccbluex/liquidbounce/utils/ClientUtils.java

Vanilla hook: Called from MixinNetHandlerLoginClient; networkManager.sendPacket plus GenericFutureListener.
None; this is the vanilla-compatible encryption continuation. It exists so the mixin path and any future callers share one code path.
Variations: ClientUtils also hosts the logger, fast-render toggle and chat helpers used across LiquidBounce.
The original 8 clients ship the stock 1.8.9 NetHandlerLoginClient unchanged, and so does November Recode 2.0 per its corpus. LiquidSense Dev replaces the join flow only for MCLeaks alt sessions, keeping the vanilla path for real accounts. Rise 6.x renames the fields (verifyToken instead of field_147330_e) but the behavior is identical: same shared-secret generation, same joinServer call, same enableEncryption-on-flush listener.

anticheat Anti-Cheat Checks

The login encryption challenge is the least instrumented packet in this set: exactly one anticheat references it, and only as packet-library plumbing. Artemis maps SERVER_LOGIN + 2 to PacketLoginOutEncryptionBegin so login-state traffic is typed; no anticheat validates the RSA handshake, because the exchange is identical for every legitimate client and predates world state.

Login packet registration (Artemis) (artemisac-artemis-minecraft-anticheat)

Registers the encryption-request packet in Artemis's packet repository so the login-state stream is typed and readable.

PacketRepository puts SERVER_LOGIN + 2 at PacketLoginOutEncryptionBegin.class and the PacketLoginOutEncryptionBegin interface extends PacketServer. The interface is the full extent of Artemis's interest: no wrapper class and no check subscribes to the packet.

Detects: None. This is registry plumbing for a packet that arrives before any check-relevant state exists.

Source: artemisac-artemis-minecraft-anticheat, ac.artemis.packet.api/src/main/java/ac/artemis/packet/wrapper/server/PacketLoginOutEncryptionBegin.java

Variations: The other 49 anticheats in the corpus never reference the packet by name or by PacketLoginOutEncryptionBegin. Login-state traffic is outside every check domain.

Wiki Cross-Reference

LOGIN id 0x01: String serverId (empty in 1.8.9), VarInt length plus DER RSA public key, then 4-byte verify token challenge.

Client answers with C01 carrying AES secret plus token encrypted under server key, then enables AES/CFB8 stream on flush.

MCP 1.8.9 S01PacketEncryptionRequest implements Packet dispatching to INetHandlerLoginClient.handleEncryptionRequest; wire serde is readPacketData/writePacketData via readByteArray, readStringFromBuffer.

1.8.9 callers: NetHandlerLoginServer.processLoginStart sends new S01PacketEncryptionRequest (line 164): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java

Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.

Vanilla Internals

Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.