Unit EOLib.Encrypt

Uses
Classes, Interfaces, Objects and Records
Types
Constants
Variables

Description

Utilities to handle EO data encryption.

Overview

Functions and Procedures

procedure Interleave(var Data: TArray<Byte>);
procedure Deinterleave(var Data: TArray<Byte>);
procedure FlipMsb(var Data: TArray<Byte>);
procedure SwapMultiples(var Data: TArray<Byte>; Multiple: Cardinal);
function ServerVerificationHash(Challenge: Cardinal): Integer;

Description

Functions and Procedures

procedure Interleave(var Data: TArray<Byte>);

Interleaves a sequence of bytes. When encrypting EO data, bytes are "woven" into each other.
Used when encrypting packets and data files.

Example:

[0, 1, 2, 3, 4, 5] → [0, 5, 1, 4, 2, 3]

This is an in-place operation.

Parameters
Data
The data to interleave
procedure Deinterleave(var Data: TArray<Byte>);

Deinterleaves a sequence of bytes. This is the reverse of Interleave.
Used when decrypting packets and data files.

Example:

[0, 1, 2, 3, 4, 5] → [0, 2, 4, 5, 3, 1]

This is an in-place operation.

Parameters
Data
The data to deinterleave
procedure FlipMsb(var Data: TArray<Byte>);

Flips the most significant bits of each byte in a sequence of bytes. (Values 0 and 128 are not flipped.)
Used when encrypting and decrypting packets.

Example:

[0, 1, 127, 128, 129, 254, 255] → [0, 129, 255, 128, 1, 126, 127]

This is an in-place operation.

Parameters
Data
The data to flip most significant bits on
procedure SwapMultiples(var Data: TArray<Byte>; Multiple: Cardinal);

Swaps the order of contiguous bytes in a sequence of bytes that are divisible by a given multiple value.
Used when encrypting and decrypting packets and data files.

Example:

Multiple := 3
[10, 21, 27] → [10, 27, 21]

This is an in-place operation.

Parameters
Data
The data to swap bytes in
Multiple
The multiple value
function ServerVerificationHash(Challenge: Cardinal): Integer;

This hash function is how the game client checks that it's communicating with a genuine server during connection initialization.

  • The client sends an integer value to the server in the INIT_INIT client packet, where it is referred to as the Challenge.

  • The server hashes the value and sends the hash back in the INIT_INIT server packet.

  • The client hashes the value and compares it to the hash sent by the server.

  • If the hashes don't match, the client drops the connection.

Warning
Oversized challenges may result in negative hash values, which cannot be represented properly in the EO protocol.

Parameters
Challenge
The challenge value sent by the client. Should be no larger than 11,092,110
Returns

The hashed challenge value


Generated by PasDoc 0.16.0-snapshot.