C# Class OpenStory.Cryptography.RollingIv

Represents an AES encryption transformer.
Datei anzeigen Open project: shoftee/OpenStory Class Usage Examples

Public Methods

Method Description
ConstructHeader ( int length ) : byte[]

Constructs a packet header.

GetPacketLength ( byte header ) : int

Reads a packet header from an array and extracts the packet's length.

GetVersion ( byte header, byte iv ) : ushort

Extracts a version from the header using a specified IV.

RollingIv ( ICryptoAlgorithm algorithm, byte initialIv, ushort versionMask ) : System

Initializes a new instance of the RollingIv class.

Transform ( byte data ) : void

Transforms the specified data in-place.

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.

ValidateHeader ( byte header ) : bool

Determines whether the start of an array is a valid packet header.

Private Methods

Method Description
GetVersionInternal ( byte header, byte iv ) : ushort
ValidateHeaderInternal ( byte header, byte iv, ushort versionMask ) : bool

Method Details

ConstructHeader() public method

Constructs a packet header.
/// Thrown if is less than 2. ///
public ConstructHeader ( int length ) : byte[]
length int The length of the packet to make a header for.
return byte[]

GetPacketLength() public static method

Reads a packet header from an array and extracts the packet's length.
/// Thrown if is . /// /// Thrown if has less than 4 elements. ///
public static GetPacketLength ( byte header ) : int
header byte The array to read from.
return int

GetVersion() public static method

Extracts a version from the header using a specified IV.
/// Thrown if /// or are . /// /// Thrown if has less than 4 elements or /// if doesn't have exactly 4 elements. ///
public static GetVersion ( byte header, byte iv ) : ushort
header byte The header byte array.
iv byte The IV to use for the decoding.
return ushort

RollingIv() public method

Initializes a new instance of the RollingIv class.
/// Thrown if or is . /// /// Thrown if does not have exactly 4 elements. ///
public RollingIv ( ICryptoAlgorithm algorithm, byte initialIv, ushort versionMask ) : System
algorithm ICryptoAlgorithm The instance for this session.
initialIv byte The initial IV for this instance.
versionMask ushort The version mask used for header creation.
return System

Transform() public method

Transforms the specified data in-place.
Thrown if is .
public Transform ( byte data ) : void
data byte The array to transform. This array will be directly modified.
return void

TryGetLength() public method

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.
/// Thrown if is . /// /// Thrown if has less than 4 elements. ///
public TryGetLength ( byte header, int &length ) : bool
header byte The header byte array to process.
length int A variable to hold the result.
return bool

ValidateHeader() public method

Determines whether the start of an array is a valid packet header.
public ValidateHeader ( byte header ) : bool
header byte The raw packet data to validate.
return bool