Class NLS
Supports the New Logon System's SRP (Secure Remote Password) authentication system as well as Warcraft III server signature validation. This class cannot be inherited.
Inheritance
Inherited Members
Namespace: MBNCSUtil
Assembly: MBNCSUtil.dll
Syntax
public sealed class NLS
Remarks
This class does not monitor contexts to ensure that its values are being modified in the appropriate sequence; the NLS authorization scheme is left up to the consumer.
Constructors
| Improve this Doc View SourceNLS(String, String)
Creates a new NLS login context.
Declaration
public NLS(string Username, string Password)
Parameters
Type | Name | Description |
---|---|---|
System.String | Username | The username to use for authentication. |
System.String | Password | The password to use for authentication. |
Remarks
This type does not validate the sequence from moving from one message to the next. Ensure that you have the correct sequence of calls.
Fields
| Improve this Doc View SourceGenerator
The generator value used for login calculations.
Declaration
public const int Generator = 47
Field Value
Type | Description |
---|---|
System.Int32 |
Modulus
The modulus value used for login calculations.
Declaration
public const string Modulus = "F8FF1A8B619918032186B68CA092B5557E976C78C73212D91216F6658523C787"
Field Value
Type | Description |
---|---|
System.String |
ServerModulus
The modulus used to calculate the server IP signature.
Declaration
public const string ServerModulus = "cf8d697fbac28db6fd9d54cc4140edc296785157e7bdf52db032d940668e16ea76348a8e6932844120d38a085e3df42a98dd00c2e4fc26fdf425d34d2dc582d020a606a1d577e1c973b8f3cb9e430788fc395a150b480f293556ba2dfcc1e5dcb556b58f0ecd3b3aa1b41942e820fab032e30b9d786efac30fc50d0fabd6a3d5 "
Field Value
Type | Description |
---|---|
System.String |
SignatureKey
The four-byte RSA server signature key used to decrypt the server signatures.
Declaration
public const int SignatureKey = 65537
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceCreateAccount(BncsPacket)
Adds the account creation information (for SID_AUTH_ACCOUNTCREATE) to the specified packet.
Declaration
public int CreateAccount(BncsPacket acctPacket)
Parameters
Type | Name | Description |
---|---|---|
BncsPacket | acctPacket | The packet to which to add the account creation information. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
This method must be called first if you are creating a new account.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
CreateAccount(Byte[], Int32, Int32)
Adds the account creation information (for SID_AUTH_ACCOUNTCREATE) to the specified buffer at the specified location.
Declaration
public int CreateAccount(byte[] buffer, int startIndex, int totalLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer to modify. |
System.Int32 | startIndex | The starting index at which to modify the buffer. |
System.Int32 | totalLength | The total number of bytes from the starting index of the buffer that may be modified. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
The writeable length of the stream must be at least 65 bytes plus the length of the user name.
This method must be called first if you are creating a new account.
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Thrown if the buffer does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
CreateAccount(Stream)
Adds the account creation information (for SID_AUTH_ACCOUNTCREATE) to the specified stream at the current location.
Declaration
public int CreateAccount(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to modify. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the stream. |
Remarks
The writeable length of the stream must be at least 65 bytes plus the length of the user name.
This method must be called first if you are creating a new account.
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Thrown if the stream does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginAccount(BncsPacket)
Adds the account login information (for SID_AUTH_ACCOUNTLOGON) to the specified packet.
Declaration
public int LoginAccount(BncsPacket loginPacket)
Parameters
Type | Name | Description |
---|---|---|
BncsPacket | loginPacket | The packet to which to add the login information. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
This method may be called first after creating the instance, or after the CreateAccount method.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginAccount(Byte[], Int32, Int32)
Adds the account login information (for SID_AUTH_ACCOUNTLOGON) to the specified buffer at the specified location.
Declaration
public int LoginAccount(byte[] buffer, int startIndex, int totalLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer to modify. |
System.Int32 | startIndex | The starting index at which to modify the buffer. |
System.Int32 | totalLength | The total number of bytes from the starting index of the buffer that may be modified. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
The writeable length of the stream must be at least 33 bytes plus the length of the username.
This method may be called first after creating the instance, or after the CreateAccount method.
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Thrown if the buffer does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginAccount(Stream)
Adds the account login information (for SID_AUTH_ACCOUNTLOGON) to the specified stream at the current location.
Declaration
public int LoginAccount(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to modify. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the stream. |
Remarks
The writeable length of the stream must be at least 33 bytes plus the length of the username.
This method may be called first after creating the instance, or after the CreateAccount method.
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Thrown if the stream does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginProof(BncsPacket, Byte[], Byte[])
Adds the account login proof (for SID_AUTH_ACCOUNTLOGONPROOF) to the specified packet.
Declaration
public int LoginProof(BncsPacket logonProofPacket, byte[] salt, byte[] serverKey)
Parameters
Type | Name | Description |
---|---|---|
BncsPacket | logonProofPacket | The BNCS packet to which to add the account logon data. |
System.Byte[] | salt | The salt value, sent from the server in SID_AUTH_ACCOUNTLOGON. |
System.Byte[] | serverKey | The server key, sent from the server in SID_AUTH_ACCOUNTLOGON. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
This method should be called after the LoginAccount method.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the salt or server key values are not exactly 32 bytes. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginProof(Byte[], Int32, Int32, Byte[], Byte[])
Adds the account login proof (for SID_AUTH_ACCOUNTLOGONPROOF) to the specified buffer at the specified location.
Declaration
public int LoginProof(byte[] buffer, int startIndex, int totalLength, byte[] salt, byte[] serverKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer to modify. |
System.Int32 | startIndex | The starting index at which to modify the buffer. |
System.Int32 | totalLength | The total number of bytes from the starting index of the buffer that may be modified. |
System.Byte[] | salt | The salt value, sent from the server in SID_AUTH_ACCOUNTLOGON. |
System.Byte[] | serverKey | The server key, sent from the server in SID_AUTH_ACCOUNTLOGON. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
The writeable length of the buffer must be at least 20 bytes.
This method should be called after the LoginAccount method.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the salt or server key values are not exactly 32 bytes. |
System.IO.IOException | Thrown if the buffer does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
LoginProof(Stream, Byte[], Byte[])
Adds the account login proof (for SID_AUTH_ACCOUNTLOGONPROOF) to the specified stream at the current location.
Declaration
public int LoginProof(Stream stream, byte[] salt, byte[] serverKey)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to modify. |
System.Byte[] | salt | The salt value, sent from the server in SID_AUTH_ACCOUNTLOGON. |
System.Byte[] | serverKey | The server key, sent from the server in SID_AUTH_ACCOUNTLOGON. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes written to the buffer. |
Remarks
The writeable length of the stream must be at least 20 bytes.
This method should be called after the LoginAccount method.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the salt or server key values are not exactly 32 bytes. |
System.IO.IOException | Thrown if the buffer does not have enough space to add the account creation information. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |
ValidateServerSignature(Byte[], Byte[])
Validates a Warcraft III server signature.
Declaration
public static bool ValidateServerSignature(byte[] serverSignature, byte[] ipAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | serverSignature | The server signature from Battle.net's SID_AUTH_INFO message. |
System.Byte[] | ipAddress | The IPv4 address of the server currently connected-to. |
Returns
Type | Description |
---|---|
System.Boolean | True if the signature matches; otherwise false. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the server signature is not exactly 128 bytes. |
VerifyServerProof(Byte[])
Verifies that the server's proof value matches the value calculated by the client.
Declaration
public bool VerifyServerProof(byte[] serverProof)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | serverProof | The 20-byte server proof. |
Returns
Type | Description |
---|---|
System.Boolean | True if the server proof is valid; otherwise false. |
Remarks
This method should be called after the LoginProof method.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the server proof value is not exactly 20 bytes. |
System.InvalidOperationException | Thrown if the object has not yet been initialized. |