C# Class OpenStory.Cryptography.EndpointCrypto

Represents a base class for cryptographic packet transformation.
Afficher le fichier Open project: shoftee/OpenStory Class Usage Examples

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
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.

Method Details

Client() public static méthode

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.
Résultat EndpointCrypto

Decrypt() public méthode

Decrypts the given packet in-place.
The array will be modified directly.
public Decrypt ( byte packet ) : void
packet byte The data to decrypt.
Résultat void

EncryptAndPack() public méthode

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.
Résultat byte[]

Server() public static méthode

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.
Résultat EndpointCrypto

TryGetLength() public méthode

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.
Résultat bool

TryUnpackAndDecrypt() public méthode

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.
Résultat bool