eolib 0.5.0
A core C library for writing applications related to Endless Online
Loading...
Searching...
No Matches
encrypt.c File Reference
#include "eolib/data.h"
#include "eolib/encrypt.h"
#include "eolib/rng.h"

Go to the source code of this file.

Functions

int32_t eo_server_verification_hash (int32_t challenge)
void eo_swap_multiples (uint8_t *data, size_t length, uint8_t multiple)
uint8_t eo_generate_swap_multiple ()
void eo_encrypt_packet (uint8_t *data, size_t length, uint8_t swap_multiple)
void eo_decrypt_packet (uint8_t *data, size_t length, uint8_t swap_multiple)

Function Documentation

◆ eo_decrypt_packet()

void eo_decrypt_packet ( uint8_t * data,
size_t length,
uint8_t swap_multiple )

Decrypts a packet in place using the specified swap multiple.

Parameters
dataThe packet data to decrypt.
lengthNumber of bytes in data.
swap_multipleThe swap multiple for the packet.

Definition at line 114 of file encrypt.c.

◆ eo_encrypt_packet()

void eo_encrypt_packet ( uint8_t * data,
size_t length,
uint8_t swap_multiple )

Encrypts a packet in place using the specified swap multiple.

Parameters
dataThe packet data to encrypt.
lengthNumber of bytes in data.
swap_multipleThe swap multiple for the packet.

Definition at line 58 of file encrypt.c.

◆ eo_generate_swap_multiple()

uint8_t eo_generate_swap_multiple ( )

Generates a cryptographically random swap multiple between 6 and 12 inclusive.

Returns
The generated swap multiple.

Definition at line 53 of file encrypt.c.

◆ eo_server_verification_hash()

int32_t eo_server_verification_hash ( int32_t challenge)

Calculates the server verification hash for the given challenge value.

Parameters
challengeThe server challenge value (from ServerInitInitServerPacket).
Returns
The verification hash to be sent back to the server.
Remarks
Implements the EO protocol challenge-response formula: hash = 110905 + ((c%9)+1) * ((11092004-c) % (((c%11)+1)*119)) * 119 + (c%2004) where c = challenge + 1. The constants are protocol-defined magic values.

Definition at line 5 of file encrypt.c.

◆ eo_swap_multiples()

void eo_swap_multiples ( uint8_t * data,
size_t length,
uint8_t multiple )

Reverses contiguous sequences of bytes where each value is a multiple of multiple.

Parameters
dataThe packet data to mutate.
lengthNumber of bytes in data.
multipleThe divisor used to determine which bytes are in a sequence.

Definition at line 12 of file encrypt.c.