Documentation

EncryptionContext
in package

Table of Contents

CHECKSUM_ALGO  = "sha256"
$ENABLED  : bool
$decryptCipher  : Cipher
$decryptCounter  : int
$encryptCipher  : Cipher
$encryptCounter  : int
$key  : string
__construct()  : mixed
cfb8()  : self
decrypt()  : string
encrypt()  : string
fakeGCM()  : self
Returns an EncryptionContext suitable for decrypting Minecraft packets from 1.16.200 and up.
calculateChecksum()  : string

Constants

Properties

Methods

__construct()

public __construct(string $encryptionKey, string $algorithm, string $iv) : mixed
Parameters
$encryptionKey : string
$algorithm : string
$iv : string
Return values
mixed

cfb8()

public static cfb8(string $encryptionKey) : self
Parameters
$encryptionKey : string
Return values
self

encrypt()

public encrypt(string $payload) : string
Parameters
$payload : string
Return values
string

fakeGCM()

Returns an EncryptionContext suitable for decrypting Minecraft packets from 1.16.200 and up.

public static fakeGCM(string $encryptionKey) : self

MCPE uses GCM, but without the auth tag, which defeats the whole purpose of using GCM. GCM is just a wrapper around CTR which adds the auth tag, so CTR can replace GCM for this case. However, since GCM passes only the first 12 bytes of the IV followed by 0002, we must do the same for compatibility with MCPE. In PM, we could skip this and just use GCM directly (since we use OpenSSL), but this way is more portable, and better for developers who come digging in the PM code looking for answers.

Parameters
$encryptionKey : string
Return values
self

calculateChecksum()

private calculateChecksum(int $counter, string $payload) : string
Parameters
$counter : int
$payload : string
Return values
string

Search results