Property | Type | Description | |
---|---|---|---|
AsyncResult | AsyncResult | ||
CryptoProvide | byte[] | ||
CryptoSelect | byte[] | ||
InitialPayload | byte[] | ||
PadC | byte[] | ||
PadD | byte[] | ||
RemoteInitialPayload | byte[] | ||
S | byte[] | ||
Skey | InfoHash | ||
VerificationConstant | byte[] |
Method | Description | |
---|---|---|
AddPayload ( byte buffer ) : void | ||
AddPayload ( byte buffer, int offset, int count ) : void | ||
BeginHandshake ( IConnection socket, AsyncCallback callback, object state ) : IAsyncResult |
Begins the message stream encryption handshaking process
|
|
BeginHandshake ( IConnection socket, byte initialBuffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult |
Begins the message stream encryption handshaking process, beginning with some data already received from the socket.
|
|
Decrypt ( byte data, int offset, int length ) : void |
Decrypts some data (should only be called after onEncryptorReady)
|
|
Encrypt ( byte data, int offset, int length ) : void |
Encrypts some data (should only be called after onEncryptorReady)
|
|
EncryptedSocket ( EncryptionTypes allowedEncryption ) : System | ||
EndHandshake ( IAsyncResult result ) : void |
Method | Description | |
---|---|---|
Combine ( ) : byte[] |
Concatenates several byte buffers
|
|
CreateCryptors ( string encryptionSalt, string decryptionSalt ) : void |
Instantiate the cryptors with the keys: Hash(encryptionSalt, S, SKEY) for the encryptor and Hash(encryptionSalt, S, SKEY) for the decryptor. (encryptionSalt should be "keyA" if you're A, "keyB" if you're B, and reverse for decryptionSalt)
|
|
DeLen ( byte data ) : int |
Converts a 2-byte big endian integer into an int (reverses operation of Len())
|
|
DoDecrypt ( byte data ) : byte[] |
Decrypts some data with the RC4 encryptor used in handshaking
|
|
DoDecrypt ( byte data, int offset, int length ) : void |
Decrypts some data with the RC4 decryptor used in handshaking
|
|
DoEncrypt ( byte data ) : byte[] | ||
DoEncrypt ( byte data, int offset, int length ) : void |
Encrypts some data with the RC4 encryptor used in handshaking
|
|
DoneReceiveY ( ) : void | ||
DoneSynchronize ( ) : void | ||
FillSynchronizeBytes ( bool succeeded, int count, object state ) : void | ||
GeneratePad ( ) : byte[] |
Returns a 0 to 512 byte 0-filled pad.
|
|
Hash ( ) : byte[] |
Hash some data with SHA1
|
|
Len ( byte data ) : byte[] |
Returns a 2-byte buffer with the length of data
|
|
Ready ( ) : void |
Signal that the cryptor is now in a state ready to encrypt and decrypt payload data
|
|
ReceiveMessage ( byte buffer, int length, AsyncCallback callback ) : void | ||
ReceiveY ( ) : void |
Receive the first 768 bits of the transmission from the remote client, which is Y in the protocol (Either "1 A->B: Diffie Hellman Ya, PadA" or "2 B->A: Diffie Hellman Yb, PadB")
|
|
SelectCrypto ( byte remoteCryptoBytes, bool replace ) : int |
Sets CryptoSelect and initializes the stream encryptor and decryptor based on the selected method.
|
|
SendMessage ( byte toSend ) : void | ||
SendY ( ) : void |
Send Y to the remote client, with a random padding that is 0 to 512 bytes long (Either "1 A->B: Diffie Hellman Ya, PadA" or "2 B->A: Diffie Hellman Yb, PadB")
|
|
SetMinCryptoAllowed ( EncryptionTypes allowedEncryption ) : void | ||
Synchronize ( byte syncData, int syncStopPoint ) : void |
Read data from the socket until the byte string in syncData is read, or until syncStopPoint is reached (in that case, there is an EncryptionError). (Either "3 A->B: HASH('req1', S)" or "4 B->A: ENCRYPT(VC)")
|
Method | Description | |
---|---|---|
DoneReceive ( bool succeeded, int count, object state ) : void | ||
DoneSend ( bool succeeded, int count, object state ) : void | ||
GenerateX ( ) : void |
Generate a 160 bit random number for X
|
|
GenerateY ( ) : void |
Calculate 2^X mod P
|
|
RandomNumber ( int max ) : int |
public AddPayload ( byte buffer, int offset, int count ) : void | ||
buffer | byte | |
offset | int | |
count | int | |
return | void |
public BeginHandshake ( IConnection socket, AsyncCallback callback, object state ) : IAsyncResult | ||
socket | IConnection | The socket to perform handshaking with |
callback | AsyncCallback | The callback. |
state | object | The state. |
return | IAsyncResult |
public BeginHandshake ( IConnection socket, byte initialBuffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult | ||
socket | IConnection | The socket to perform handshaking with |
initialBuffer | byte | Buffer containing soome data already received from the socket |
offset | int | Offset to begin reading in initialBuffer |
count | int | Number of bytes to read from initialBuffer |
callback | AsyncCallback | The callback. |
state | object | The state. |
return | IAsyncResult |
protected CreateCryptors ( string encryptionSalt, string decryptionSalt ) : void | ||
encryptionSalt | string | The salt to calculate the encryption key with |
decryptionSalt | string | The salt to calculate the decryption key with |
return | void |
public Decrypt ( byte data, int offset, int length ) : void | ||
data | byte | The data. |
offset | int | Offset to begin decryption |
length | int | The length. |
return | void |
protected DoDecrypt ( byte data ) : byte[] | ||
data | byte | Buffers with the data to decrypt |
return | byte[] |
protected DoDecrypt ( byte data, int offset, int length ) : void | ||
data | byte | The data. |
offset | int | Offset to begin decryption |
length | int | The length. |
return | void |
protected DoEncrypt ( byte data, int offset, int length ) : void | ||
data | byte | The data. |
offset | int | Offset to begin encryption |
length | int | The length. |
return | void |
public Encrypt ( byte data, int offset, int length ) : void | ||
data | byte | The data. |
offset | int | Offset to begin encryption |
length | int | The length. |
return | void |
public EncryptedSocket ( EncryptionTypes allowedEncryption ) : System | ||
allowedEncryption | EncryptionTypes | |
return | System |
public EndHandshake ( IAsyncResult result ) : void | ||
result | IAsyncResult | |
return | void |
protected FillSynchronizeBytes ( bool succeeded, int count, object state ) : void | ||
succeeded | bool | |
count | int | |
state | object | |
return | void |
protected ReceiveMessage ( byte buffer, int length, AsyncCallback callback ) : void | ||
buffer | byte | |
length | int | |
callback | AsyncCallback | |
return | void |
protected SelectCrypto ( byte remoteCryptoBytes, bool replace ) : int | ||
remoteCryptoBytes | byte | /// The cryptographic methods supported/wanted by the remote client in CryptoProvide /// format. The highest order one available will be selected /// |
replace | bool | if set to |
return | int |
protected SetMinCryptoAllowed ( EncryptionTypes allowedEncryption ) : void | ||
allowedEncryption | EncryptionTypes | |
return | void |
protected Synchronize ( byte syncData, int syncStopPoint ) : void | ||
syncData | byte | Buffer with the data to synchronize to |
syncStopPoint | int | /// Maximum number of bytes (measured from the total received from the socket since connection) /// to read before giving up /// |
return | void |