C# Класс OpenStory.Cryptography.EndpointCrypto

Represents a base class for cryptographic packet transformation.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Client ( RollingIvFactory factory, byte clientIv, byte serverIv ) : EndpointCrypto

Creates a new instance of the EndpointCrypto class used for client-side cryptography.

Encryption uses the local IV, decryption uses the remote IV. Server's local IV has flipped version, Client's local IV has regular version.

Decrypt ( byte packet ) : void

Decrypts the given packet in-place.

The array will be modified directly.

EncryptAndPack ( byte packetData ) : byte[]

Encrypts a packet, constructs a header for it and packs them into a new array.

The array given as the packetData parameter is transformed in-place.

Server ( RollingIvFactory factory, byte clientIv, byte serverIv ) : EndpointCrypto

Creates a new instance of the EndpointCrypto class used for server-side cryptography.

Encryption uses the local IV, decryption uses the remote IV. Server's local IV has flipped version, Client's local IV has regular version.

TryGetLength ( byte header, int &length ) : bool

Attempts to extract the length of a packet from its header.

When overriding this method in a derived class, do not call the base implementation.

TryUnpackAndDecrypt ( byte rawData, byte &decryptedData ) : bool

Attempts to unpack the packet data from the given array and decrypt it.

This method will return if and only if the header was invalid.

Приватные методы

Метод Описание
ConstructHeader ( int length ) : byte[]

Constructs a packet header and encodes the given length in it.

When overriding this method in a derived class, do not call the base implementation.

EndpointCrypto ( RollingIv encryptor, RollingIv decryptor ) : System

Initializes a new instance of the EndpointCrypto class.

Описание методов

Client() публичный статический Метод

Creates a new instance of the EndpointCrypto class used for client-side cryptography.
Encryption uses the local IV, decryption uses the remote IV. Server's local IV has flipped version, Client's local IV has regular version.
public static Client ( RollingIvFactory factory, byte clientIv, byte serverIv ) : EndpointCrypto
factory RollingIvFactory The instance to use.
clientIv byte The IV for the client.
serverIv byte The IV for the server.
Результат EndpointCrypto

Decrypt() публичный Метод

Decrypts the given packet in-place.
The array will be modified directly.
public Decrypt ( byte packet ) : void
packet byte The data to decrypt.
Результат void

EncryptAndPack() публичный Метод

Encrypts a packet, constructs a header for it and packs them into a new array.
The array given as the packetData parameter is transformed in-place.
/// Thrown if is . ///
public EncryptAndPack ( byte packetData ) : byte[]
packetData byte The packet data to encrypt and pack.
Результат byte[]

Server() публичный статический Метод

Creates a new instance of the EndpointCrypto class used for server-side cryptography.
Encryption uses the local IV, decryption uses the remote IV. Server's local IV has flipped version, Client's local IV has regular version.
public static Server ( RollingIvFactory factory, byte clientIv, byte serverIv ) : EndpointCrypto
factory RollingIvFactory The instance to use.
clientIv byte The IV for the client.
serverIv byte The IV for the server.
Результат EndpointCrypto

TryGetLength() публичный Метод

Attempts to extract the length of a packet from its header.
When overriding this method in a derived class, do not call the base implementation.
public TryGetLength ( byte header, int &length ) : bool
header byte The header byte array to process.
length int A variable to hold the result.
Результат bool

TryUnpackAndDecrypt() публичный Метод

Attempts to unpack the packet data from the given array and decrypt it.
This method will return if and only if the header was invalid.
Thrown if is .
public TryUnpackAndDecrypt ( byte rawData, byte &decryptedData ) : bool
rawData byte The raw packet data.
decryptedData byte A reference to hold the decrypted data.
Результат bool