mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Merge 16008930d3 into 1697db9d7f
This commit is contained in:
commit
bc01ba9622
|
|
@ -17,7 +17,7 @@ namespace TLSharp.Core.Auth
|
||||||
|
|
||||||
public class Step1_PQRequest
|
public class Step1_PQRequest
|
||||||
{
|
{
|
||||||
private byte[] nonce;
|
private readonly byte[] nonce;
|
||||||
|
|
||||||
public Step1_PQRequest()
|
public Step1_PQRequest()
|
||||||
{
|
{
|
||||||
|
|
@ -52,33 +52,27 @@ namespace TLSharp.Core.Auth
|
||||||
const int responseConstructorNumber = 0x05162463;
|
const int responseConstructorNumber = 0x05162463;
|
||||||
var responseCode = binaryReader.ReadInt32();
|
var responseCode = binaryReader.ReadInt32();
|
||||||
if (responseCode != responseConstructorNumber)
|
if (responseCode != responseConstructorNumber)
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"invalid response code: {responseCode}");
|
throw new InvalidOperationException($"invalid response code: {responseCode}");
|
||||||
}
|
|
||||||
|
|
||||||
var nonceFromServer = binaryReader.ReadBytes(16);
|
var nonceFromServer = binaryReader.ReadBytes(16);
|
||||||
|
|
||||||
if (!nonceFromServer.SequenceEqual(nonce))
|
if (!nonceFromServer.SequenceEqual(nonce))
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid nonce from server");
|
throw new InvalidOperationException("invalid nonce from server");
|
||||||
}
|
|
||||||
|
|
||||||
var serverNonce = binaryReader.ReadBytes(16);
|
var serverNonce = binaryReader.ReadBytes(16);
|
||||||
|
|
||||||
byte[] pqbytes = Serializers.Bytes.read(binaryReader);
|
var pqbytes = Serializers.Bytes.read(binaryReader);
|
||||||
var pq = new BigInteger(1, pqbytes);
|
var pq = new BigInteger(1, pqbytes);
|
||||||
|
|
||||||
var vectorId = binaryReader.ReadInt32();
|
var vectorId = binaryReader.ReadInt32();
|
||||||
const int vectorConstructorNumber = 0x1cb5c415;
|
const int vectorConstructorNumber = 0x1cb5c415;
|
||||||
if (vectorId != vectorConstructorNumber)
|
if (vectorId != vectorConstructorNumber)
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Invalid vector constructor number {vectorId}");
|
throw new InvalidOperationException($"Invalid vector constructor number {vectorId}");
|
||||||
}
|
|
||||||
|
|
||||||
var fingerprintCount = binaryReader.ReadInt32();
|
var fingerprintCount = binaryReader.ReadInt32();
|
||||||
for (var i = 0; i < fingerprintCount; i++)
|
for (var i = 0; i < fingerprintCount; i++)
|
||||||
{
|
{
|
||||||
byte[] fingerprint = binaryReader.ReadBytes(8);
|
var fingerprint = binaryReader.ReadBytes(8);
|
||||||
fingerprints.Add(fingerprint);
|
fingerprints.Add(fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ namespace TLSharp.Core.Auth
|
||||||
|
|
||||||
byte[] reqDhParamsBytes;
|
byte[] reqDhParamsBytes;
|
||||||
|
|
||||||
using (MemoryStream pqInnerData = new MemoryStream(255))
|
using (var pqInnerData = new MemoryStream(255))
|
||||||
{
|
{
|
||||||
using (BinaryWriter pqInnerDataWriter = new BinaryWriter(pqInnerData))
|
using (var pqInnerDataWriter = new BinaryWriter(pqInnerData))
|
||||||
{
|
{
|
||||||
pqInnerDataWriter.Write(0x83c95aec); // pq_inner_data
|
pqInnerDataWriter.Write(0x83c95aec); // pq_inner_data
|
||||||
Serializers.Bytes.write(pqInnerDataWriter, pq.ToByteArrayUnsigned());
|
Serializers.Bytes.write(pqInnerDataWriter, pq.ToByteArrayUnsigned());
|
||||||
|
|
@ -45,10 +45,10 @@ namespace TLSharp.Core.Auth
|
||||||
|
|
||||||
byte[] ciphertext = null;
|
byte[] ciphertext = null;
|
||||||
byte[] targetFingerprint = null;
|
byte[] targetFingerprint = null;
|
||||||
foreach (byte[] fingerprint in fingerprints)
|
foreach (var fingerprint in fingerprints)
|
||||||
{
|
{
|
||||||
ciphertext = RSA.Encrypt(BitConverter.ToString(fingerprint).Replace("-", string.Empty),
|
ciphertext = RSA.Encrypt(BitConverter.ToString(fingerprint).Replace("-", string.Empty),
|
||||||
pqInnerData.GetBuffer(), 0, (int)pqInnerData.Position);
|
pqInnerData.GetBuffer(), 0, (int) pqInnerData.Position);
|
||||||
if (ciphertext != null)
|
if (ciphertext != null)
|
||||||
{
|
{
|
||||||
targetFingerprint = fingerprint;
|
targetFingerprint = fingerprint;
|
||||||
|
|
@ -57,14 +57,13 @@ namespace TLSharp.Core.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ciphertext == null)
|
if (ciphertext == null)
|
||||||
{
|
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
String.Format("not found valid key for fingerprints: {0}", String.Join(", ", fingerprints)));
|
string.Format("not found valid key for fingerprints: {0}",
|
||||||
}
|
string.Join(", ", fingerprints)));
|
||||||
|
|
||||||
using (MemoryStream reqDHParams = new MemoryStream(1024))
|
using (var reqDHParams = new MemoryStream(1024))
|
||||||
{
|
{
|
||||||
using (BinaryWriter reqDHParamsWriter = new BinaryWriter(reqDHParams))
|
using (var reqDHParamsWriter = new BinaryWriter(reqDHParams))
|
||||||
{
|
{
|
||||||
reqDHParamsWriter.Write(0xd712e4be); // req_dh_params
|
reqDHParamsWriter.Write(0xd712e4be); // req_dh_params
|
||||||
reqDHParamsWriter.Write(nonce);
|
reqDHParamsWriter.Write(nonce);
|
||||||
|
|
@ -86,24 +85,19 @@ namespace TLSharp.Core.Auth
|
||||||
{
|
{
|
||||||
byte[] encryptedAnswer;
|
byte[] encryptedAnswer;
|
||||||
|
|
||||||
using (MemoryStream responseStream = new MemoryStream(response, false))
|
using (var responseStream = new MemoryStream(response, false))
|
||||||
{
|
{
|
||||||
using (BinaryReader responseReader = new BinaryReader(responseStream))
|
using (var responseReader = new BinaryReader(responseStream))
|
||||||
{
|
{
|
||||||
uint responseCode = responseReader.ReadUInt32();
|
var responseCode = responseReader.ReadUInt32();
|
||||||
|
|
||||||
if (responseCode == 0x79cb045d)
|
if (responseCode == 0x79cb045d)
|
||||||
{
|
|
||||||
// server_DH_params_fail
|
|
||||||
throw new InvalidOperationException("server_DH_params_fail: TODO");
|
throw new InvalidOperationException("server_DH_params_fail: TODO");
|
||||||
}
|
|
||||||
|
|
||||||
if (responseCode != 0xd0e8075c)
|
if (responseCode != 0xd0e8075c)
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"invalid response code: {responseCode}");
|
throw new InvalidOperationException($"invalid response code: {responseCode}");
|
||||||
}
|
|
||||||
|
|
||||||
byte[] nonceFromServer = responseReader.ReadBytes(16);
|
var nonceFromServer = responseReader.ReadBytes(16);
|
||||||
|
|
||||||
// TODO:!
|
// TODO:!
|
||||||
/*
|
/*
|
||||||
|
|
@ -115,7 +109,7 @@ namespace TLSharp.Core.Auth
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
byte[] serverNonceFromServer = responseReader.ReadBytes(16);
|
var serverNonceFromServer = responseReader.ReadBytes(16);
|
||||||
|
|
||||||
// TODO: !
|
// TODO: !
|
||||||
/*
|
/*
|
||||||
|
|
@ -128,7 +122,7 @@ namespace TLSharp.Core.Auth
|
||||||
|
|
||||||
encryptedAnswer = Serializers.Bytes.read(responseReader);
|
encryptedAnswer = Serializers.Bytes.read(responseReader);
|
||||||
|
|
||||||
return new Step2_Response()
|
return new Step2_Response
|
||||||
{
|
{
|
||||||
EncryptedAnswer = encryptedAnswer,
|
EncryptedAnswer = encryptedAnswer,
|
||||||
ServerNonce = serverNonceFromServer,
|
ServerNonce = serverNonceFromServer,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ namespace TLSharp.Core.Auth
|
||||||
{
|
{
|
||||||
public AuthKey AuthKey { get; set; }
|
public AuthKey AuthKey { get; set; }
|
||||||
public int TimeOffset { get; set; }
|
public int TimeOffset { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Step3_CompleteDHExchange
|
public class Step3_CompleteDHExchange
|
||||||
|
|
@ -23,8 +22,8 @@ namespace TLSharp.Core.Auth
|
||||||
public byte[] ToBytes(byte[] nonce, byte[] serverNonce, byte[] newNonce, byte[] encryptedAnswer)
|
public byte[] ToBytes(byte[] nonce, byte[] serverNonce, byte[] newNonce, byte[] encryptedAnswer)
|
||||||
{
|
{
|
||||||
this.newNonce = newNonce;
|
this.newNonce = newNonce;
|
||||||
AESKeyData key = AES.GenerateKeyDataFromNonces(serverNonce, newNonce);
|
var key = AES.GenerateKeyDataFromNonces(serverNonce, newNonce);
|
||||||
byte[] plaintextAnswer = AES.DecryptAES(key, encryptedAnswer);
|
var plaintextAnswer = AES.DecryptAES(key, encryptedAnswer);
|
||||||
|
|
||||||
// logger.debug("plaintext answer: {0}", BitConverter.ToString(plaintextAnswer));
|
// logger.debug("plaintext answer: {0}", BitConverter.ToString(plaintextAnswer));
|
||||||
|
|
||||||
|
|
@ -32,32 +31,26 @@ namespace TLSharp.Core.Auth
|
||||||
BigInteger dhPrime;
|
BigInteger dhPrime;
|
||||||
BigInteger ga;
|
BigInteger ga;
|
||||||
|
|
||||||
using (MemoryStream dhInnerData = new MemoryStream(plaintextAnswer))
|
using (var dhInnerData = new MemoryStream(plaintextAnswer))
|
||||||
{
|
{
|
||||||
using (BinaryReader dhInnerDataReader = new BinaryReader(dhInnerData))
|
using (var dhInnerDataReader = new BinaryReader(dhInnerData))
|
||||||
{
|
{
|
||||||
byte[] hashsum = dhInnerDataReader.ReadBytes(20);
|
var hashsum = dhInnerDataReader.ReadBytes(20);
|
||||||
uint code = dhInnerDataReader.ReadUInt32();
|
var code = dhInnerDataReader.ReadUInt32();
|
||||||
if (code != 0xb5890dba)
|
if (code != 0xb5890dba)
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"invalid dh_inner_data code: {code}");
|
throw new InvalidOperationException($"invalid dh_inner_data code: {code}");
|
||||||
}
|
|
||||||
|
|
||||||
// logger.debug("valid code");
|
// logger.debug("valid code");
|
||||||
|
|
||||||
byte[] nonceFromServer1 = dhInnerDataReader.ReadBytes(16);
|
var nonceFromServer1 = dhInnerDataReader.ReadBytes(16);
|
||||||
if (!nonceFromServer1.SequenceEqual(nonce))
|
if (!nonceFromServer1.SequenceEqual(nonce))
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid nonce in encrypted answer");
|
throw new InvalidOperationException("invalid nonce in encrypted answer");
|
||||||
}
|
|
||||||
|
|
||||||
// logger.debug("valid nonce");
|
// logger.debug("valid nonce");
|
||||||
|
|
||||||
byte[] serverNonceFromServer1 = dhInnerDataReader.ReadBytes(16);
|
var serverNonceFromServer1 = dhInnerDataReader.ReadBytes(16);
|
||||||
if (!serverNonceFromServer1.SequenceEqual(serverNonce))
|
if (!serverNonceFromServer1.SequenceEqual(serverNonce))
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid server nonce in encrypted answer");
|
throw new InvalidOperationException("invalid server nonce in encrypted answer");
|
||||||
}
|
|
||||||
|
|
||||||
// logger.debug("valid server nonce");
|
// logger.debug("valid server nonce");
|
||||||
|
|
||||||
|
|
@ -65,39 +58,43 @@ namespace TLSharp.Core.Auth
|
||||||
dhPrime = new BigInteger(1, Serializers.Bytes.read(dhInnerDataReader));
|
dhPrime = new BigInteger(1, Serializers.Bytes.read(dhInnerDataReader));
|
||||||
ga = new BigInteger(1, Serializers.Bytes.read(dhInnerDataReader));
|
ga = new BigInteger(1, Serializers.Bytes.read(dhInnerDataReader));
|
||||||
|
|
||||||
int serverTime = dhInnerDataReader.ReadInt32();
|
var serverTime = dhInnerDataReader.ReadInt32();
|
||||||
timeOffset = serverTime - (int)(Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds) / 1000);
|
timeOffset = serverTime -
|
||||||
|
(int) (Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1))
|
||||||
|
.TotalMilliseconds) / 1000);
|
||||||
|
|
||||||
// logger.debug("g: {0}, dhprime: {1}, ga: {2}", g, dhPrime, ga);
|
// logger.debug("g: {0}, dhprime: {1}, ga: {2}", g, dhPrime, ga);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigInteger b = new BigInteger(2048, new Random());
|
var b = new BigInteger(2048, new Random());
|
||||||
BigInteger gb = BigInteger.ValueOf(g).ModPow(b, dhPrime);
|
var gb = BigInteger.ValueOf(g).ModPow(b, dhPrime);
|
||||||
_gab = ga.ModPow(b, dhPrime);
|
_gab = ga.ModPow(b, dhPrime);
|
||||||
|
|
||||||
// logger.debug("gab: {0}", gab);
|
// logger.debug("gab: {0}", gab);
|
||||||
|
|
||||||
// prepare client dh inner data
|
// prepare client dh inner data
|
||||||
byte[] clientDHInnerDataBytes;
|
byte[] clientDHInnerDataBytes;
|
||||||
using (MemoryStream clientDhInnerData = new MemoryStream())
|
using (var clientDhInnerData = new MemoryStream())
|
||||||
{
|
{
|
||||||
using (BinaryWriter clientDhInnerDataWriter = new BinaryWriter(clientDhInnerData))
|
using (var clientDhInnerDataWriter = new BinaryWriter(clientDhInnerData))
|
||||||
{
|
{
|
||||||
clientDhInnerDataWriter.Write(0x6643b654); // client_dh_inner_data
|
clientDhInnerDataWriter.Write(0x6643b654); // client_dh_inner_data
|
||||||
clientDhInnerDataWriter.Write(nonce);
|
clientDhInnerDataWriter.Write(nonce);
|
||||||
clientDhInnerDataWriter.Write(serverNonce);
|
clientDhInnerDataWriter.Write(serverNonce);
|
||||||
clientDhInnerDataWriter.Write((long)0); // TODO: retry_id
|
clientDhInnerDataWriter.Write((long) 0); // TODO: retry_id
|
||||||
Serializers.Bytes.write(clientDhInnerDataWriter, gb.ToByteArrayUnsigned());
|
Serializers.Bytes.write(clientDhInnerDataWriter, gb.ToByteArrayUnsigned());
|
||||||
|
|
||||||
using (MemoryStream clientDhInnerDataWithHash = new MemoryStream())
|
using (var clientDhInnerDataWithHash = new MemoryStream())
|
||||||
{
|
{
|
||||||
using (BinaryWriter clientDhInnerDataWithHashWriter = new BinaryWriter(clientDhInnerDataWithHash))
|
using (var clientDhInnerDataWithHashWriter = new BinaryWriter(clientDhInnerDataWithHash))
|
||||||
{
|
{
|
||||||
using (SHA1 sha1 = new SHA1Managed())
|
using (SHA1 sha1 = new SHA1Managed())
|
||||||
{
|
{
|
||||||
clientDhInnerDataWithHashWriter.Write(sha1.ComputeHash(clientDhInnerData.GetBuffer(), 0, (int)clientDhInnerData.Position));
|
clientDhInnerDataWithHashWriter.Write(sha1.ComputeHash(clientDhInnerData.GetBuffer(), 0,
|
||||||
clientDhInnerDataWithHashWriter.Write(clientDhInnerData.GetBuffer(), 0, (int)clientDhInnerData.Position);
|
(int) clientDhInnerData.Position));
|
||||||
|
clientDhInnerDataWithHashWriter.Write(clientDhInnerData.GetBuffer(), 0,
|
||||||
|
(int) clientDhInnerData.Position);
|
||||||
clientDHInnerDataBytes = clientDhInnerDataWithHash.ToArray();
|
clientDHInnerDataBytes = clientDhInnerDataWithHash.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,15 +105,15 @@ namespace TLSharp.Core.Auth
|
||||||
// logger.debug("client dh inner data papared len {0}: {1}", clientDHInnerDataBytes.Length, BitConverter.ToString(clientDHInnerDataBytes).Replace("-", ""));
|
// logger.debug("client dh inner data papared len {0}: {1}", clientDHInnerDataBytes.Length, BitConverter.ToString(clientDHInnerDataBytes).Replace("-", ""));
|
||||||
|
|
||||||
// encryption
|
// encryption
|
||||||
byte[] clientDhInnerDataEncryptedBytes = AES.EncryptAES(key, clientDHInnerDataBytes);
|
var clientDhInnerDataEncryptedBytes = AES.EncryptAES(key, clientDHInnerDataBytes);
|
||||||
|
|
||||||
// logger.debug("inner data encrypted {0}: {1}", clientDhInnerDataEncryptedBytes.Length, BitConverter.ToString(clientDhInnerDataEncryptedBytes).Replace("-", ""));
|
// logger.debug("inner data encrypted {0}: {1}", clientDhInnerDataEncryptedBytes.Length, BitConverter.ToString(clientDhInnerDataEncryptedBytes).Replace("-", ""));
|
||||||
|
|
||||||
// prepare set_client_dh_params
|
// prepare set_client_dh_params
|
||||||
byte[] setclientDhParamsBytes;
|
byte[] setclientDhParamsBytes;
|
||||||
using (MemoryStream setClientDhParams = new MemoryStream())
|
using (var setClientDhParams = new MemoryStream())
|
||||||
{
|
{
|
||||||
using (BinaryWriter setClientDhParamsWriter = new BinaryWriter(setClientDhParams))
|
using (var setClientDhParamsWriter = new BinaryWriter(setClientDhParams))
|
||||||
{
|
{
|
||||||
setClientDhParamsWriter.Write(0xf5045f1f);
|
setClientDhParamsWriter.Write(0xf5045f1f);
|
||||||
setClientDhParamsWriter.Write(nonce);
|
setClientDhParamsWriter.Write(nonce);
|
||||||
|
|
@ -134,17 +131,18 @@ namespace TLSharp.Core.Auth
|
||||||
|
|
||||||
public Step3_Response FromBytes(byte[] response)
|
public Step3_Response FromBytes(byte[] response)
|
||||||
{
|
{
|
||||||
using (MemoryStream responseStream = new MemoryStream(response))
|
using (var responseStream = new MemoryStream(response))
|
||||||
{
|
{
|
||||||
using (BinaryReader responseReader = new BinaryReader(responseStream))
|
using (var responseReader = new BinaryReader(responseStream))
|
||||||
{
|
{
|
||||||
uint code = responseReader.ReadUInt32();
|
var code = responseReader.ReadUInt32();
|
||||||
if (code == 0x3bcbf734)
|
if (code == 0x3bcbf734)
|
||||||
{ // dh_gen_ok
|
{
|
||||||
|
// dh_gen_ok
|
||||||
//logger.debug("dh_gen_ok");
|
//logger.debug("dh_gen_ok");
|
||||||
|
|
||||||
|
|
||||||
byte[] nonceFromServer = responseReader.ReadBytes(16);
|
var nonceFromServer = responseReader.ReadBytes(16);
|
||||||
// TODO
|
// TODO
|
||||||
/*
|
/*
|
||||||
if (!nonceFromServer.SequenceEqual(nonce))
|
if (!nonceFromServer.SequenceEqual(nonce))
|
||||||
|
|
@ -154,7 +152,7 @@ namespace TLSharp.Core.Auth
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
byte[] serverNonceFromServer = responseReader.ReadBytes(16);
|
var serverNonceFromServer = responseReader.ReadBytes(16);
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
||||||
|
|
@ -166,44 +164,33 @@ namespace TLSharp.Core.Auth
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
byte[] newNonceHash1 = responseReader.ReadBytes(16);
|
var newNonceHash1 = responseReader.ReadBytes(16);
|
||||||
//logger.debug("new nonce hash 1: {0}", BitConverter.ToString(newNonceHash1));
|
//logger.debug("new nonce hash 1: {0}", BitConverter.ToString(newNonceHash1));
|
||||||
|
|
||||||
AuthKey authKey = new AuthKey(_gab);
|
var authKey = new AuthKey(_gab);
|
||||||
|
|
||||||
byte[] newNonceHashCalculated = authKey.CalcNewNonceHash(newNonce, 1);
|
var newNonceHashCalculated = authKey.CalcNewNonceHash(newNonce, 1);
|
||||||
|
|
||||||
if (!newNonceHash1.SequenceEqual(newNonceHashCalculated))
|
if (!newNonceHash1.SequenceEqual(newNonceHashCalculated))
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid new nonce hash");
|
throw new InvalidOperationException("invalid new nonce hash");
|
||||||
}
|
|
||||||
|
|
||||||
//logger.info("generated new auth key: {0}", gab);
|
//logger.info("generated new auth key: {0}", gab);
|
||||||
//logger.info("saving time offset: {0}", timeOffset);
|
//logger.info("saving time offset: {0}", timeOffset);
|
||||||
//TelegramSession.Instance.TimeOffset = timeOffset;
|
//TelegramSession.Instance.TimeOffset = timeOffset;
|
||||||
|
|
||||||
return new Step3_Response()
|
return new Step3_Response
|
||||||
{
|
{
|
||||||
AuthKey = authKey,
|
AuthKey = authKey,
|
||||||
TimeOffset = timeOffset
|
TimeOffset = timeOffset
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (code == 0x46dc1fb9)
|
if (code == 0x46dc1fb9)
|
||||||
{ // dh_gen_retry
|
|
||||||
throw new NotImplementedException("dh_gen_retry");
|
throw new NotImplementedException("dh_gen_retry");
|
||||||
|
if (code == 0xa69dae02)
|
||||||
}
|
|
||||||
else if (code == 0xa69dae02)
|
|
||||||
{
|
|
||||||
// dh_gen_fail
|
|
||||||
throw new NotImplementedException("dh_gen_fail");
|
throw new NotImplementedException("dh_gen_fail");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"dh_gen unknown: {code}");
|
throw new InvalidOperationException($"dh_gen unknown: {code}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,24 +6,15 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
public class AESKeyData
|
public class AESKeyData
|
||||||
{
|
{
|
||||||
private readonly byte[] key;
|
|
||||||
private readonly byte[] iv;
|
|
||||||
|
|
||||||
public AESKeyData(byte[] key, byte[] iv)
|
public AESKeyData(byte[] key, byte[] iv)
|
||||||
{
|
{
|
||||||
this.key = key;
|
Key = key;
|
||||||
this.iv = iv;
|
Iv = iv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Key
|
public byte[] Key { get; }
|
||||||
{
|
|
||||||
get { return key; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] Iv
|
public byte[] Iv { get; }
|
||||||
{
|
|
||||||
get { return iv; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AES
|
public class AES
|
||||||
|
|
@ -36,16 +27,16 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
newNonce.CopyTo(nonces, 0);
|
newNonce.CopyTo(nonces, 0);
|
||||||
serverNonce.CopyTo(nonces, 32);
|
serverNonce.CopyTo(nonces, 32);
|
||||||
byte[] hash1 = hash.ComputeHash(nonces);
|
var hash1 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
serverNonce.CopyTo(nonces, 0);
|
serverNonce.CopyTo(nonces, 0);
|
||||||
newNonce.CopyTo(nonces, 16);
|
newNonce.CopyTo(nonces, 16);
|
||||||
byte[] hash2 = hash.ComputeHash(nonces);
|
var hash2 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
nonces = new byte[64];
|
nonces = new byte[64];
|
||||||
newNonce.CopyTo(nonces, 0);
|
newNonce.CopyTo(nonces, 0);
|
||||||
newNonce.CopyTo(nonces, 32);
|
newNonce.CopyTo(nonces, 32);
|
||||||
byte[] hash3 = hash.ComputeHash(nonces);
|
var hash3 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
using (var keyBuffer = new MemoryStream(32))
|
using (var keyBuffer = new MemoryStream(32))
|
||||||
using (var ivBuffer = new MemoryStream(32))
|
using (var ivBuffer = new MemoryStream(32))
|
||||||
|
|
@ -70,16 +61,16 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
newNonce.CopyTo(nonces, 0);
|
newNonce.CopyTo(nonces, 0);
|
||||||
serverNonce.CopyTo(nonces, 32);
|
serverNonce.CopyTo(nonces, 32);
|
||||||
byte[] hash1 = hash.ComputeHash(nonces);
|
var hash1 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
serverNonce.CopyTo(nonces, 0);
|
serverNonce.CopyTo(nonces, 0);
|
||||||
newNonce.CopyTo(nonces, 16);
|
newNonce.CopyTo(nonces, 16);
|
||||||
byte[] hash2 = hash.ComputeHash(nonces);
|
var hash2 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
nonces = new byte[64];
|
nonces = new byte[64];
|
||||||
newNonce.CopyTo(nonces, 0);
|
newNonce.CopyTo(nonces, 0);
|
||||||
newNonce.CopyTo(nonces, 32);
|
newNonce.CopyTo(nonces, 32);
|
||||||
byte[] hash3 = hash.ComputeHash(nonces);
|
var hash3 = hash.ComputeHash(nonces);
|
||||||
|
|
||||||
using (var keyBuffer = new MemoryStream(32))
|
using (var keyBuffer = new MemoryStream(32))
|
||||||
using (var ivBuffer = new MemoryStream(32))
|
using (var ivBuffer = new MemoryStream(32))
|
||||||
|
|
@ -114,27 +105,23 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
Array.Copy(iv, 0, iv1, 0, iv1.Length);
|
Array.Copy(iv, 0, iv1, 0, iv1.Length);
|
||||||
Array.Copy(iv, iv1.Length, iv2, 0, iv2.Length);
|
Array.Copy(iv, iv1.Length, iv2, 0, iv2.Length);
|
||||||
|
|
||||||
AesEngine aes = new AesEngine();
|
var aes = new AesEngine();
|
||||||
aes.Init(false, key);
|
aes.Init(false, key);
|
||||||
|
|
||||||
byte[] plaintext = new byte[ciphertext.Length];
|
var plaintext = new byte[ciphertext.Length];
|
||||||
int blocksCount = ciphertext.Length / 16;
|
var blocksCount = ciphertext.Length / 16;
|
||||||
|
|
||||||
byte[] ciphertextBlock = new byte[16];
|
var ciphertextBlock = new byte[16];
|
||||||
byte[] plaintextBlock = new byte[16];
|
var plaintextBlock = new byte[16];
|
||||||
for (int blockIndex = 0; blockIndex < blocksCount; blockIndex++)
|
for (var blockIndex = 0; blockIndex < blocksCount; blockIndex++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
{
|
ciphertextBlock[i] = (byte) (ciphertext[blockIndex * 16 + i] ^ iv2[i]);
|
||||||
ciphertextBlock[i] = (byte)(ciphertext[blockIndex * 16 + i] ^ iv2[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
aes.ProcessBlock(ciphertextBlock, 0, plaintextBlock, 0);
|
aes.ProcessBlock(ciphertextBlock, 0, plaintextBlock, 0);
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
{
|
|
||||||
plaintextBlock[i] ^= iv1[i];
|
plaintextBlock[i] ^= iv1[i];
|
||||||
}
|
|
||||||
|
|
||||||
Array.Copy(ciphertext, blockIndex * 16, iv1, 0, 16);
|
Array.Copy(ciphertext, blockIndex * 16, iv1, 0, 16);
|
||||||
Array.Copy(plaintextBlock, 0, iv2, 0, 16);
|
Array.Copy(plaintextBlock, 0, iv2, 0, 16);
|
||||||
|
|
@ -147,18 +134,15 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public static byte[] EncryptIGE(byte[] originPlaintext, byte[] key, byte[] iv)
|
public static byte[] EncryptIGE(byte[] originPlaintext, byte[] key, byte[] iv)
|
||||||
{
|
{
|
||||||
|
|
||||||
byte[] plaintext;
|
byte[] plaintext;
|
||||||
using (MemoryStream plaintextBuffer = new MemoryStream(originPlaintext.Length + 40))
|
using (var plaintextBuffer = new MemoryStream(originPlaintext.Length + 40))
|
||||||
{
|
{
|
||||||
//using(SHA1 hash = new SHA1Managed()) {
|
//using(SHA1 hash = new SHA1Managed()) {
|
||||||
//byte[] hashsum = hash.ComputeHash(originPlaintext);
|
//byte[] hashsum = hash.ComputeHash(originPlaintext);
|
||||||
//plaintextBuffer.Write(hashsum, 0, hashsum.Length);
|
//plaintextBuffer.Write(hashsum, 0, hashsum.Length);
|
||||||
plaintextBuffer.Write(originPlaintext, 0, originPlaintext.Length);
|
plaintextBuffer.Write(originPlaintext, 0, originPlaintext.Length);
|
||||||
while (plaintextBuffer.Position % 16 != 0)
|
while (plaintextBuffer.Position % 16 != 0)
|
||||||
{
|
|
||||||
plaintextBuffer.WriteByte(0); // TODO: random padding
|
plaintextBuffer.WriteByte(0); // TODO: random padding
|
||||||
}
|
|
||||||
plaintext = plaintextBuffer.ToArray();
|
plaintext = plaintextBuffer.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,24 +152,22 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
Array.Copy(iv, 0, iv1, 0, iv1.Length);
|
Array.Copy(iv, 0, iv1, 0, iv1.Length);
|
||||||
Array.Copy(iv, iv1.Length, iv2, 0, iv2.Length);
|
Array.Copy(iv, iv1.Length, iv2, 0, iv2.Length);
|
||||||
|
|
||||||
AesEngine aes = new AesEngine();
|
var aes = new AesEngine();
|
||||||
aes.Init(true, key);
|
aes.Init(true, key);
|
||||||
|
|
||||||
int blocksCount = plaintext.Length / 16;
|
var blocksCount = plaintext.Length / 16;
|
||||||
byte[] ciphertext = new byte[plaintext.Length];
|
var ciphertext = new byte[plaintext.Length];
|
||||||
|
|
||||||
byte[] ciphertextBlock = new byte[16];
|
var ciphertextBlock = new byte[16];
|
||||||
byte[] plaintextBlock = new byte[16];
|
var plaintextBlock = new byte[16];
|
||||||
for (int blockIndex = 0; blockIndex < blocksCount; blockIndex++)
|
for (var blockIndex = 0; blockIndex < blocksCount; blockIndex++)
|
||||||
{
|
{
|
||||||
Array.Copy(plaintext, 16 * blockIndex, plaintextBlock, 0, 16);
|
Array.Copy(plaintext, 16 * blockIndex, plaintextBlock, 0, 16);
|
||||||
|
|
||||||
//logger.info("plaintext block: {0} xor {1}", BitConverter.ToString(plaintextBlock).Replace("-", ""), BitConverter.ToString(iv1).Replace("-", ""));
|
//logger.info("plaintext block: {0} xor {1}", BitConverter.ToString(plaintextBlock).Replace("-", ""), BitConverter.ToString(iv1).Replace("-", ""));
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
{
|
|
||||||
plaintextBlock[i] ^= iv1[i];
|
plaintextBlock[i] ^= iv1[i];
|
||||||
}
|
|
||||||
|
|
||||||
//logger.info("xored plaintext: {0}", BitConverter.ToString(plaintextBlock).Replace("-", ""));
|
//logger.info("xored plaintext: {0}", BitConverter.ToString(plaintextBlock).Replace("-", ""));
|
||||||
|
|
||||||
|
|
@ -193,10 +175,8 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
//logger.info("encrypted plaintext: {0} xor {1}", BitConverter.ToString(ciphertextBlock).Replace("-", ""), BitConverter.ToString(iv2).Replace("-", ""));
|
//logger.info("encrypted plaintext: {0} xor {1}", BitConverter.ToString(ciphertextBlock).Replace("-", ""), BitConverter.ToString(iv2).Replace("-", ""));
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (var i = 0; i < 16; i++)
|
||||||
{
|
|
||||||
ciphertextBlock[i] ^= iv2[i];
|
ciphertextBlock[i] ^= iv2[i];
|
||||||
}
|
|
||||||
|
|
||||||
//logger.info("xored ciphertext: {0}", BitConverter.ToString(ciphertextBlock).Replace("-", ""));
|
//logger.info("xored ciphertext: {0}", BitConverter.ToString(ciphertextBlock).Replace("-", ""));
|
||||||
|
|
||||||
|
|
@ -212,12 +192,10 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
public static byte[] XOR(byte[] buffer1, byte[] buffer2)
|
public static byte[] XOR(byte[] buffer1, byte[] buffer2)
|
||||||
{
|
{
|
||||||
var result = new byte[buffer1.Length];
|
var result = new byte[buffer1.Length];
|
||||||
for (int i = 0; i < buffer1.Length; i++)
|
for (var i = 0; i < buffer1.Length; i++)
|
||||||
result[i] = (byte)(buffer1[i] ^ buffer2[i]);
|
result[i] = (byte) (buffer1[i] ^ buffer2[i]);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -227,11 +205,13 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
// The S box
|
// The S box
|
||||||
private const uint m1 = 0x80808080;
|
private const uint m1 = 0x80808080;
|
||||||
|
|
||||||
private const uint m2 = 0x7f7f7f7f;
|
private const uint m2 = 0x7f7f7f7f;
|
||||||
private const uint m3 = 0x0000001b;
|
private const uint m3 = 0x0000001b;
|
||||||
private const int BLOCK_SIZE = 16;
|
private const int BLOCK_SIZE = 16;
|
||||||
|
|
||||||
private static readonly byte[] S = {
|
private static readonly byte[] S =
|
||||||
|
{
|
||||||
99, 124, 119, 123, 242, 107, 111, 197,
|
99, 124, 119, 123, 242, 107, 111, 197,
|
||||||
48, 1, 103, 43, 254, 215, 171, 118,
|
48, 1, 103, 43, 254, 215, 171, 118,
|
||||||
202, 130, 201, 125, 250, 89, 71, 240,
|
202, 130, 201, 125, 250, 89, 71, 240,
|
||||||
|
|
@ -267,7 +247,8 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
};
|
};
|
||||||
|
|
||||||
// The inverse S-box
|
// The inverse S-box
|
||||||
private static readonly byte[] Si = {
|
private static readonly byte[] Si =
|
||||||
|
{
|
||||||
82, 9, 106, 213, 48, 54, 165, 56,
|
82, 9, 106, 213, 48, 54, 165, 56,
|
||||||
191, 64, 163, 158, 129, 243, 215, 251,
|
191, 64, 163, 158, 129, 243, 215, 251,
|
||||||
124, 227, 57, 130, 155, 47, 255, 135,
|
124, 227, 57, 130, 155, 47, 255, 135,
|
||||||
|
|
@ -303,13 +284,15 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
};
|
};
|
||||||
|
|
||||||
// vector used in calculating key schedule (powers of x in GF(256))
|
// vector used in calculating key schedule (powers of x in GF(256))
|
||||||
private static readonly byte[] rcon = {
|
private static readonly byte[] rcon =
|
||||||
|
{
|
||||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
|
||||||
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
|
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
|
||||||
};
|
};
|
||||||
|
|
||||||
// precomputation tables of calculations for rounds
|
// precomputation tables of calculations for rounds
|
||||||
private static readonly uint[] T0 = {
|
private static readonly uint[] T0 =
|
||||||
|
{
|
||||||
0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, 0x0df2f2ff,
|
0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, 0x0df2f2ff,
|
||||||
0xbd6b6bd6, 0xb16f6fde, 0x54c5c591, 0x50303060, 0x03010102,
|
0xbd6b6bd6, 0xb16f6fde, 0x54c5c591, 0x50303060, 0x03010102,
|
||||||
0xa96767ce, 0x7d2b2b56, 0x19fefee7, 0x62d7d7b5, 0xe6abab4d,
|
0xa96767ce, 0x7d2b2b56, 0x19fefee7, 0x62d7d7b5, 0xe6abab4d,
|
||||||
|
|
@ -364,7 +347,8 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
0x3a16162c
|
0x3a16162c
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly uint[] Tinv0 = {
|
private static readonly uint[] Tinv0 =
|
||||||
|
{
|
||||||
0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a, 0xcb6bab3b,
|
0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a, 0xcb6bab3b,
|
||||||
0xf1459d1f, 0xab58faac, 0x9303e34b, 0x55fa3020, 0xf66d76ad,
|
0xf1459d1f, 0xab58faac, 0x9303e34b, 0x55fa3020, 0xf66d76ad,
|
||||||
0x9176cc88, 0x254c02f5, 0xfcd7e54f, 0xd7cb2ac5, 0x80443526,
|
0x9176cc88, 0x254c02f5, 0xfcd7e54f, 0xd7cb2ac5, 0x80443526,
|
||||||
|
|
@ -420,19 +404,13 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
};
|
};
|
||||||
|
|
||||||
private uint C0, C1, C2, C3;
|
private uint C0, C1, C2, C3;
|
||||||
|
private bool forEncryption;
|
||||||
private int ROUNDS;
|
private int ROUNDS;
|
||||||
private uint[,] WorkingKey;
|
private uint[,] WorkingKey;
|
||||||
private bool forEncryption;
|
|
||||||
|
|
||||||
public string AlgorithmName
|
public string AlgorithmName => "AES";
|
||||||
{
|
|
||||||
get { return "AES"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsPartialBlockOkay
|
public bool IsPartialBlockOkay => false;
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private uint Shift(
|
private uint Shift(
|
||||||
uint r,
|
uint r,
|
||||||
|
|
@ -460,10 +438,10 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
private uint Inv_Mcol(
|
private uint Inv_Mcol(
|
||||||
uint x)
|
uint x)
|
||||||
{
|
{
|
||||||
uint f2 = FFmulX(x);
|
var f2 = FFmulX(x);
|
||||||
uint f4 = FFmulX(f2);
|
var f4 = FFmulX(f2);
|
||||||
uint f8 = FFmulX(f4);
|
var f8 = FFmulX(f4);
|
||||||
uint f9 = x ^ f8;
|
var f9 = x ^ f8;
|
||||||
|
|
||||||
return f2 ^ f4 ^ f8 ^ Shift(f2 ^ f9, 8) ^ Shift(f4 ^ f9, 16) ^ Shift(f9, 24);
|
return f2 ^ f4 ^ f8 ^ Shift(f2 ^ f9, 8) ^ Shift(f4 ^ f9, 16) ^ Shift(f9, 24);
|
||||||
}
|
}
|
||||||
|
|
@ -472,9 +450,9 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
uint x)
|
uint x)
|
||||||
{
|
{
|
||||||
return S[x & 255]
|
return S[x & 255]
|
||||||
| (((uint)S[(x >> 8) & 255]) << 8)
|
| ((uint) S[(x >> 8) & 255] << 8)
|
||||||
| (((uint)S[(x >> 16) & 255]) << 16)
|
| ((uint) S[(x >> 16) & 255] << 16)
|
||||||
| (((uint)S[(x >> 24) & 255]) << 24);
|
| ((uint) S[(x >> 24) & 255] << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -488,10 +466,10 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
byte[] key,
|
byte[] key,
|
||||||
bool forEncryption)
|
bool forEncryption)
|
||||||
{
|
{
|
||||||
int KC = key.Length / 4; // key length in words
|
var KC = key.Length / 4; // key length in words
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
if ((KC != 4) && (KC != 6) && (KC != 8))
|
if (KC != 4 && KC != 6 && KC != 8)
|
||||||
throw new ArgumentException("Key length not 128/192/256 bits.");
|
throw new ArgumentException("Key length not 128/192/256 bits.");
|
||||||
|
|
||||||
ROUNDS = KC + 6; // This is not always true for the generalized Rijndael that allows larger block sizes
|
ROUNDS = KC + 6; // This is not always true for the generalized Rijndael that allows larger block sizes
|
||||||
|
|
@ -502,7 +480,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
//
|
//
|
||||||
|
|
||||||
t = 0;
|
t = 0;
|
||||||
for (int i = 0; i < key.Length; t++)
|
for (var i = 0; i < key.Length; t++)
|
||||||
{
|
{
|
||||||
W[t >> 2, t & 3] = Pack.LE_To_UInt32(key, i);
|
W[t >> 2, t & 3] = Pack.LE_To_UInt32(key, i);
|
||||||
i += 4;
|
i += 4;
|
||||||
|
|
@ -512,32 +490,22 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// while not enough round key material calculated
|
// while not enough round key material calculated
|
||||||
// calculate new values
|
// calculate new values
|
||||||
//
|
//
|
||||||
int k = (ROUNDS + 1) << 2;
|
var k = (ROUNDS + 1) << 2;
|
||||||
for (int i = KC; (i < k); i++)
|
for (var i = KC; i < k; i++)
|
||||||
{
|
|
||||||
uint temp = W[(i - 1) >> 2, (i - 1) & 3];
|
|
||||||
if ((i % KC) == 0)
|
|
||||||
{
|
|
||||||
temp = SubWord(Shift(temp, 8)) ^ rcon[(i / KC) - 1];
|
|
||||||
}
|
|
||||||
else if ((KC > 6) && ((i % KC) == 4))
|
|
||||||
{
|
{
|
||||||
|
var temp = W[(i - 1) >> 2, (i - 1) & 3];
|
||||||
|
if (i % KC == 0)
|
||||||
|
temp = SubWord(Shift(temp, 8)) ^ rcon[i / KC - 1];
|
||||||
|
else if (KC > 6 && i % KC == 4)
|
||||||
temp = SubWord(temp);
|
temp = SubWord(temp);
|
||||||
}
|
|
||||||
|
|
||||||
W[i >> 2, i & 3] = W[(i - KC) >> 2, (i - KC) & 3] ^ temp;
|
W[i >> 2, i & 3] = W[(i - KC) >> 2, (i - KC) & 3] ^ temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!forEncryption)
|
if (!forEncryption)
|
||||||
{
|
for (var j = 1; j < ROUNDS; j++)
|
||||||
for (int j = 1; j < ROUNDS; j++)
|
for (var i = 0; i < 4; i++)
|
||||||
{
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
W[j, i] = Inv_Mcol(W[j, i]);
|
W[j, i] = Inv_Mcol(W[j, i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return W;
|
return W;
|
||||||
}
|
}
|
||||||
|
|
@ -556,29 +524,19 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
public int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
public int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
||||||
{
|
{
|
||||||
if (WorkingKey == null)
|
if (WorkingKey == null)
|
||||||
{
|
|
||||||
throw new InvalidOperationException("AES engine not initialised");
|
throw new InvalidOperationException("AES engine not initialised");
|
||||||
}
|
|
||||||
|
|
||||||
if ((inOff + (32 / 2)) > input.Length)
|
if (inOff + 32 / 2 > input.Length)
|
||||||
{
|
|
||||||
throw new InvalidOperationException("input buffer too short");
|
throw new InvalidOperationException("input buffer too short");
|
||||||
}
|
|
||||||
|
|
||||||
if ((outOff + (32 / 2)) > output.Length)
|
if (outOff + 32 / 2 > output.Length)
|
||||||
{
|
|
||||||
throw new InvalidOperationException("output buffer too short");
|
throw new InvalidOperationException("output buffer too short");
|
||||||
}
|
|
||||||
|
|
||||||
UnPackBlock(input, inOff);
|
UnPackBlock(input, inOff);
|
||||||
|
|
||||||
if (forEncryption)
|
if (forEncryption)
|
||||||
{
|
|
||||||
EncryptBlock(WorkingKey);
|
EncryptBlock(WorkingKey);
|
||||||
}
|
else DecryptBlock(WorkingKey);
|
||||||
else {
|
|
||||||
DecryptBlock(WorkingKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
PackBlock(output, outOff);
|
PackBlock(output, outOff);
|
||||||
|
|
||||||
|
|
@ -650,14 +608,14 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
// the final round's table is a simple function of S so we don't use a whole other four tables for it
|
// the final round's table is a simple function of S so we don't use a whole other four tables for it
|
||||||
|
|
||||||
C0 = S[r0 & 255] ^ (((uint)S[(r1 >> 8) & 255]) << 8) ^ (((uint)S[(r2 >> 16) & 255]) << 16) ^
|
C0 = S[r0 & 255] ^ ((uint) S[(r1 >> 8) & 255] << 8) ^ ((uint) S[(r2 >> 16) & 255] << 16) ^
|
||||||
(((uint)S[(r3 >> 24) & 255]) << 24) ^ KW[r, 0];
|
((uint) S[(r3 >> 24) & 255] << 24) ^ KW[r, 0];
|
||||||
C1 = S[r1 & 255] ^ (((uint)S[(r2 >> 8) & 255]) << 8) ^ (((uint)S[(r3 >> 16) & 255]) << 16) ^
|
C1 = S[r1 & 255] ^ ((uint) S[(r2 >> 8) & 255] << 8) ^ ((uint) S[(r3 >> 16) & 255] << 16) ^
|
||||||
(((uint)S[(r0 >> 24) & 255]) << 24) ^ KW[r, 1];
|
((uint) S[(r0 >> 24) & 255] << 24) ^ KW[r, 1];
|
||||||
C2 = S[r2 & 255] ^ (((uint)S[(r3 >> 8) & 255]) << 8) ^ (((uint)S[(r0 >> 16) & 255]) << 16) ^
|
C2 = S[r2 & 255] ^ ((uint) S[(r3 >> 8) & 255] << 8) ^ ((uint) S[(r0 >> 16) & 255] << 16) ^
|
||||||
(((uint)S[(r1 >> 24) & 255]) << 24) ^ KW[r, 2];
|
((uint) S[(r1 >> 24) & 255] << 24) ^ KW[r, 2];
|
||||||
C3 = S[r3 & 255] ^ (((uint)S[(r0 >> 8) & 255]) << 8) ^ (((uint)S[(r1 >> 16) & 255]) << 16) ^
|
C3 = S[r3 & 255] ^ ((uint) S[(r0 >> 8) & 255] << 8) ^ ((uint) S[(r1 >> 16) & 255] << 16) ^
|
||||||
(((uint)S[(r2 >> 24) & 255]) << 24) ^ KW[r, 3];
|
((uint) S[(r2 >> 24) & 255] << 24) ^ KW[r, 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DecryptBlock(
|
private void DecryptBlock(
|
||||||
|
|
@ -702,14 +660,14 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
// the final round's table is a simple function of Si so we don't use a whole other four tables for it
|
// the final round's table is a simple function of Si so we don't use a whole other four tables for it
|
||||||
|
|
||||||
C0 = Si[r0 & 255] ^ (((uint)Si[(r3 >> 8) & 255]) << 8) ^ (((uint)Si[(r2 >> 16) & 255]) << 16) ^
|
C0 = Si[r0 & 255] ^ ((uint) Si[(r3 >> 8) & 255] << 8) ^ ((uint) Si[(r2 >> 16) & 255] << 16) ^
|
||||||
(((uint)Si[(r1 >> 24) & 255]) << 24) ^ KW[0, 0];
|
((uint) Si[(r1 >> 24) & 255] << 24) ^ KW[0, 0];
|
||||||
C1 = Si[r1 & 255] ^ (((uint)Si[(r0 >> 8) & 255]) << 8) ^ (((uint)Si[(r3 >> 16) & 255]) << 16) ^
|
C1 = Si[r1 & 255] ^ ((uint) Si[(r0 >> 8) & 255] << 8) ^ ((uint) Si[(r3 >> 16) & 255] << 16) ^
|
||||||
(((uint)Si[(r2 >> 24) & 255]) << 24) ^ KW[0, 1];
|
((uint) Si[(r2 >> 24) & 255] << 24) ^ KW[0, 1];
|
||||||
C2 = Si[r2 & 255] ^ (((uint)Si[(r1 >> 8) & 255]) << 8) ^ (((uint)Si[(r0 >> 16) & 255]) << 16) ^
|
C2 = Si[r2 & 255] ^ ((uint) Si[(r1 >> 8) & 255] << 8) ^ ((uint) Si[(r0 >> 16) & 255] << 16) ^
|
||||||
(((uint)Si[(r3 >> 24) & 255]) << 24) ^ KW[0, 2];
|
((uint) Si[(r3 >> 24) & 255] << 24) ^ KW[0, 2];
|
||||||
C3 = Si[r3 & 255] ^ (((uint)Si[(r2 >> 8) & 255]) << 8) ^ (((uint)Si[(r1 >> 16) & 255]) << 16) ^
|
C3 = Si[r3 & 255] ^ ((uint) Si[(r2 >> 8) & 255] << 8) ^ ((uint) Si[(r1 >> 16) & 255] << 16) ^
|
||||||
(((uint)Si[(r0 >> 24) & 255]) << 24) ^ KW[0, 3];
|
((uint) Si[(r0 >> 24) & 255] << 24) ^ KW[0, 3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -722,122 +680,122 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
internal static void UInt32_To_BE(uint n, byte[] bs)
|
internal static void UInt32_To_BE(uint n, byte[] bs)
|
||||||
{
|
{
|
||||||
bs[0] = (byte)(n >> 24);
|
bs[0] = (byte) (n >> 24);
|
||||||
bs[1] = (byte)(n >> 16);
|
bs[1] = (byte) (n >> 16);
|
||||||
bs[2] = (byte)(n >> 8);
|
bs[2] = (byte) (n >> 8);
|
||||||
bs[3] = (byte)(n);
|
bs[3] = (byte) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt32_To_BE(uint n, byte[] bs, int off)
|
internal static void UInt32_To_BE(uint n, byte[] bs, int off)
|
||||||
{
|
{
|
||||||
bs[off] = (byte)(n >> 24);
|
bs[off] = (byte) (n >> 24);
|
||||||
bs[++off] = (byte)(n >> 16);
|
bs[++off] = (byte) (n >> 16);
|
||||||
bs[++off] = (byte)(n >> 8);
|
bs[++off] = (byte) (n >> 8);
|
||||||
bs[++off] = (byte)(n);
|
bs[++off] = (byte) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint BE_To_UInt32(byte[] bs)
|
internal static uint BE_To_UInt32(byte[] bs)
|
||||||
{
|
{
|
||||||
uint n = (uint)bs[0] << 24;
|
var n = (uint) bs[0] << 24;
|
||||||
n |= (uint)bs[1] << 16;
|
n |= (uint) bs[1] << 16;
|
||||||
n |= (uint)bs[2] << 8;
|
n |= (uint) bs[2] << 8;
|
||||||
n |= bs[3];
|
n |= bs[3];
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint BE_To_UInt32(byte[] bs, int off)
|
internal static uint BE_To_UInt32(byte[] bs, int off)
|
||||||
{
|
{
|
||||||
uint n = (uint)bs[off] << 24;
|
var n = (uint) bs[off] << 24;
|
||||||
n |= (uint)bs[++off] << 16;
|
n |= (uint) bs[++off] << 16;
|
||||||
n |= (uint)bs[++off] << 8;
|
n |= (uint) bs[++off] << 8;
|
||||||
n |= bs[++off];
|
n |= bs[++off];
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong BE_To_UInt64(byte[] bs)
|
internal static ulong BE_To_UInt64(byte[] bs)
|
||||||
{
|
{
|
||||||
uint hi = BE_To_UInt32(bs);
|
var hi = BE_To_UInt32(bs);
|
||||||
uint lo = BE_To_UInt32(bs, 4);
|
var lo = BE_To_UInt32(bs, 4);
|
||||||
return ((ulong)hi << 32) | lo;
|
return ((ulong) hi << 32) | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong BE_To_UInt64(byte[] bs, int off)
|
internal static ulong BE_To_UInt64(byte[] bs, int off)
|
||||||
{
|
{
|
||||||
uint hi = BE_To_UInt32(bs, off);
|
var hi = BE_To_UInt32(bs, off);
|
||||||
uint lo = BE_To_UInt32(bs, off + 4);
|
var lo = BE_To_UInt32(bs, off + 4);
|
||||||
return ((ulong)hi << 32) | lo;
|
return ((ulong) hi << 32) | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt64_To_BE(ulong n, byte[] bs)
|
internal static void UInt64_To_BE(ulong n, byte[] bs)
|
||||||
{
|
{
|
||||||
UInt32_To_BE((uint)(n >> 32), bs);
|
UInt32_To_BE((uint) (n >> 32), bs);
|
||||||
UInt32_To_BE((uint)(n), bs, 4);
|
UInt32_To_BE((uint) n, bs, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
|
internal static void UInt64_To_BE(ulong n, byte[] bs, int off)
|
||||||
{
|
{
|
||||||
UInt32_To_BE((uint)(n >> 32), bs, off);
|
UInt32_To_BE((uint) (n >> 32), bs, off);
|
||||||
UInt32_To_BE((uint)(n), bs, off + 4);
|
UInt32_To_BE((uint) n, bs, off + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt32_To_LE(uint n, byte[] bs)
|
internal static void UInt32_To_LE(uint n, byte[] bs)
|
||||||
{
|
{
|
||||||
bs[0] = (byte)(n);
|
bs[0] = (byte) n;
|
||||||
bs[1] = (byte)(n >> 8);
|
bs[1] = (byte) (n >> 8);
|
||||||
bs[2] = (byte)(n >> 16);
|
bs[2] = (byte) (n >> 16);
|
||||||
bs[3] = (byte)(n >> 24);
|
bs[3] = (byte) (n >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt32_To_LE(uint n, byte[] bs, int off)
|
internal static void UInt32_To_LE(uint n, byte[] bs, int off)
|
||||||
{
|
{
|
||||||
bs[off] = (byte)(n);
|
bs[off] = (byte) n;
|
||||||
bs[++off] = (byte)(n >> 8);
|
bs[++off] = (byte) (n >> 8);
|
||||||
bs[++off] = (byte)(n >> 16);
|
bs[++off] = (byte) (n >> 16);
|
||||||
bs[++off] = (byte)(n >> 24);
|
bs[++off] = (byte) (n >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint LE_To_UInt32(byte[] bs)
|
internal static uint LE_To_UInt32(byte[] bs)
|
||||||
{
|
{
|
||||||
uint n = bs[0];
|
uint n = bs[0];
|
||||||
n |= (uint)bs[1] << 8;
|
n |= (uint) bs[1] << 8;
|
||||||
n |= (uint)bs[2] << 16;
|
n |= (uint) bs[2] << 16;
|
||||||
n |= (uint)bs[3] << 24;
|
n |= (uint) bs[3] << 24;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static uint LE_To_UInt32(byte[] bs, int off)
|
internal static uint LE_To_UInt32(byte[] bs, int off)
|
||||||
{
|
{
|
||||||
uint n = bs[off];
|
uint n = bs[off];
|
||||||
n |= (uint)bs[++off] << 8;
|
n |= (uint) bs[++off] << 8;
|
||||||
n |= (uint)bs[++off] << 16;
|
n |= (uint) bs[++off] << 16;
|
||||||
n |= (uint)bs[++off] << 24;
|
n |= (uint) bs[++off] << 24;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong LE_To_UInt64(byte[] bs)
|
internal static ulong LE_To_UInt64(byte[] bs)
|
||||||
{
|
{
|
||||||
uint lo = LE_To_UInt32(bs);
|
var lo = LE_To_UInt32(bs);
|
||||||
uint hi = LE_To_UInt32(bs, 4);
|
var hi = LE_To_UInt32(bs, 4);
|
||||||
return ((ulong)hi << 32) | lo;
|
return ((ulong) hi << 32) | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong LE_To_UInt64(byte[] bs, int off)
|
internal static ulong LE_To_UInt64(byte[] bs, int off)
|
||||||
{
|
{
|
||||||
uint lo = LE_To_UInt32(bs, off);
|
var lo = LE_To_UInt32(bs, off);
|
||||||
uint hi = LE_To_UInt32(bs, off + 4);
|
var hi = LE_To_UInt32(bs, off + 4);
|
||||||
return ((ulong)hi << 32) | lo;
|
return ((ulong) hi << 32) | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt64_To_LE(ulong n, byte[] bs)
|
internal static void UInt64_To_LE(ulong n, byte[] bs)
|
||||||
{
|
{
|
||||||
UInt32_To_LE((uint)(n), bs);
|
UInt32_To_LE((uint) n, bs);
|
||||||
UInt32_To_LE((uint)(n >> 32), bs, 4);
|
UInt32_To_LE((uint) (n >> 32), bs, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
|
internal static void UInt64_To_LE(ulong n, byte[] bs, int off)
|
||||||
{
|
{
|
||||||
UInt32_To_LE((uint)(n), bs, off);
|
UInt32_To_LE((uint) n, bs, off);
|
||||||
UInt32_To_LE((uint)(n >> 32), bs, off + 4);
|
UInt32_To_LE((uint) (n >> 32), bs, off + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,21 +6,20 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
public class AuthKey
|
public class AuthKey
|
||||||
{
|
{
|
||||||
private byte[] key;
|
private readonly ulong auxHash;
|
||||||
private ulong keyId;
|
|
||||||
private ulong auxHash;
|
|
||||||
public AuthKey(BigInteger gab)
|
public AuthKey(BigInteger gab)
|
||||||
{
|
{
|
||||||
key = gab.ToByteArrayUnsigned();
|
Data = gab.ToByteArrayUnsigned();
|
||||||
using (SHA1 hash = new SHA1Managed())
|
using (SHA1 hash = new SHA1Managed())
|
||||||
{
|
{
|
||||||
using (MemoryStream hashStream = new MemoryStream(hash.ComputeHash(key), false))
|
using (var hashStream = new MemoryStream(hash.ComputeHash(Data), false))
|
||||||
{
|
{
|
||||||
using (BinaryReader hashReader = new BinaryReader(hashStream))
|
using (var hashReader = new BinaryReader(hashStream))
|
||||||
{
|
{
|
||||||
auxHash = hashReader.ReadUInt64();
|
auxHash = hashReader.ReadUInt64();
|
||||||
hashReader.ReadBytes(4);
|
hashReader.ReadBytes(4);
|
||||||
keyId = hashReader.ReadUInt64();
|
Id = hashReader.ReadUInt64();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,34 +27,38 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public AuthKey(byte[] data)
|
public AuthKey(byte[] data)
|
||||||
{
|
{
|
||||||
key = data;
|
Data = data;
|
||||||
using (SHA1 hash = new SHA1Managed())
|
using (SHA1 hash = new SHA1Managed())
|
||||||
{
|
{
|
||||||
using (MemoryStream hashStream = new MemoryStream(hash.ComputeHash(key), false))
|
using (var hashStream = new MemoryStream(hash.ComputeHash(Data), false))
|
||||||
{
|
{
|
||||||
using (BinaryReader hashReader = new BinaryReader(hashStream))
|
using (var hashReader = new BinaryReader(hashStream))
|
||||||
{
|
{
|
||||||
auxHash = hashReader.ReadUInt64();
|
auxHash = hashReader.ReadUInt64();
|
||||||
hashReader.ReadBytes(4);
|
hashReader.ReadBytes(4);
|
||||||
keyId = hashReader.ReadUInt64();
|
Id = hashReader.ReadUInt64();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] Data { get; }
|
||||||
|
|
||||||
|
public ulong Id { get; }
|
||||||
|
|
||||||
public byte[] CalcNewNonceHash(byte[] newNonce, int number)
|
public byte[] CalcNewNonceHash(byte[] newNonce, int number)
|
||||||
{
|
{
|
||||||
using (MemoryStream buffer = new MemoryStream(100))
|
using (var buffer = new MemoryStream(100))
|
||||||
{
|
{
|
||||||
using (BinaryWriter bufferWriter = new BinaryWriter(buffer))
|
using (var bufferWriter = new BinaryWriter(buffer))
|
||||||
{
|
{
|
||||||
bufferWriter.Write(newNonce);
|
bufferWriter.Write(newNonce);
|
||||||
bufferWriter.Write((byte)number);
|
bufferWriter.Write((byte) number);
|
||||||
bufferWriter.Write(auxHash);
|
bufferWriter.Write(auxHash);
|
||||||
using (SHA1 sha1 = new SHA1Managed())
|
using (SHA1 sha1 = new SHA1Managed())
|
||||||
{
|
{
|
||||||
byte[] hash = sha1.ComputeHash(buffer.GetBuffer(), 0, (int)buffer.Position);
|
var hash = sha1.ComputeHash(buffer.GetBuffer(), 0, (int) buffer.Position);
|
||||||
byte[] newNonceHash = new byte[16];
|
var newNonceHash = new byte[16];
|
||||||
Array.Copy(hash, 4, newNonceHash, 0, 16);
|
Array.Copy(hash, 4, newNonceHash, 0, 16);
|
||||||
return newNonceHash;
|
return newNonceHash;
|
||||||
}
|
}
|
||||||
|
|
@ -63,25 +66,9 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Data
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return keyId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format("(Key: {0}, KeyId: {1}, AuxHash: {2})", key, keyId, auxHash);
|
return string.Format("(Key: {0}, KeyId: {1}, AuxHash: {2})", Data, Id, auxHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,22 +1,16 @@
|
||||||
using System;
|
using System.Security.Cryptography;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Ionic.Crc;
|
|
||||||
|
|
||||||
namespace TLSharp.Core.MTProto.Crypto
|
namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
public class Crc32 : HashAlgorithm
|
public class Crc32 : HashAlgorithm
|
||||||
{
|
{
|
||||||
public const UInt32 DefaultPolynomial = 0xedb88320u;
|
public const uint DefaultPolynomial = 0xedb88320u;
|
||||||
public const UInt32 DefaultSeed = 0xffffffffu;
|
public const uint DefaultSeed = 0xffffffffu;
|
||||||
|
private static uint[] defaultTable;
|
||||||
|
|
||||||
private UInt32 hash;
|
private uint hash;
|
||||||
private UInt32 seed;
|
private readonly uint seed;
|
||||||
private UInt32[] table;
|
private readonly uint[] table;
|
||||||
private static UInt32[] defaultTable;
|
|
||||||
|
|
||||||
public Crc32()
|
public Crc32()
|
||||||
{
|
{
|
||||||
|
|
@ -25,13 +19,15 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
hash = seed;
|
hash = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Crc32(UInt32 polynomial, UInt32 seed)
|
public Crc32(uint polynomial, uint seed)
|
||||||
{
|
{
|
||||||
table = InitializeTable(polynomial);
|
table = InitializeTable(polynomial);
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
hash = seed;
|
hash = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int HashSize => 32;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
hash = seed;
|
hash = seed;
|
||||||
|
|
@ -48,41 +44,36 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected override byte[] HashFinal()
|
protected override byte[] HashFinal()
|
||||||
{
|
{
|
||||||
byte[] hashBuffer = UInt32ToBigEndianBytes(~hash);
|
var hashBuffer = UInt32ToBigEndianBytes(~hash);
|
||||||
this.HashValue = hashBuffer;
|
HashValue = hashBuffer;
|
||||||
return hashBuffer;
|
return hashBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int HashSize
|
public static uint Compute(byte[] buffer)
|
||||||
{
|
|
||||||
get { return 32; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UInt32 Compute(byte[] buffer)
|
|
||||||
{
|
{
|
||||||
return ~CalculateHash(InitializeTable(DefaultPolynomial), DefaultSeed, buffer, 0, buffer.Length);
|
return ~CalculateHash(InitializeTable(DefaultPolynomial), DefaultSeed, buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UInt32 Compute(UInt32 seed, byte[] buffer)
|
public static uint Compute(uint seed, byte[] buffer)
|
||||||
{
|
{
|
||||||
return ~CalculateHash(InitializeTable(DefaultPolynomial), seed, buffer, 0, buffer.Length);
|
return ~CalculateHash(InitializeTable(DefaultPolynomial), seed, buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer)
|
public static uint Compute(uint polynomial, uint seed, byte[] buffer)
|
||||||
{
|
{
|
||||||
return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length);
|
return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UInt32[] InitializeTable(UInt32 polynomial)
|
private static uint[] InitializeTable(uint polynomial)
|
||||||
{
|
{
|
||||||
if (polynomial == DefaultPolynomial && defaultTable != null)
|
if (polynomial == DefaultPolynomial && defaultTable != null)
|
||||||
return defaultTable;
|
return defaultTable;
|
||||||
|
|
||||||
UInt32[] createTable = new UInt32[256];
|
var createTable = new uint[256];
|
||||||
for (int i = 0; i < 256; i++)
|
for (var i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
UInt32 entry = (UInt32)i;
|
var entry = (uint) i;
|
||||||
for (int j = 0; j < 8; j++)
|
for (var j = 0; j < 8; j++)
|
||||||
if ((entry & 1) == 1)
|
if ((entry & 1) == 1)
|
||||||
entry = (entry >> 1) ^ polynomial;
|
entry = (entry >> 1) ^ polynomial;
|
||||||
else
|
else
|
||||||
|
|
@ -96,24 +87,25 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
return createTable;
|
return createTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UInt32 CalculateHash(UInt32[] table, UInt32 seed, byte[] buffer, int start, int size)
|
private static uint CalculateHash(uint[] table, uint seed, byte[] buffer, int start, int size)
|
||||||
{
|
{
|
||||||
UInt32 crc = seed;
|
var crc = seed;
|
||||||
for (int i = start; i < size; i++)
|
for (var i = start; i < size; i++)
|
||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
crc = (crc >> 8) ^ table[buffer[i] ^ crc & 0xff];
|
crc = (crc >> 8) ^ table[buffer[i] ^ (crc & 0xff)];
|
||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] UInt32ToBigEndianBytes(UInt32 x)
|
private byte[] UInt32ToBigEndianBytes(uint x)
|
||||||
{
|
{
|
||||||
return new byte[] {
|
return new[]
|
||||||
(byte)((x >> 24) & 0xff),
|
{
|
||||||
(byte)((x >> 16) & 0xff),
|
(byte) ((x >> 24) & 0xff),
|
||||||
(byte)((x >> 8) & 0xff),
|
(byte) ((x >> 16) & 0xff),
|
||||||
(byte)(x & 0xff)
|
(byte) ((x >> 8) & 0xff),
|
||||||
|
(byte) (x & 0xff)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,39 +19,29 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
this.q = BigInteger.ValueOf(q);
|
this.q = BigInteger.ValueOf(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigInteger Min
|
public BigInteger Min => p.Min(q);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return p.Min(q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigInteger Max
|
public BigInteger Max => p.Max(q);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return p.Max(q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format("P: {0}, Q: {1}", p, q);
|
return string.Format("P: {0}, Q: {1}", p, q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Factorizator
|
public class Factorizator
|
||||||
{
|
{
|
||||||
public static Random random = new Random();
|
public static Random random = new Random();
|
||||||
|
|
||||||
public static long findSmallMultiplierLopatin(long what)
|
public static long findSmallMultiplierLopatin(long what)
|
||||||
{
|
{
|
||||||
long g = 0;
|
long g = 0;
|
||||||
for (int i = 0; i < 3; i++)
|
for (var i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
int q = (random.Next(128) & 15) + 17;
|
var q = (random.Next(128) & 15) + 17;
|
||||||
long x = random.Next(1000000000) + 1, y = x;
|
long x = random.Next(1000000000) + 1, y = x;
|
||||||
int lim = 1 << (i + 18);
|
var lim = 1 << (i + 18);
|
||||||
for (int j = 1; j < lim; j++)
|
for (var j = 1; j < lim; j++)
|
||||||
{
|
{
|
||||||
long a = x, b = x, c = q;
|
long a = x, b = x, c = q;
|
||||||
while (b != 0)
|
while (b != 0)
|
||||||
|
|
@ -60,36 +50,26 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
c += a;
|
c += a;
|
||||||
if (c >= what)
|
if (c >= what)
|
||||||
{
|
|
||||||
c -= what;
|
c -= what;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
a += a;
|
a += a;
|
||||||
if (a >= what)
|
if (a >= what)
|
||||||
{
|
|
||||||
a -= what;
|
a -= what;
|
||||||
}
|
|
||||||
b >>= 1;
|
b >>= 1;
|
||||||
}
|
}
|
||||||
x = c;
|
x = c;
|
||||||
long z = x < y ? y - x : x - y;
|
var z = x < y ? y - x : x - y;
|
||||||
g = GCD(z, what);
|
g = GCD(z, what);
|
||||||
if (g != 1)
|
if (g != 1)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if ((j & (j - 1)) == 0)
|
if ((j & (j - 1)) == 0)
|
||||||
{
|
|
||||||
y = x;
|
y = x;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (g > 1)
|
if (g > 1)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
long p = what / g;
|
var p = what / g;
|
||||||
return Math.Min(p, g);
|
return Math.Min(p, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,20 +78,12 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
while (a != 0 && b != 0)
|
while (a != 0 && b != 0)
|
||||||
{
|
{
|
||||||
while ((b & 1) == 0)
|
while ((b & 1) == 0)
|
||||||
{
|
|
||||||
b >>= 1;
|
b >>= 1;
|
||||||
}
|
|
||||||
while ((a & 1) == 0)
|
while ((a & 1) == 0)
|
||||||
{
|
|
||||||
a >>= 1;
|
a >>= 1;
|
||||||
}
|
|
||||||
if (a > b)
|
if (a > b)
|
||||||
{
|
|
||||||
a -= b;
|
a -= b;
|
||||||
}
|
else b -= a;
|
||||||
else {
|
|
||||||
b -= a;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return b == 0 ? a : b;
|
return b == 0 ? a : b;
|
||||||
}
|
}
|
||||||
|
|
@ -120,19 +92,14 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
if (pq.BitLength < 64)
|
if (pq.BitLength < 64)
|
||||||
{
|
{
|
||||||
long pqlong = pq.LongValue;
|
var pqlong = pq.LongValue;
|
||||||
long divisor = findSmallMultiplierLopatin(pqlong);
|
var divisor = findSmallMultiplierLopatin(pqlong);
|
||||||
return new FactorizedPair(BigInteger.ValueOf(divisor), BigInteger.ValueOf(pqlong / divisor));
|
return new FactorizedPair(BigInteger.ValueOf(divisor), BigInteger.ValueOf(pqlong / divisor));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// TODO: port pollard factorization
|
// TODO: port pollard factorization
|
||||||
throw new InvalidOperationException("pq too long; TODO: port the pollard algo");
|
throw new InvalidOperationException("pq too long; TODO: port the pollard algo");
|
||||||
// logger.error("pq too long; TODO: port the pollard algo");
|
// logger.error("pq too long; TODO: port the pollard algo");
|
||||||
// return null;
|
// return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -59,6 +59,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public class MD5
|
public class MD5
|
||||||
{
|
{
|
||||||
|
private readonly MD5Digest digest = new MD5Digest();
|
||||||
|
|
||||||
public static string GetMd5String(string data)
|
public static string GetMd5String(string data)
|
||||||
{
|
{
|
||||||
|
|
@ -67,16 +68,14 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public static byte[] GetMd5Bytes(byte[] data)
|
public static byte[] GetMd5Bytes(byte[] data)
|
||||||
{
|
{
|
||||||
MD5Digest digest = new MD5Digest();
|
var digest = new MD5Digest();
|
||||||
digest.BlockUpdate(data, 0, data.Length);
|
digest.BlockUpdate(data, 0, data.Length);
|
||||||
byte[] hash = new byte[16];
|
var hash = new byte[16];
|
||||||
digest.DoFinal(hash, 0);
|
digest.DoFinal(hash, 0);
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MD5Digest digest = new MD5Digest();
|
|
||||||
|
|
||||||
public void Update(byte[] chunk)
|
public void Update(byte[] chunk)
|
||||||
{
|
{
|
||||||
digest.BlockUpdate(chunk, 0, chunk.Length);
|
digest.BlockUpdate(chunk, 0, chunk.Length);
|
||||||
|
|
@ -89,7 +88,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public string FinalString()
|
public string FinalString()
|
||||||
{
|
{
|
||||||
byte[] hash = new byte[16];
|
var hash = new byte[16];
|
||||||
digest.DoFinal(hash, 0);
|
digest.DoFinal(hash, 0);
|
||||||
return BitConverter.ToString(hash).Replace("-", "").ToLower();
|
return BitConverter.ToString(hash).Replace("-", "").ToLower();
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +139,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
//
|
//
|
||||||
// fill the current word
|
// fill the current word
|
||||||
//
|
//
|
||||||
while ((xBufOff != 0) && (length > 0))
|
while (xBufOff != 0 && length > 0)
|
||||||
{
|
{
|
||||||
Update(input[inOff]);
|
Update(input[inOff]);
|
||||||
inOff++;
|
inOff++;
|
||||||
|
|
@ -189,7 +188,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public void Finish()
|
public void Finish()
|
||||||
{
|
{
|
||||||
long bitLength = (byteCount << 3);
|
var bitLength = byteCount << 3;
|
||||||
|
|
||||||
//
|
//
|
||||||
// add the pad bytes.
|
// add the pad bytes.
|
||||||
|
|
@ -215,6 +214,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// round 1 left rotates
|
// round 1 left rotates
|
||||||
//
|
//
|
||||||
private static readonly int S11 = 7;
|
private static readonly int S11 = 7;
|
||||||
|
|
||||||
private static readonly int S12 = 12;
|
private static readonly int S12 = 12;
|
||||||
private static readonly int S13 = 17;
|
private static readonly int S13 = 17;
|
||||||
private static readonly int S14 = 22;
|
private static readonly int S14 = 22;
|
||||||
|
|
@ -223,6 +223,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// round 2 left rotates
|
// round 2 left rotates
|
||||||
//
|
//
|
||||||
private static readonly int S21 = 5;
|
private static readonly int S21 = 5;
|
||||||
|
|
||||||
private static readonly int S22 = 9;
|
private static readonly int S22 = 9;
|
||||||
private static readonly int S23 = 14;
|
private static readonly int S23 = 14;
|
||||||
private static readonly int S24 = 20;
|
private static readonly int S24 = 20;
|
||||||
|
|
@ -231,6 +232,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// round 3 left rotates
|
// round 3 left rotates
|
||||||
//
|
//
|
||||||
private static readonly int S31 = 4;
|
private static readonly int S31 = 4;
|
||||||
|
|
||||||
private static readonly int S32 = 11;
|
private static readonly int S32 = 11;
|
||||||
private static readonly int S33 = 16;
|
private static readonly int S33 = 16;
|
||||||
private static readonly int S34 = 23;
|
private static readonly int S34 = 23;
|
||||||
|
|
@ -239,6 +241,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// round 4 left rotates
|
// round 4 left rotates
|
||||||
//
|
//
|
||||||
private static readonly int S41 = 6;
|
private static readonly int S41 = 6;
|
||||||
|
|
||||||
private static readonly int S42 = 10;
|
private static readonly int S42 = 10;
|
||||||
private static readonly int S43 = 15;
|
private static readonly int S43 = 15;
|
||||||
private static readonly int S44 = 21;
|
private static readonly int S44 = 21;
|
||||||
|
|
@ -268,10 +271,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
xOff = t.xOff;
|
xOff = t.xOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string AlgorithmName
|
public override string AlgorithmName => "MD5";
|
||||||
{
|
|
||||||
get { return "MD5"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetDigestSize()
|
public override int GetDigestSize()
|
||||||
{
|
{
|
||||||
|
|
@ -286,21 +286,17 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
| ((input[inOff + 2] & 0xff) << 16) | ((input[inOff + 3] & 0xff) << 24);
|
| ((input[inOff + 2] & 0xff) << 16) | ((input[inOff + 3] & 0xff) << 24);
|
||||||
|
|
||||||
if (xOff == 16)
|
if (xOff == 16)
|
||||||
{
|
|
||||||
ProcessBlock();
|
ProcessBlock();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal override void ProcessLength(
|
internal override void ProcessLength(
|
||||||
long bitLength)
|
long bitLength)
|
||||||
{
|
{
|
||||||
if (xOff > 14)
|
if (xOff > 14)
|
||||||
{
|
|
||||||
ProcessBlock();
|
ProcessBlock();
|
||||||
}
|
|
||||||
|
|
||||||
X[14] = (int)(bitLength & 0xffffffff);
|
X[14] = (int) (bitLength & 0xffffffff);
|
||||||
X[15] = (int)((ulong)bitLength >> 32);
|
X[15] = (int) ((ulong) bitLength >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnpackWord(
|
private void UnpackWord(
|
||||||
|
|
@ -308,10 +304,10 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
byte[] outBytes,
|
byte[] outBytes,
|
||||||
int outOff)
|
int outOff)
|
||||||
{
|
{
|
||||||
outBytes[outOff] = (byte)word;
|
outBytes[outOff] = (byte) word;
|
||||||
outBytes[outOff + 1] = (byte)((uint)word >> 8);
|
outBytes[outOff + 1] = (byte) ((uint) word >> 8);
|
||||||
outBytes[outOff + 2] = (byte)((uint)word >> 16);
|
outBytes[outOff + 2] = (byte) ((uint) word >> 16);
|
||||||
outBytes[outOff + 3] = (byte)((uint)word >> 24);
|
outBytes[outOff + 3] = (byte) ((uint) word >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int DoFinal(
|
public override int DoFinal(
|
||||||
|
|
@ -338,18 +334,16 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
|
||||||
H1 = unchecked(0x67452301);
|
H1 = 0x67452301;
|
||||||
H2 = unchecked((int)0xefcdab89);
|
H2 = unchecked((int) 0xefcdab89);
|
||||||
H3 = unchecked((int)0x98badcfe);
|
H3 = unchecked((int) 0x98badcfe);
|
||||||
H4 = unchecked(0x10325476);
|
H4 = 0x10325476;
|
||||||
|
|
||||||
xOff = 0;
|
xOff = 0;
|
||||||
|
|
||||||
for (int i = 0; i != X.Length; i++)
|
for (var i = 0; i != X.Length; i++)
|
||||||
{
|
|
||||||
X[i] = 0;
|
X[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rotate int x left n bits.
|
* rotate int x left n bits.
|
||||||
|
|
@ -359,7 +353,7 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
int x,
|
int x,
|
||||||
int n)
|
int n)
|
||||||
{
|
{
|
||||||
return (x << n) | (int)((uint)x >> (32 - n));
|
return (x << n) | (int) ((uint) x >> (32 - n));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -400,90 +394,90 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
internal override void ProcessBlock()
|
internal override void ProcessBlock()
|
||||||
{
|
{
|
||||||
int a = H1;
|
var a = H1;
|
||||||
int b = H2;
|
var b = H2;
|
||||||
int c = H3;
|
var c = H3;
|
||||||
int d = H4;
|
var d = H4;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Round 1 - F cycle, 16 times.
|
// Round 1 - F cycle, 16 times.
|
||||||
//
|
//
|
||||||
a = RotateLeft((a + F(b, c, d) + X[0] + unchecked((int)0xd76aa478)), S11) + b;
|
a = RotateLeft(a + F(b, c, d) + X[0] + unchecked((int) 0xd76aa478), S11) + b;
|
||||||
d = RotateLeft((d + F(a, b, c) + X[1] + unchecked((int)0xe8c7b756)), S12) + a;
|
d = RotateLeft(d + F(a, b, c) + X[1] + unchecked((int) 0xe8c7b756), S12) + a;
|
||||||
c = RotateLeft((c + F(d, a, b) + X[2] + unchecked(0x242070db)), S13) + d;
|
c = RotateLeft(c + F(d, a, b) + X[2] + 0x242070db, S13) + d;
|
||||||
b = RotateLeft((b + F(c, d, a) + X[3] + unchecked((int)0xc1bdceee)), S14) + c;
|
b = RotateLeft(b + F(c, d, a) + X[3] + unchecked((int) 0xc1bdceee), S14) + c;
|
||||||
a = RotateLeft((a + F(b, c, d) + X[4] + unchecked((int)0xf57c0faf)), S11) + b;
|
a = RotateLeft(a + F(b, c, d) + X[4] + unchecked((int) 0xf57c0faf), S11) + b;
|
||||||
d = RotateLeft((d + F(a, b, c) + X[5] + unchecked(0x4787c62a)), S12) + a;
|
d = RotateLeft(d + F(a, b, c) + X[5] + 0x4787c62a, S12) + a;
|
||||||
c = RotateLeft((c + F(d, a, b) + X[6] + unchecked((int)0xa8304613)), S13) + d;
|
c = RotateLeft(c + F(d, a, b) + X[6] + unchecked((int) 0xa8304613), S13) + d;
|
||||||
b = RotateLeft((b + F(c, d, a) + X[7] + unchecked((int)0xfd469501)), S14) + c;
|
b = RotateLeft(b + F(c, d, a) + X[7] + unchecked((int) 0xfd469501), S14) + c;
|
||||||
a = RotateLeft((a + F(b, c, d) + X[8] + unchecked(0x698098d8)), S11) + b;
|
a = RotateLeft(a + F(b, c, d) + X[8] + 0x698098d8, S11) + b;
|
||||||
d = RotateLeft((d + F(a, b, c) + X[9] + unchecked((int)0x8b44f7af)), S12) + a;
|
d = RotateLeft(d + F(a, b, c) + X[9] + unchecked((int) 0x8b44f7af), S12) + a;
|
||||||
c = RotateLeft((c + F(d, a, b) + X[10] + unchecked((int)0xffff5bb1)), S13) + d;
|
c = RotateLeft(c + F(d, a, b) + X[10] + unchecked((int) 0xffff5bb1), S13) + d;
|
||||||
b = RotateLeft((b + F(c, d, a) + X[11] + unchecked((int)0x895cd7be)), S14) + c;
|
b = RotateLeft(b + F(c, d, a) + X[11] + unchecked((int) 0x895cd7be), S14) + c;
|
||||||
a = RotateLeft((a + F(b, c, d) + X[12] + unchecked(0x6b901122)), S11) + b;
|
a = RotateLeft(a + F(b, c, d) + X[12] + 0x6b901122, S11) + b;
|
||||||
d = RotateLeft((d + F(a, b, c) + X[13] + unchecked((int)0xfd987193)), S12) + a;
|
d = RotateLeft(d + F(a, b, c) + X[13] + unchecked((int) 0xfd987193), S12) + a;
|
||||||
c = RotateLeft((c + F(d, a, b) + X[14] + unchecked((int)0xa679438e)), S13) + d;
|
c = RotateLeft(c + F(d, a, b) + X[14] + unchecked((int) 0xa679438e), S13) + d;
|
||||||
b = RotateLeft((b + F(c, d, a) + X[15] + unchecked(0x49b40821)), S14) + c;
|
b = RotateLeft(b + F(c, d, a) + X[15] + 0x49b40821, S14) + c;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Round 2 - G cycle, 16 times.
|
// Round 2 - G cycle, 16 times.
|
||||||
//
|
//
|
||||||
a = RotateLeft((a + G(b, c, d) + X[1] + unchecked((int)0xf61e2562)), S21) + b;
|
a = RotateLeft(a + G(b, c, d) + X[1] + unchecked((int) 0xf61e2562), S21) + b;
|
||||||
d = RotateLeft((d + G(a, b, c) + X[6] + unchecked((int)0xc040b340)), S22) + a;
|
d = RotateLeft(d + G(a, b, c) + X[6] + unchecked((int) 0xc040b340), S22) + a;
|
||||||
c = RotateLeft((c + G(d, a, b) + X[11] + unchecked(0x265e5a51)), S23) + d;
|
c = RotateLeft(c + G(d, a, b) + X[11] + 0x265e5a51, S23) + d;
|
||||||
b = RotateLeft((b + G(c, d, a) + X[0] + unchecked((int)0xe9b6c7aa)), S24) + c;
|
b = RotateLeft(b + G(c, d, a) + X[0] + unchecked((int) 0xe9b6c7aa), S24) + c;
|
||||||
a = RotateLeft((a + G(b, c, d) + X[5] + unchecked((int)0xd62f105d)), S21) + b;
|
a = RotateLeft(a + G(b, c, d) + X[5] + unchecked((int) 0xd62f105d), S21) + b;
|
||||||
d = RotateLeft((d + G(a, b, c) + X[10] + unchecked(0x02441453)), S22) + a;
|
d = RotateLeft(d + G(a, b, c) + X[10] + 0x02441453, S22) + a;
|
||||||
c = RotateLeft((c + G(d, a, b) + X[15] + unchecked((int)0xd8a1e681)), S23) + d;
|
c = RotateLeft(c + G(d, a, b) + X[15] + unchecked((int) 0xd8a1e681), S23) + d;
|
||||||
b = RotateLeft((b + G(c, d, a) + X[4] + unchecked((int)0xe7d3fbc8)), S24) + c;
|
b = RotateLeft(b + G(c, d, a) + X[4] + unchecked((int) 0xe7d3fbc8), S24) + c;
|
||||||
a = RotateLeft((a + G(b, c, d) + X[9] + unchecked(0x21e1cde6)), S21) + b;
|
a = RotateLeft(a + G(b, c, d) + X[9] + 0x21e1cde6, S21) + b;
|
||||||
d = RotateLeft((d + G(a, b, c) + X[14] + unchecked((int)0xc33707d6)), S22) + a;
|
d = RotateLeft(d + G(a, b, c) + X[14] + unchecked((int) 0xc33707d6), S22) + a;
|
||||||
c = RotateLeft((c + G(d, a, b) + X[3] + unchecked((int)0xf4d50d87)), S23) + d;
|
c = RotateLeft(c + G(d, a, b) + X[3] + unchecked((int) 0xf4d50d87), S23) + d;
|
||||||
b = RotateLeft((b + G(c, d, a) + X[8] + unchecked(0x455a14ed)), S24) + c;
|
b = RotateLeft(b + G(c, d, a) + X[8] + 0x455a14ed, S24) + c;
|
||||||
a = RotateLeft((a + G(b, c, d) + X[13] + unchecked((int)0xa9e3e905)), S21) + b;
|
a = RotateLeft(a + G(b, c, d) + X[13] + unchecked((int) 0xa9e3e905), S21) + b;
|
||||||
d = RotateLeft((d + G(a, b, c) + X[2] + unchecked((int)0xfcefa3f8)), S22) + a;
|
d = RotateLeft(d + G(a, b, c) + X[2] + unchecked((int) 0xfcefa3f8), S22) + a;
|
||||||
c = RotateLeft((c + G(d, a, b) + X[7] + unchecked(0x676f02d9)), S23) + d;
|
c = RotateLeft(c + G(d, a, b) + X[7] + 0x676f02d9, S23) + d;
|
||||||
b = RotateLeft((b + G(c, d, a) + X[12] + unchecked((int)0x8d2a4c8a)), S24) + c;
|
b = RotateLeft(b + G(c, d, a) + X[12] + unchecked((int) 0x8d2a4c8a), S24) + c;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Round 3 - H cycle, 16 times.
|
// Round 3 - H cycle, 16 times.
|
||||||
//
|
//
|
||||||
a = RotateLeft((a + H(b, c, d) + X[5] + unchecked((int)0xfffa3942)), S31) + b;
|
a = RotateLeft(a + H(b, c, d) + X[5] + unchecked((int) 0xfffa3942), S31) + b;
|
||||||
d = RotateLeft((d + H(a, b, c) + X[8] + unchecked((int)0x8771f681)), S32) + a;
|
d = RotateLeft(d + H(a, b, c) + X[8] + unchecked((int) 0x8771f681), S32) + a;
|
||||||
c = RotateLeft((c + H(d, a, b) + X[11] + unchecked(0x6d9d6122)), S33) + d;
|
c = RotateLeft(c + H(d, a, b) + X[11] + 0x6d9d6122, S33) + d;
|
||||||
b = RotateLeft((b + H(c, d, a) + X[14] + unchecked((int)0xfde5380c)), S34) + c;
|
b = RotateLeft(b + H(c, d, a) + X[14] + unchecked((int) 0xfde5380c), S34) + c;
|
||||||
a = RotateLeft((a + H(b, c, d) + X[1] + unchecked((int)0xa4beea44)), S31) + b;
|
a = RotateLeft(a + H(b, c, d) + X[1] + unchecked((int) 0xa4beea44), S31) + b;
|
||||||
d = RotateLeft((d + H(a, b, c) + X[4] + unchecked(0x4bdecfa9)), S32) + a;
|
d = RotateLeft(d + H(a, b, c) + X[4] + 0x4bdecfa9, S32) + a;
|
||||||
c = RotateLeft((c + H(d, a, b) + X[7] + unchecked((int)0xf6bb4b60)), S33) + d;
|
c = RotateLeft(c + H(d, a, b) + X[7] + unchecked((int) 0xf6bb4b60), S33) + d;
|
||||||
b = RotateLeft((b + H(c, d, a) + X[10] + unchecked((int)0xbebfbc70)), S34) + c;
|
b = RotateLeft(b + H(c, d, a) + X[10] + unchecked((int) 0xbebfbc70), S34) + c;
|
||||||
a = RotateLeft((a + H(b, c, d) + X[13] + unchecked(0x289b7ec6)), S31) + b;
|
a = RotateLeft(a + H(b, c, d) + X[13] + 0x289b7ec6, S31) + b;
|
||||||
d = RotateLeft((d + H(a, b, c) + X[0] + unchecked((int)0xeaa127fa)), S32) + a;
|
d = RotateLeft(d + H(a, b, c) + X[0] + unchecked((int) 0xeaa127fa), S32) + a;
|
||||||
c = RotateLeft((c + H(d, a, b) + X[3] + unchecked((int)0xd4ef3085)), S33) + d;
|
c = RotateLeft(c + H(d, a, b) + X[3] + unchecked((int) 0xd4ef3085), S33) + d;
|
||||||
b = RotateLeft((b + H(c, d, a) + X[6] + unchecked(0x04881d05)), S34) + c;
|
b = RotateLeft(b + H(c, d, a) + X[6] + 0x04881d05, S34) + c;
|
||||||
a = RotateLeft((a + H(b, c, d) + X[9] + unchecked((int)0xd9d4d039)), S31) + b;
|
a = RotateLeft(a + H(b, c, d) + X[9] + unchecked((int) 0xd9d4d039), S31) + b;
|
||||||
d = RotateLeft((d + H(a, b, c) + X[12] + unchecked((int)0xe6db99e5)), S32) + a;
|
d = RotateLeft(d + H(a, b, c) + X[12] + unchecked((int) 0xe6db99e5), S32) + a;
|
||||||
c = RotateLeft((c + H(d, a, b) + X[15] + unchecked(0x1fa27cf8)), S33) + d;
|
c = RotateLeft(c + H(d, a, b) + X[15] + 0x1fa27cf8, S33) + d;
|
||||||
b = RotateLeft((b + H(c, d, a) + X[2] + unchecked((int)0xc4ac5665)), S34) + c;
|
b = RotateLeft(b + H(c, d, a) + X[2] + unchecked((int) 0xc4ac5665), S34) + c;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Round 4 - K cycle, 16 times.
|
// Round 4 - K cycle, 16 times.
|
||||||
//
|
//
|
||||||
a = RotateLeft((a + K(b, c, d) + X[0] + unchecked((int)0xf4292244)), S41) + b;
|
a = RotateLeft(a + K(b, c, d) + X[0] + unchecked((int) 0xf4292244), S41) + b;
|
||||||
d = RotateLeft((d + K(a, b, c) + X[7] + unchecked(0x432aff97)), S42) + a;
|
d = RotateLeft(d + K(a, b, c) + X[7] + 0x432aff97, S42) + a;
|
||||||
c = RotateLeft((c + K(d, a, b) + X[14] + unchecked((int)0xab9423a7)), S43) + d;
|
c = RotateLeft(c + K(d, a, b) + X[14] + unchecked((int) 0xab9423a7), S43) + d;
|
||||||
b = RotateLeft((b + K(c, d, a) + X[5] + unchecked((int)0xfc93a039)), S44) + c;
|
b = RotateLeft(b + K(c, d, a) + X[5] + unchecked((int) 0xfc93a039), S44) + c;
|
||||||
a = RotateLeft((a + K(b, c, d) + X[12] + unchecked(0x655b59c3)), S41) + b;
|
a = RotateLeft(a + K(b, c, d) + X[12] + 0x655b59c3, S41) + b;
|
||||||
d = RotateLeft((d + K(a, b, c) + X[3] + unchecked((int)0x8f0ccc92)), S42) + a;
|
d = RotateLeft(d + K(a, b, c) + X[3] + unchecked((int) 0x8f0ccc92), S42) + a;
|
||||||
c = RotateLeft((c + K(d, a, b) + X[10] + unchecked((int)0xffeff47d)), S43) + d;
|
c = RotateLeft(c + K(d, a, b) + X[10] + unchecked((int) 0xffeff47d), S43) + d;
|
||||||
b = RotateLeft((b + K(c, d, a) + X[1] + unchecked((int)0x85845dd1)), S44) + c;
|
b = RotateLeft(b + K(c, d, a) + X[1] + unchecked((int) 0x85845dd1), S44) + c;
|
||||||
a = RotateLeft((a + K(b, c, d) + X[8] + unchecked(0x6fa87e4f)), S41) + b;
|
a = RotateLeft(a + K(b, c, d) + X[8] + 0x6fa87e4f, S41) + b;
|
||||||
d = RotateLeft((d + K(a, b, c) + X[15] + unchecked((int)0xfe2ce6e0)), S42) + a;
|
d = RotateLeft(d + K(a, b, c) + X[15] + unchecked((int) 0xfe2ce6e0), S42) + a;
|
||||||
c = RotateLeft((c + K(d, a, b) + X[6] + unchecked((int)0xa3014314)), S43) + d;
|
c = RotateLeft(c + K(d, a, b) + X[6] + unchecked((int) 0xa3014314), S43) + d;
|
||||||
b = RotateLeft((b + K(c, d, a) + X[13] + unchecked(0x4e0811a1)), S44) + c;
|
b = RotateLeft(b + K(c, d, a) + X[13] + 0x4e0811a1, S44) + c;
|
||||||
a = RotateLeft((a + K(b, c, d) + X[4] + unchecked((int)0xf7537e82)), S41) + b;
|
a = RotateLeft(a + K(b, c, d) + X[4] + unchecked((int) 0xf7537e82), S41) + b;
|
||||||
d = RotateLeft((d + K(a, b, c) + X[11] + unchecked((int)0xbd3af235)), S42) + a;
|
d = RotateLeft(d + K(a, b, c) + X[11] + unchecked((int) 0xbd3af235), S42) + a;
|
||||||
c = RotateLeft((c + K(d, a, b) + X[2] + unchecked(0x2ad7d2bb)), S43) + d;
|
c = RotateLeft(c + K(d, a, b) + X[2] + 0x2ad7d2bb, S43) + d;
|
||||||
b = RotateLeft((b + K(c, d, a) + X[9] + unchecked((int)0xeb86d391)), S44) + c;
|
b = RotateLeft(b + K(c, d, a) + X[9] + unchecked((int) 0xeb86d391), S44) + c;
|
||||||
|
|
||||||
H1 += a;
|
H1 += a;
|
||||||
H2 += b;
|
H2 += b;
|
||||||
|
|
@ -494,10 +488,8 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
// reset the offset and clean out the word buffer.
|
// reset the offset and clean out the word buffer.
|
||||||
//
|
//
|
||||||
xOff = 0;
|
xOff = 0;
|
||||||
for (int i = 0; i != X.Length; i++)
|
for (var i = 0; i != X.Length; i++)
|
||||||
{
|
|
||||||
X[i] = 0;
|
X[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,13 +5,12 @@ using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace TLSharp.Core.MTProto.Crypto
|
namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
|
internal class RSAServerKey
|
||||||
class RSAServerKey
|
|
||||||
{
|
{
|
||||||
|
private readonly BigInteger e;
|
||||||
|
|
||||||
private string fingerprint;
|
private string fingerprint;
|
||||||
private BigInteger m;
|
private readonly BigInteger m;
|
||||||
private BigInteger e;
|
|
||||||
|
|
||||||
public RSAServerKey(string fingerprint, BigInteger m, BigInteger e)
|
public RSAServerKey(string fingerprint, BigInteger m, BigInteger e)
|
||||||
{
|
{
|
||||||
|
|
@ -22,62 +21,63 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
|
|
||||||
public byte[] Encrypt(byte[] data, int offset, int length)
|
public byte[] Encrypt(byte[] data, int offset, int length)
|
||||||
{
|
{
|
||||||
|
using (var buffer = new MemoryStream(255))
|
||||||
using (MemoryStream buffer = new MemoryStream(255))
|
using (var writer = new BinaryWriter(buffer))
|
||||||
using (BinaryWriter writer = new BinaryWriter(buffer))
|
|
||||||
{
|
{
|
||||||
using (SHA1 sha1 = new SHA1Managed())
|
using (SHA1 sha1 = new SHA1Managed())
|
||||||
{
|
{
|
||||||
byte[] hashsum = sha1.ComputeHash(data, offset, length);
|
var hashsum = sha1.ComputeHash(data, offset, length);
|
||||||
writer.Write(hashsum);
|
writer.Write(hashsum);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.Write(data, offset, length);
|
buffer.Write(data, offset, length);
|
||||||
if (length < 235)
|
if (length < 235)
|
||||||
{
|
{
|
||||||
byte[] padding = new byte[235 - length];
|
var padding = new byte[235 - length];
|
||||||
new Random().NextBytes(padding);
|
new Random().NextBytes(padding);
|
||||||
buffer.Write(padding, 0, padding.Length);
|
buffer.Write(padding, 0, padding.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] ciphertext = new BigInteger(1, buffer.ToArray()).ModPow(e, m).ToByteArrayUnsigned();
|
var ciphertext = new BigInteger(1, buffer.ToArray()).ModPow(e, m).ToByteArrayUnsigned();
|
||||||
|
|
||||||
if (ciphertext.Length == 256)
|
if (ciphertext.Length == 256)
|
||||||
{
|
{
|
||||||
return ciphertext;
|
return ciphertext;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
byte[] paddedCiphertext = new byte[256];
|
|
||||||
int padding = 256 - ciphertext.Length;
|
|
||||||
for (int i = 0; i < padding; i++)
|
|
||||||
{
|
{
|
||||||
|
var paddedCiphertext = new byte[256];
|
||||||
|
var padding = 256 - ciphertext.Length;
|
||||||
|
for (var i = 0; i < padding; i++)
|
||||||
paddedCiphertext[i] = 0;
|
paddedCiphertext[i] = 0;
|
||||||
}
|
|
||||||
ciphertext.CopyTo(paddedCiphertext, padding);
|
ciphertext.CopyTo(paddedCiphertext, padding);
|
||||||
return paddedCiphertext;
|
return paddedCiphertext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class RSA
|
public class RSA
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, RSAServerKey> serverKeys = new Dictionary<string, RSAServerKey>() {
|
private static readonly Dictionary<string, RSAServerKey> serverKeys = new Dictionary<string, RSAServerKey>
|
||||||
{ "216be86c022bb4c3", new RSAServerKey("216be86c022bb4c3", new BigInteger("00C150023E2F70DB7985DED064759CFECF0AF328E69A41DAF4D6F01B538135A6F91F8F8B2A0EC9BA9720CE352EFCF6C5680FFC424BD634864902DE0B4BD6D49F4E580230E3AE97D95C8B19442B3C0A10D8F5633FECEDD6926A7F6DAB0DDB7D457F9EA81B8465FCD6FFFEED114011DF91C059CAEDAF97625F6C96ECC74725556934EF781D866B34F011FCE4D835A090196E9A5F0E4449AF7EB697DDB9076494CA5F81104A305B6DD27665722C46B60E5DF680FB16B210607EF217652E60236C255F6A28315F4083A96791D7214BF64C1DF4FD0DB1944FB26A2A57031B32EEE64AD15A8BA68885CDE74A5BFC920F6ABF59BA5C75506373E7130F9042DA922179251F", 16), new BigInteger("010001", 16)) }
|
{
|
||||||
|
{
|
||||||
|
"216be86c022bb4c3",
|
||||||
|
new RSAServerKey("216be86c022bb4c3",
|
||||||
|
new BigInteger(
|
||||||
|
"00C150023E2F70DB7985DED064759CFECF0AF328E69A41DAF4D6F01B538135A6F91F8F8B2A0EC9BA9720CE352EFCF6C5680FFC424BD634864902DE0B4BD6D49F4E580230E3AE97D95C8B19442B3C0A10D8F5633FECEDD6926A7F6DAB0DDB7D457F9EA81B8465FCD6FFFEED114011DF91C059CAEDAF97625F6C96ECC74725556934EF781D866B34F011FCE4D835A090196E9A5F0E4449AF7EB697DDB9076494CA5F81104A305B6DD27665722C46B60E5DF680FB16B210607EF217652E60236C255F6A28315F4083A96791D7214BF64C1DF4FD0DB1944FB26A2A57031B32EEE64AD15A8BA68885CDE74A5BFC920F6ABF59BA5C75506373E7130F9042DA922179251F",
|
||||||
|
16), new BigInteger("010001", 16))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static byte[] Encrypt(string fingerprint, byte[] data, int offset, int length)
|
public static byte[] Encrypt(string fingerprint, byte[] data, int offset, int length)
|
||||||
{
|
{
|
||||||
string fingerprintLower = fingerprint.ToLower();
|
var fingerprintLower = fingerprint.ToLower();
|
||||||
if (!serverKeys.ContainsKey(fingerprintLower))
|
if (!serverKeys.ContainsKey(fingerprintLower))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
RSAServerKey key = serverKeys[fingerprintLower];
|
var key = serverKeys[fingerprintLower];
|
||||||
|
|
||||||
return key.Encrypt(data, offset, length);
|
return key.Encrypt(data, offset, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,26 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TLSharp.Core.MTProto.Crypto
|
namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
public class Salt : IComparable<Salt>
|
public class Salt : IComparable<Salt>
|
||||||
{
|
{
|
||||||
private int validSince;
|
|
||||||
private int validUntil;
|
|
||||||
private ulong salt;
|
|
||||||
|
|
||||||
public Salt(int validSince, int validUntil, ulong salt)
|
public Salt(int validSince, int validUntil, ulong salt)
|
||||||
{
|
{
|
||||||
this.validSince = validSince;
|
ValidSince = validSince;
|
||||||
this.validUntil = validUntil;
|
ValidUntil = validUntil;
|
||||||
this.salt = salt;
|
Value = salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ValidSince
|
public int ValidSince { get; }
|
||||||
{
|
|
||||||
get { return validSince; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ValidUntil
|
public int ValidUntil { get; }
|
||||||
{
|
|
||||||
get { return validUntil; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong Value
|
public ulong Value { get; }
|
||||||
{
|
|
||||||
get { return salt; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CompareTo(Salt other)
|
public int CompareTo(Salt other)
|
||||||
{
|
{
|
||||||
return validUntil.CompareTo(other.validSince);
|
return ValidUntil.CompareTo(other.ValidSince);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,51 +28,33 @@ namespace TLSharp.Core.MTProto.Crypto
|
||||||
{
|
{
|
||||||
private SortedSet<Salt> salts;
|
private SortedSet<Salt> salts;
|
||||||
|
|
||||||
|
public int Count => salts.Count;
|
||||||
|
|
||||||
public void Add(Salt salt)
|
public void Add(Salt salt)
|
||||||
{
|
{
|
||||||
salts.Add(salt);
|
salts.Add(salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return salts.Count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: get actual salt and other...
|
// TODO: get actual salt and other...
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetFutureSaltsResponse
|
public class GetFutureSaltsResponse
|
||||||
{
|
{
|
||||||
private ulong requestId;
|
|
||||||
private int now;
|
|
||||||
private SaltCollection salts;
|
|
||||||
|
|
||||||
public GetFutureSaltsResponse(ulong requestId, int now)
|
public GetFutureSaltsResponse(ulong requestId, int now)
|
||||||
{
|
{
|
||||||
this.requestId = requestId;
|
RequestId = requestId;
|
||||||
this.now = now;
|
Now = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ulong RequestId { get; }
|
||||||
|
|
||||||
|
public int Now { get; }
|
||||||
|
|
||||||
|
public SaltCollection Salts { get; }
|
||||||
|
|
||||||
public void AddSalt(Salt salt)
|
public void AddSalt(Salt salt)
|
||||||
{
|
{
|
||||||
salts.Add(salt);
|
Salts.Add(salt);
|
||||||
}
|
|
||||||
|
|
||||||
public ulong RequestId
|
|
||||||
{
|
|
||||||
get { return requestId; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Now
|
|
||||||
{
|
|
||||||
get { return now; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaltCollection Salts
|
|
||||||
{
|
|
||||||
get { return salts; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,24 +6,32 @@ namespace TLSharp.Core.MTProto
|
||||||
{
|
{
|
||||||
public class Serializers
|
public class Serializers
|
||||||
{
|
{
|
||||||
|
public static string VectorToString<T>(List<T> list)
|
||||||
|
{
|
||||||
|
var tokens = new string[list.Count];
|
||||||
|
for (var i = 0; i < list.Count; i++)
|
||||||
|
tokens[i] = list[i].ToString();
|
||||||
|
return "[" + string.Join(", ", tokens) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
public static class Bytes
|
public static class Bytes
|
||||||
{
|
{
|
||||||
public static byte[] read(BinaryReader binaryReader)
|
public static byte[] read(BinaryReader binaryReader)
|
||||||
{
|
{
|
||||||
byte firstByte = binaryReader.ReadByte();
|
var firstByte = binaryReader.ReadByte();
|
||||||
int len, padding;
|
int len, padding;
|
||||||
if (firstByte == 254)
|
if (firstByte == 254)
|
||||||
{
|
{
|
||||||
len = binaryReader.ReadByte() | (binaryReader.ReadByte() << 8) | (binaryReader.ReadByte() << 16);
|
len = binaryReader.ReadByte() | (binaryReader.ReadByte() << 8) | (binaryReader.ReadByte() << 16);
|
||||||
padding = len % 4;
|
padding = len % 4;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
len = firstByte;
|
len = firstByte;
|
||||||
padding = (len + 1) % 4;
|
padding = (len + 1) % 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = binaryReader.ReadBytes(len);
|
var data = binaryReader.ReadBytes(len);
|
||||||
if (padding > 0)
|
if (padding > 0)
|
||||||
{
|
{
|
||||||
padding = 4 - padding;
|
padding = 4 - padding;
|
||||||
|
|
@ -40,32 +48,27 @@ namespace TLSharp.Core.MTProto
|
||||||
{
|
{
|
||||||
padding = (data.Length + 1) % 4;
|
padding = (data.Length + 1) % 4;
|
||||||
if (padding != 0)
|
if (padding != 0)
|
||||||
{
|
|
||||||
padding = 4 - padding;
|
padding = 4 - padding;
|
||||||
}
|
|
||||||
|
|
||||||
binaryWriter.Write((byte)data.Length);
|
binaryWriter.Write((byte) data.Length);
|
||||||
binaryWriter.Write(data);
|
binaryWriter.Write(data);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
padding = (data.Length) % 4;
|
{
|
||||||
|
padding = data.Length % 4;
|
||||||
if (padding != 0)
|
if (padding != 0)
|
||||||
{
|
|
||||||
padding = 4 - padding;
|
padding = 4 - padding;
|
||||||
}
|
|
||||||
|
|
||||||
binaryWriter.Write((byte)254);
|
binaryWriter.Write((byte) 254);
|
||||||
binaryWriter.Write((byte)(data.Length));
|
binaryWriter.Write((byte) data.Length);
|
||||||
binaryWriter.Write((byte)(data.Length >> 8));
|
binaryWriter.Write((byte) (data.Length >> 8));
|
||||||
binaryWriter.Write((byte)(data.Length >> 16));
|
binaryWriter.Write((byte) (data.Length >> 16));
|
||||||
binaryWriter.Write(data);
|
binaryWriter.Write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < padding; i++)
|
for (var i = 0; i < padding; i++)
|
||||||
{
|
binaryWriter.Write((byte) 0);
|
||||||
binaryWriter.Write((byte)0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return binaryWriter;
|
return binaryWriter;
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +78,7 @@ namespace TLSharp.Core.MTProto
|
||||||
{
|
{
|
||||||
public static string read(BinaryReader reader)
|
public static string read(BinaryReader reader)
|
||||||
{
|
{
|
||||||
byte[] data = Bytes.read(reader);
|
var data = Bytes.read(reader);
|
||||||
return Encoding.UTF8.GetString(data, 0, data.Length);
|
return Encoding.UTF8.GetString(data, 0, data.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,15 +87,5 @@ namespace TLSharp.Core.MTProto
|
||||||
return Bytes.write(writer, Encoding.UTF8.GetBytes(str));
|
return Bytes.write(writer, Encoding.UTF8.GetBytes(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string VectorToString<T>(List<T> list)
|
|
||||||
{
|
|
||||||
string[] tokens = new string[list.Count];
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
|
||||||
{
|
|
||||||
tokens[i] = list[i].ToString();
|
|
||||||
}
|
|
||||||
return "[" + System.String.Join(", ", tokens) + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,11 +6,11 @@ namespace TLSharp.Core.Network
|
||||||
{
|
{
|
||||||
public class MtProtoPlainSender
|
public class MtProtoPlainSender
|
||||||
{
|
{
|
||||||
|
private readonly TcpTransport _transport;
|
||||||
|
private long lastMessageId;
|
||||||
|
private readonly Random random;
|
||||||
private int sequence = 0;
|
private int sequence = 0;
|
||||||
private int timeOffset;
|
private int timeOffset;
|
||||||
private long lastMessageId;
|
|
||||||
private Random random;
|
|
||||||
private TcpTransport _transport;
|
|
||||||
|
|
||||||
public MtProtoPlainSender(TcpTransport transport)
|
public MtProtoPlainSender(TcpTransport transport)
|
||||||
{
|
{
|
||||||
|
|
@ -24,12 +24,12 @@ namespace TLSharp.Core.Network
|
||||||
{
|
{
|
||||||
using (var binaryWriter = new BinaryWriter(memoryStream))
|
using (var binaryWriter = new BinaryWriter(memoryStream))
|
||||||
{
|
{
|
||||||
binaryWriter.Write((long)0);
|
binaryWriter.Write((long) 0);
|
||||||
binaryWriter.Write(GetNewMessageId());
|
binaryWriter.Write(GetNewMessageId());
|
||||||
binaryWriter.Write(data.Length);
|
binaryWriter.Write(data.Length);
|
||||||
binaryWriter.Write(data);
|
binaryWriter.Write(data);
|
||||||
|
|
||||||
byte[] packet = memoryStream.ToArray();
|
var packet = memoryStream.ToArray();
|
||||||
|
|
||||||
await _transport.Send(packet);
|
await _transport.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
@ -42,13 +42,13 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
using (var memoryStream = new MemoryStream(result.Body))
|
using (var memoryStream = new MemoryStream(result.Body))
|
||||||
{
|
{
|
||||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream))
|
using (var binaryReader = new BinaryReader(memoryStream))
|
||||||
{
|
{
|
||||||
long authKeyid = binaryReader.ReadInt64();
|
var authKeyid = binaryReader.ReadInt64();
|
||||||
long messageId = binaryReader.ReadInt64();
|
var messageId = binaryReader.ReadInt64();
|
||||||
int messageLength = binaryReader.ReadInt32();
|
var messageLength = binaryReader.ReadInt32();
|
||||||
|
|
||||||
byte[] response = binaryReader.ReadBytes(messageLength);
|
var response = binaryReader.ReadBytes(messageLength);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
@ -57,21 +57,17 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
private long GetNewMessageId()
|
private long GetNewMessageId()
|
||||||
{
|
{
|
||||||
long time = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
var time = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
||||||
long newMessageId = ((time / 1000 + timeOffset) << 32) |
|
var newMessageId = ((time / 1000 + timeOffset) << 32) |
|
||||||
((time % 1000) << 22) |
|
((time % 1000) << 22) |
|
||||||
(random.Next(524288) << 2); // 2^19
|
(random.Next(524288) << 2); // 2^19
|
||||||
// [ unix timestamp : 32 bit] [ milliseconds : 10 bit ] [ buffer space : 1 bit ] [ random : 19 bit ] [ msg_id type : 2 bit ] = [ msg_id : 64 bit ]
|
// [ unix timestamp : 32 bit] [ milliseconds : 10 bit ] [ buffer space : 1 bit ] [ random : 19 bit ] [ msg_id type : 2 bit ] = [ msg_id : 64 bit ]
|
||||||
|
|
||||||
if (lastMessageId >= newMessageId)
|
if (lastMessageId >= newMessageId)
|
||||||
{
|
|
||||||
newMessageId = lastMessageId + 4;
|
newMessageId = lastMessageId + 4;
|
||||||
}
|
|
||||||
|
|
||||||
lastMessageId = newMessageId;
|
lastMessageId = newMessageId;
|
||||||
return newMessageId;
|
return newMessageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ionic.Zlib;
|
using Ionic.Zlib;
|
||||||
|
using TeleSharp.TL;
|
||||||
using TLSharp.Core.MTProto;
|
using TLSharp.Core.MTProto;
|
||||||
using TLSharp.Core.MTProto.Crypto;
|
using TLSharp.Core.MTProto.Crypto;
|
||||||
using TLSharp.Core.Requests;
|
using TLSharp.Core.Requests;
|
||||||
|
|
@ -16,10 +15,10 @@ namespace TLSharp.Core.Network
|
||||||
{
|
{
|
||||||
public class MtProtoSender
|
public class MtProtoSender
|
||||||
{
|
{
|
||||||
|
private readonly Session _session;
|
||||||
//private ulong sessionId = GenerateRandomUlong();
|
//private ulong sessionId = GenerateRandomUlong();
|
||||||
|
|
||||||
private TcpTransport _transport;
|
private TcpTransport _transport;
|
||||||
private Session _session;
|
|
||||||
|
|
||||||
public List<ulong> needConfirmation = new List<ulong>();
|
public List<ulong> needConfirmation = new List<ulong>();
|
||||||
|
|
||||||
|
|
@ -39,7 +38,7 @@ namespace TLSharp.Core.Network
|
||||||
return confirmed ? _session.Sequence++ * 2 + 1 : _session.Sequence * 2;
|
return confirmed ? _session.Sequence++ * 2 + 1 : _session.Sequence * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Send(TeleSharp.TL.TLMethod request)
|
public async Task Send(TLMethod request)
|
||||||
{
|
{
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
if (needConfirmation.Any())
|
if (needConfirmation.Any())
|
||||||
|
|
@ -65,15 +64,15 @@ namespace TLSharp.Core.Network
|
||||||
_session.Save();
|
_session.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Send(byte[] packet, TeleSharp.TL.TLMethod request)
|
public async Task Send(byte[] packet, TLMethod request)
|
||||||
{
|
{
|
||||||
request.MessageId = _session.GetNewMessageId();
|
request.MessageId = _session.GetNewMessageId();
|
||||||
|
|
||||||
byte[] msgKey;
|
byte[] msgKey;
|
||||||
byte[] ciphertext;
|
byte[] ciphertext;
|
||||||
using (MemoryStream plaintextPacket = makeMemory(8 + 8 + 8 + 4 + 4 + packet.Length))
|
using (var plaintextPacket = makeMemory(8 + 8 + 8 + 4 + 4 + packet.Length))
|
||||||
{
|
{
|
||||||
using (BinaryWriter plaintextWriter = new BinaryWriter(plaintextPacket))
|
using (var plaintextWriter = new BinaryWriter(plaintextPacket))
|
||||||
{
|
{
|
||||||
plaintextWriter.Write(_session.Salt);
|
plaintextWriter.Write(_session.Salt);
|
||||||
plaintextWriter.Write(_session.Id);
|
plaintextWriter.Write(_session.Id);
|
||||||
|
|
@ -83,13 +82,14 @@ namespace TLSharp.Core.Network
|
||||||
plaintextWriter.Write(packet);
|
plaintextWriter.Write(packet);
|
||||||
|
|
||||||
msgKey = Helpers.CalcMsgKey(plaintextPacket.GetBuffer());
|
msgKey = Helpers.CalcMsgKey(plaintextPacket.GetBuffer());
|
||||||
ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true), plaintextPacket.GetBuffer());
|
ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true),
|
||||||
|
plaintextPacket.GetBuffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (MemoryStream ciphertextPacket = makeMemory(8 + 16 + ciphertext.Length))
|
using (var ciphertextPacket = makeMemory(8 + 16 + ciphertext.Length))
|
||||||
{
|
{
|
||||||
using (BinaryWriter writer = new BinaryWriter(ciphertextPacket))
|
using (var writer = new BinaryWriter(ciphertextPacket))
|
||||||
{
|
{
|
||||||
writer.Write(_session.AuthKey.Id);
|
writer.Write(_session.AuthKey.Id);
|
||||||
writer.Write(msgKey);
|
writer.Write(msgKey);
|
||||||
|
|
@ -112,27 +112,28 @@ namespace TLSharp.Core.Network
|
||||||
if (inputReader.BaseStream.Length < 8)
|
if (inputReader.BaseStream.Length < 8)
|
||||||
throw new InvalidOperationException($"Can't decode packet");
|
throw new InvalidOperationException($"Can't decode packet");
|
||||||
|
|
||||||
ulong remoteAuthKeyId = inputReader.ReadUInt64(); // TODO: check auth key id
|
var remoteAuthKeyId = inputReader.ReadUInt64(); // TODO: check auth key id
|
||||||
byte[] msgKey = inputReader.ReadBytes(16); // TODO: check msg_key correctness
|
var msgKey = inputReader.ReadBytes(16); // TODO: check msg_key correctness
|
||||||
AESKeyData keyData = Helpers.CalcKey(_session.AuthKey.Data, msgKey, false);
|
var keyData = Helpers.CalcKey(_session.AuthKey.Data, msgKey, false);
|
||||||
|
|
||||||
byte[] plaintext = AES.DecryptAES(keyData, inputReader.ReadBytes((int)(inputStream.Length - inputStream.Position)));
|
var plaintext = AES.DecryptAES(keyData,
|
||||||
|
inputReader.ReadBytes((int) (inputStream.Length - inputStream.Position)));
|
||||||
|
|
||||||
using (MemoryStream plaintextStream = new MemoryStream(plaintext))
|
using (var plaintextStream = new MemoryStream(plaintext))
|
||||||
using (BinaryReader plaintextReader = new BinaryReader(plaintextStream))
|
using (var plaintextReader = new BinaryReader(plaintextStream))
|
||||||
{
|
{
|
||||||
var remoteSalt = plaintextReader.ReadUInt64();
|
var remoteSalt = plaintextReader.ReadUInt64();
|
||||||
var remoteSessionId = plaintextReader.ReadUInt64();
|
var remoteSessionId = plaintextReader.ReadUInt64();
|
||||||
remoteMessageId = plaintextReader.ReadUInt64();
|
remoteMessageId = plaintextReader.ReadUInt64();
|
||||||
remoteSequence = plaintextReader.ReadInt32();
|
remoteSequence = plaintextReader.ReadInt32();
|
||||||
int msgLen = plaintextReader.ReadInt32();
|
var msgLen = plaintextReader.ReadInt32();
|
||||||
message = plaintextReader.ReadBytes(msgLen);
|
message = plaintextReader.ReadBytes(msgLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Tuple<byte[], ulong, int>(message, remoteMessageId, remoteSequence);
|
return new Tuple<byte[], ulong, int>(message, remoteMessageId, remoteSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<byte[]> Receive(TeleSharp.TL.TLMethod request)
|
public async Task<byte[]> Receive(TLMethod request)
|
||||||
{
|
{
|
||||||
while (!request.ConfirmReceived)
|
while (!request.ConfirmReceived)
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +162,7 @@ namespace TLSharp.Core.Network
|
||||||
await Receive(pingRequest);
|
await Receive(pingRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
// TODO: check salt
|
// TODO: check salt
|
||||||
// TODO: check sessionid
|
// TODO: check sessionid
|
||||||
|
|
@ -170,7 +171,7 @@ namespace TLSharp.Core.Network
|
||||||
//logger.debug("processMessage: msg_id {0}, sequence {1}, data {2}", BitConverter.ToString(((MemoryStream)messageReader.BaseStream).GetBuffer(), (int) messageReader.BaseStream.Position, (int) (messageReader.BaseStream.Length - messageReader.BaseStream.Position)).Replace("-","").ToLower());
|
//logger.debug("processMessage: msg_id {0}, sequence {1}, data {2}", BitConverter.ToString(((MemoryStream)messageReader.BaseStream).GetBuffer(), (int) messageReader.BaseStream.Position, (int) (messageReader.BaseStream.Length - messageReader.BaseStream.Position)).Replace("-","").ToLower());
|
||||||
needConfirmation.Add(messageId);
|
needConfirmation.Add(messageId);
|
||||||
|
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
messageReader.BaseStream.Position -= 4;
|
messageReader.BaseStream.Position -= 4;
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
|
|
@ -238,12 +239,12 @@ namespace TLSharp.Core.Network
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader));
|
byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader));
|
||||||
using (MemoryStream packedStream = new MemoryStream(packedData, false))
|
using (var packedStream = new MemoryStream(packedData, false))
|
||||||
using (BinaryReader compressedReader = new BinaryReader(packedStream))
|
using (var compressedReader = new BinaryReader(packedStream))
|
||||||
{
|
{
|
||||||
processMessage(messageId, sequence, compressedReader, request);
|
processMessage(messageId, sequence, compressedReader, request);
|
||||||
}
|
}
|
||||||
|
|
@ -251,12 +252,12 @@ namespace TLSharp.Core.Network
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HandleRpcResult(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool HandleRpcResult(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
ulong requestId = messageReader.ReadUInt64();
|
var requestId = messageReader.ReadUInt64();
|
||||||
|
|
||||||
if (requestId == (ulong)request.MessageId)
|
if (requestId == (ulong) request.MessageId)
|
||||||
request.ConfirmReceived = true;
|
request.ConfirmReceived = true;
|
||||||
|
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
|
|
@ -275,11 +276,12 @@ namespace TLSharp.Core.Network
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint innerCode = messageReader.ReadUInt32();
|
var innerCode = messageReader.ReadUInt32();
|
||||||
if (innerCode == 0x2144ca19)
|
if (innerCode == 0x2144ca19)
|
||||||
{ // rpc_error
|
{
|
||||||
int errorCode = messageReader.ReadInt32();
|
// rpc_error
|
||||||
string errorMessage = Serializers.String.read(messageReader);
|
var errorCode = messageReader.ReadInt32();
|
||||||
|
var errorMessage = Serializers.String.read(messageReader);
|
||||||
|
|
||||||
if (errorMessage.StartsWith("FLOOD_WAIT_"))
|
if (errorMessage.StartsWith("FLOOD_WAIT_"))
|
||||||
{
|
{
|
||||||
|
|
@ -287,44 +289,37 @@ namespace TLSharp.Core.Network
|
||||||
var seconds = int.Parse(resultString);
|
var seconds = int.Parse(resultString);
|
||||||
throw new FloodException(TimeSpan.FromSeconds(seconds));
|
throw new FloodException(TimeSpan.FromSeconds(seconds));
|
||||||
}
|
}
|
||||||
else if (errorMessage.StartsWith("PHONE_MIGRATE_"))
|
if (errorMessage.StartsWith("PHONE_MIGRATE_"))
|
||||||
{
|
{
|
||||||
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
||||||
var dcIdx = int.Parse(resultString);
|
var dcIdx = int.Parse(resultString);
|
||||||
throw new PhoneMigrationException(dcIdx);
|
throw new PhoneMigrationException(dcIdx);
|
||||||
}
|
}
|
||||||
else if (errorMessage.StartsWith("FILE_MIGRATE_"))
|
if (errorMessage.StartsWith("FILE_MIGRATE_"))
|
||||||
{
|
{
|
||||||
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
||||||
var dcIdx = int.Parse(resultString);
|
var dcIdx = int.Parse(resultString);
|
||||||
throw new FileMigrationException(dcIdx);
|
throw new FileMigrationException(dcIdx);
|
||||||
}
|
}
|
||||||
else if (errorMessage.StartsWith("USER_MIGRATE_"))
|
if (errorMessage.StartsWith("USER_MIGRATE_"))
|
||||||
{
|
{
|
||||||
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
||||||
var dcIdx = int.Parse(resultString);
|
var dcIdx = int.Parse(resultString);
|
||||||
throw new UserMigrationException(dcIdx);
|
throw new UserMigrationException(dcIdx);
|
||||||
}
|
}
|
||||||
else if (errorMessage == "PHONE_CODE_INVALID")
|
if (errorMessage == "PHONE_CODE_INVALID")
|
||||||
{
|
throw new InvalidPhoneCodeException(
|
||||||
throw new InvalidPhoneCodeException("The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram");
|
"The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram");
|
||||||
}
|
if (errorMessage == "SESSION_PASSWORD_NEEDED")
|
||||||
else if (errorMessage == "SESSION_PASSWORD_NEEDED")
|
|
||||||
{
|
|
||||||
throw new CloudPasswordNeededException("This Account has Cloud Password !");
|
throw new CloudPasswordNeededException("This Account has Cloud Password !");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(errorMessage);
|
throw new InvalidOperationException(errorMessage);
|
||||||
}
|
}
|
||||||
|
if (innerCode == 0x3072cfa1)
|
||||||
}
|
|
||||||
else if (innerCode == 0x3072cfa1)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// gzip_packed
|
// gzip_packed
|
||||||
byte[] packedData = Serializers.Bytes.read(messageReader);
|
var packedData = Serializers.Bytes.read(messageReader);
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
using (var packedStream = new MemoryStream(packedData, false))
|
using (var packedStream = new MemoryStream(packedData, false))
|
||||||
|
|
@ -341,7 +336,6 @@ namespace TLSharp.Core.Network
|
||||||
}
|
}
|
||||||
catch (ZlibException ex)
|
catch (ZlibException ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -360,36 +354,44 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
private bool HandleBadMsgNotification(ulong messageId, int sequence, BinaryReader messageReader)
|
private bool HandleBadMsgNotification(ulong messageId, int sequence, BinaryReader messageReader)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
ulong requestId = messageReader.ReadUInt64();
|
var requestId = messageReader.ReadUInt64();
|
||||||
int requestSequence = messageReader.ReadInt32();
|
var requestSequence = messageReader.ReadInt32();
|
||||||
int errorCode = messageReader.ReadInt32();
|
var errorCode = messageReader.ReadInt32();
|
||||||
|
|
||||||
switch (errorCode)
|
switch (errorCode)
|
||||||
{
|
{
|
||||||
case 16:
|
case 16:
|
||||||
throw new InvalidOperationException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)");
|
throw new InvalidOperationException(
|
||||||
|
"msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)");
|
||||||
case 17:
|
case 17:
|
||||||
throw new InvalidOperationException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)");
|
throw new InvalidOperationException(
|
||||||
|
"msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)");
|
||||||
case 18:
|
case 18:
|
||||||
throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)");
|
throw new InvalidOperationException(
|
||||||
|
"incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)");
|
||||||
case 19:
|
case 19:
|
||||||
throw new InvalidOperationException("container msg_id is the same as msg_id of a previously received message (this must never happen)");
|
throw new InvalidOperationException(
|
||||||
|
"container msg_id is the same as msg_id of a previously received message (this must never happen)");
|
||||||
case 20:
|
case 20:
|
||||||
throw new InvalidOperationException("message too old, and it cannot be verified whether the server has received a message with this msg_id or not");
|
throw new InvalidOperationException(
|
||||||
|
"message too old, and it cannot be verified whether the server has received a message with this msg_id or not");
|
||||||
case 32:
|
case 32:
|
||||||
throw new InvalidOperationException("msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)");
|
throw new InvalidOperationException(
|
||||||
|
"msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)");
|
||||||
case 33:
|
case 33:
|
||||||
throw new InvalidOperationException(" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)");
|
throw new InvalidOperationException(
|
||||||
|
" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)");
|
||||||
case 34:
|
case 34:
|
||||||
throw new InvalidOperationException("an even msg_seqno expected (irrelevant message), but odd received");
|
throw new InvalidOperationException(
|
||||||
|
"an even msg_seqno expected (irrelevant message), but odd received");
|
||||||
case 35:
|
case 35:
|
||||||
throw new InvalidOperationException("odd msg_seqno expected (relevant message), but even received");
|
throw new InvalidOperationException("odd msg_seqno expected (relevant message), but even received");
|
||||||
case 48:
|
case 48:
|
||||||
throw new InvalidOperationException("incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)");
|
throw new InvalidOperationException(
|
||||||
|
"incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)");
|
||||||
case 64:
|
case 64:
|
||||||
throw new InvalidOperationException("invalid container");
|
throw new InvalidOperationException("invalid container");
|
||||||
|
|
||||||
}
|
}
|
||||||
throw new NotImplementedException("This should never happens");
|
throw new NotImplementedException("This should never happens");
|
||||||
/*
|
/*
|
||||||
|
|
@ -411,13 +413,13 @@ namespace TLSharp.Core.Network
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HandleBadServerSalt(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool HandleBadServerSalt(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
ulong badMsgId = messageReader.ReadUInt64();
|
var badMsgId = messageReader.ReadUInt64();
|
||||||
int badMsgSeqNo = messageReader.ReadInt32();
|
var badMsgSeqNo = messageReader.ReadInt32();
|
||||||
int errorCode = messageReader.ReadInt32();
|
var errorCode = messageReader.ReadInt32();
|
||||||
ulong newSalt = messageReader.ReadUInt64();
|
var newSalt = messageReader.ReadUInt64();
|
||||||
|
|
||||||
//logger.debug("bad_server_salt: msgid {0}, seq {1}, errorcode {2}, newsalt {3}", badMsgId, badMsgSeqNo, errorCode, newSalt);
|
//logger.debug("bad_server_salt: msgid {0}, seq {1}, errorcode {2}, newsalt {3}", badMsgId, badMsgSeqNo, errorCode, newSalt);
|
||||||
|
|
||||||
|
|
@ -451,8 +453,8 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
private bool HandleFutureSalts(ulong messageId, int sequence, BinaryReader messageReader)
|
private bool HandleFutureSalts(ulong messageId, int sequence, BinaryReader messageReader)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
ulong requestId = messageReader.ReadUInt64();
|
var requestId = messageReader.ReadUInt64();
|
||||||
|
|
||||||
messageReader.BaseStream.Position -= 12;
|
messageReader.BaseStream.Position -= 12;
|
||||||
|
|
||||||
|
|
@ -472,15 +474,13 @@ namespace TLSharp.Core.Network
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HandlePong(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool HandlePong(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
ulong msgId = messageReader.ReadUInt64();
|
var msgId = messageReader.ReadUInt64();
|
||||||
|
|
||||||
if (msgId == (ulong)request.MessageId)
|
if (msgId == (ulong) request.MessageId)
|
||||||
{
|
|
||||||
request.ConfirmReceived = true;
|
request.ConfirmReceived = true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -490,23 +490,21 @@ namespace TLSharp.Core.Network
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
|
private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
uint code = messageReader.ReadUInt32();
|
var code = messageReader.ReadUInt32();
|
||||||
int size = messageReader.ReadInt32();
|
var size = messageReader.ReadInt32();
|
||||||
for (int i = 0; i < size; i++)
|
for (var i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
ulong innerMessageId = messageReader.ReadUInt64();
|
var innerMessageId = messageReader.ReadUInt64();
|
||||||
int innerSequence = messageReader.ReadInt32();
|
var innerSequence = messageReader.ReadInt32();
|
||||||
int innerLength = messageReader.ReadInt32();
|
var innerLength = messageReader.ReadInt32();
|
||||||
long beginPosition = messageReader.BaseStream.Position;
|
var beginPosition = messageReader.BaseStream.Position;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!processMessage(innerMessageId, sequence, messageReader, request))
|
if (!processMessage(innerMessageId, sequence, messageReader, request))
|
||||||
{
|
|
||||||
messageReader.BaseStream.Position = beginPosition + innerLength;
|
messageReader.BaseStream.Position = beginPosition + innerLength;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// logger.error("failed to process message in contailer: {0}", e);
|
// logger.error("failed to process message in contailer: {0}", e);
|
||||||
|
|
@ -525,33 +523,34 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
public class FloodException : Exception
|
public class FloodException : Exception
|
||||||
{
|
{
|
||||||
public TimeSpan TimeToWait { get; private set; }
|
|
||||||
|
|
||||||
internal FloodException(TimeSpan timeToWait)
|
internal FloodException(TimeSpan timeToWait)
|
||||||
: base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." +
|
: base(
|
||||||
|
$"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." +
|
||||||
" If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.")
|
" If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.")
|
||||||
{
|
{
|
||||||
TimeToWait = timeToWait;
|
TimeToWait = timeToWait;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimeSpan TimeToWait { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal abstract class DataCenterMigrationException : Exception
|
internal abstract class DataCenterMigrationException : Exception
|
||||||
{
|
{
|
||||||
internal int DC { get; private set; }
|
|
||||||
|
|
||||||
private const string REPORT_MESSAGE =
|
private const string REPORT_MESSAGE =
|
||||||
" See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error";
|
" See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error";
|
||||||
|
|
||||||
protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE)
|
protected DataCenterMigrationException(string msg, int dc) : base(msg + REPORT_MESSAGE)
|
||||||
{
|
{
|
||||||
DC = dc;
|
DC = dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal int DC { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class PhoneMigrationException : DataCenterMigrationException
|
internal class PhoneMigrationException : DataCenterMigrationException
|
||||||
{
|
{
|
||||||
internal PhoneMigrationException(int dc)
|
internal PhoneMigrationException(int dc)
|
||||||
: base ($"Phone number registered to a different DC: {dc}.", dc)
|
: base($"Phone number registered to a different DC: {dc}.", dc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +558,7 @@ namespace TLSharp.Core.Network
|
||||||
internal class FileMigrationException : DataCenterMigrationException
|
internal class FileMigrationException : DataCenterMigrationException
|
||||||
{
|
{
|
||||||
internal FileMigrationException(int dc)
|
internal FileMigrationException(int dc)
|
||||||
: base ($"File located on a different DC: {dc}.", dc)
|
: base($"File located on a different DC: {dc}.", dc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ namespace TLSharp.Core.Network
|
||||||
{
|
{
|
||||||
public class TcpMessage
|
public class TcpMessage
|
||||||
{
|
{
|
||||||
public int SequneceNumber { get; private set; }
|
|
||||||
public byte[] Body { get; private set; }
|
|
||||||
|
|
||||||
public TcpMessage(int seqNumber, byte[] body)
|
public TcpMessage(int seqNumber, byte[] body)
|
||||||
{
|
{
|
||||||
if (body == null)
|
if (body == null)
|
||||||
|
|
@ -18,6 +15,9 @@ namespace TLSharp.Core.Network
|
||||||
Body = body;
|
Body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int SequneceNumber { get; }
|
||||||
|
public byte[] Body { get; }
|
||||||
|
|
||||||
public byte[] Encode()
|
public byte[] Encode()
|
||||||
{
|
{
|
||||||
using (var memoryStream = new MemoryStream())
|
using (var memoryStream = new MemoryStream())
|
||||||
|
|
@ -66,17 +66,15 @@ namespace TLSharp.Core.Network
|
||||||
throw new InvalidOperationException(string.Format("invalid packet length: {0}", packetLength));
|
throw new InvalidOperationException(string.Format("invalid packet length: {0}", packetLength));
|
||||||
|
|
||||||
var seq = binaryReader.ReadInt32();
|
var seq = binaryReader.ReadInt32();
|
||||||
byte[] packet = binaryReader.ReadBytes(packetLength - 12);
|
var packet = binaryReader.ReadBytes(packetLength - 12);
|
||||||
var checksum = (int)binaryReader.ReadInt32();
|
var checksum = binaryReader.ReadInt32();
|
||||||
|
|
||||||
var crc32 = new CRC32();
|
var crc32 = new CRC32();
|
||||||
crc32.SlurpBlock(body, 0, packetLength - 4);
|
crc32.SlurpBlock(body, 0, packetLength - 4);
|
||||||
var validChecksum = crc32.Crc32Result;
|
var validChecksum = crc32.Crc32Result;
|
||||||
|
|
||||||
if (checksum != validChecksum)
|
if (checksum != validChecksum)
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid checksum! skip");
|
throw new InvalidOperationException("invalid checksum! skip");
|
||||||
}
|
|
||||||
|
|
||||||
return new TcpMessage(seq, packet);
|
return new TcpMessage(seq, packet);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace TLSharp.Core.Network
|
||||||
public class TcpTransport : IDisposable
|
public class TcpTransport : IDisposable
|
||||||
{
|
{
|
||||||
private readonly TcpClient _tcpClient;
|
private readonly TcpClient _tcpClient;
|
||||||
private int sendCounter = 0;
|
private int sendCounter;
|
||||||
|
|
||||||
public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null)
|
public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null)
|
||||||
{
|
{
|
||||||
|
|
@ -22,8 +22,16 @@ namespace TLSharp.Core.Network
|
||||||
_tcpClient.Connect(ipAddress, port);
|
_tcpClient.Connect(ipAddress, port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_tcpClient = handler(address, port);
|
_tcpClient = handler(address, port);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_tcpClient.Connected)
|
||||||
|
_tcpClient.Close();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Send(byte[] packet)
|
public async Task Send(byte[] packet)
|
||||||
{
|
{
|
||||||
|
|
@ -43,16 +51,16 @@ namespace TLSharp.Core.Network
|
||||||
var packetLengthBytes = new byte[4];
|
var packetLengthBytes = new byte[4];
|
||||||
if (await stream.ReadAsync(packetLengthBytes, 0, 4) != 4)
|
if (await stream.ReadAsync(packetLengthBytes, 0, 4) != 4)
|
||||||
throw new InvalidOperationException("Couldn't read the packet length");
|
throw new InvalidOperationException("Couldn't read the packet length");
|
||||||
int packetLength = BitConverter.ToInt32(packetLengthBytes, 0);
|
var packetLength = BitConverter.ToInt32(packetLengthBytes, 0);
|
||||||
|
|
||||||
var seqBytes = new byte[4];
|
var seqBytes = new byte[4];
|
||||||
if (await stream.ReadAsync(seqBytes, 0, 4) != 4)
|
if (await stream.ReadAsync(seqBytes, 0, 4) != 4)
|
||||||
throw new InvalidOperationException("Couldn't read the sequence");
|
throw new InvalidOperationException("Couldn't read the sequence");
|
||||||
int seq = BitConverter.ToInt32(seqBytes, 0);
|
var seq = BitConverter.ToInt32(seqBytes, 0);
|
||||||
|
|
||||||
int readBytes = 0;
|
var readBytes = 0;
|
||||||
var body = new byte[packetLength - 12];
|
var body = new byte[packetLength - 12];
|
||||||
int neededToRead = packetLength - 12;
|
var neededToRead = packetLength - 12;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -61,15 +69,14 @@ namespace TLSharp.Core.Network
|
||||||
neededToRead -= availableBytes;
|
neededToRead -= availableBytes;
|
||||||
Buffer.BlockCopy(bodyByte, 0, body, readBytes, availableBytes);
|
Buffer.BlockCopy(bodyByte, 0, body, readBytes, availableBytes);
|
||||||
readBytes += availableBytes;
|
readBytes += availableBytes;
|
||||||
}
|
} while (readBytes != packetLength - 12);
|
||||||
while (readBytes != packetLength - 12);
|
|
||||||
|
|
||||||
var crcBytes = new byte[4];
|
var crcBytes = new byte[4];
|
||||||
if (await stream.ReadAsync(crcBytes, 0, 4) != 4)
|
if (await stream.ReadAsync(crcBytes, 0, 4) != 4)
|
||||||
throw new InvalidOperationException("Couldn't read the crc");
|
throw new InvalidOperationException("Couldn't read the crc");
|
||||||
int checksum = BitConverter.ToInt32(crcBytes, 0);
|
var checksum = BitConverter.ToInt32(crcBytes, 0);
|
||||||
|
|
||||||
byte[] rv = new byte[packetLengthBytes.Length + seqBytes.Length + body.Length];
|
var rv = new byte[packetLengthBytes.Length + seqBytes.Length + body.Length];
|
||||||
|
|
||||||
Buffer.BlockCopy(packetLengthBytes, 0, rv, 0, packetLengthBytes.Length);
|
Buffer.BlockCopy(packetLengthBytes, 0, rv, 0, packetLengthBytes.Length);
|
||||||
Buffer.BlockCopy(seqBytes, 0, rv, packetLengthBytes.Length, seqBytes.Length);
|
Buffer.BlockCopy(seqBytes, 0, rv, packetLengthBytes.Length, seqBytes.Length);
|
||||||
|
|
@ -79,17 +86,9 @@ namespace TLSharp.Core.Network
|
||||||
var validChecksum = crc32.Crc32Result;
|
var validChecksum = crc32.Crc32Result;
|
||||||
|
|
||||||
if (checksum != validChecksum)
|
if (checksum != validChecksum)
|
||||||
{
|
|
||||||
throw new InvalidOperationException("invalid checksum! skip");
|
throw new InvalidOperationException("invalid checksum! skip");
|
||||||
}
|
|
||||||
|
|
||||||
return new TcpMessage(seq, body);
|
return new TcpMessage(seq, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_tcpClient.Connected)
|
|
||||||
_tcpClient.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using TeleSharp.TL;
|
||||||
|
|
||||||
namespace TLSharp.Core.Requests
|
namespace TLSharp.Core.Requests
|
||||||
{
|
{
|
||||||
public class AckRequest : TeleSharp.TL.TLMethod
|
public class AckRequest : TLMethod
|
||||||
{
|
{
|
||||||
private readonly List<ulong> _msgs;
|
private readonly List<ulong> _msgs;
|
||||||
|
|
||||||
|
|
@ -14,16 +14,19 @@ namespace TLSharp.Core.Requests
|
||||||
_msgs = msgs;
|
_msgs = msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool Confirmed => false;
|
||||||
|
public override bool Responded { get; }
|
||||||
|
|
||||||
|
public override int Constructor => 0x62d6b459;
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter writer)
|
public override void SerializeBody(BinaryWriter writer)
|
||||||
{
|
{
|
||||||
writer.Write(0x62d6b459); // msgs_ack
|
writer.Write(0x62d6b459); // msgs_ack
|
||||||
writer.Write(0x1cb5c415); // Vector
|
writer.Write(0x1cb5c415); // Vector
|
||||||
writer.Write(_msgs.Count);
|
writer.Write(_msgs.Count);
|
||||||
foreach (ulong messageId in _msgs)
|
foreach (var messageId in _msgs)
|
||||||
{
|
|
||||||
writer.Write(messageId);
|
writer.Write(messageId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader reader)
|
public override void DeserializeBody(BinaryReader reader)
|
||||||
{
|
{
|
||||||
|
|
@ -34,16 +37,5 @@ namespace TLSharp.Core.Requests
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Confirmed => false;
|
|
||||||
public override bool Responded { get; }
|
|
||||||
|
|
||||||
public override int Constructor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 0x62d6b459;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
|
|
||||||
namespace TLSharp.Core.Requests
|
namespace TLSharp.Core.Requests
|
||||||
{
|
{
|
||||||
public class PingRequest : TeleSharp.TL.TLMethod
|
public class PingRequest : TLMethod
|
||||||
{
|
{
|
||||||
public PingRequest()
|
public override int Constructor => 0x7abe77ec;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter writer)
|
public override void SerializeBody(BinaryWriter writer)
|
||||||
{
|
{
|
||||||
|
|
@ -27,13 +24,5 @@ namespace TLSharp.Core.Requests
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Constructor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 0x7abe77ec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,6 @@ namespace TLSharp.Core
|
||||||
{
|
{
|
||||||
public void Save(Session session)
|
public void Save(Session session)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session Load(string sessionUserId)
|
public Session Load(string sessionUserId)
|
||||||
|
|
@ -54,10 +53,19 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
public class Session
|
public class Session
|
||||||
{
|
{
|
||||||
private const string defaultConnectionAddress = "149.154.175.100";//"149.154.167.50";
|
private const string defaultConnectionAddress = "149.154.175.100"; //"149.154.167.50";
|
||||||
|
|
||||||
private const int defaultConnectionPort = 443;
|
private const int defaultConnectionPort = 443;
|
||||||
|
|
||||||
|
private readonly ISessionStore _store;
|
||||||
|
private readonly Random random;
|
||||||
|
|
||||||
|
private Session(ISessionStore store)
|
||||||
|
{
|
||||||
|
random = new Random();
|
||||||
|
_store = store;
|
||||||
|
}
|
||||||
|
|
||||||
public string SessionUserId { get; set; }
|
public string SessionUserId { get; set; }
|
||||||
public string ServerAddress { get; set; }
|
public string ServerAddress { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
|
|
@ -69,15 +77,6 @@ namespace TLSharp.Core
|
||||||
public long LastMessageId { get; set; }
|
public long LastMessageId { get; set; }
|
||||||
public int SessionExpires { get; set; }
|
public int SessionExpires { get; set; }
|
||||||
public TLUser TLUser { get; set; }
|
public TLUser TLUser { get; set; }
|
||||||
private Random random;
|
|
||||||
|
|
||||||
private ISessionStore _store;
|
|
||||||
|
|
||||||
private Session(ISessionStore store)
|
|
||||||
{
|
|
||||||
random = new Random();
|
|
||||||
_store = store;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] ToBytes()
|
public byte[] ToBytes()
|
||||||
{
|
{
|
||||||
|
|
@ -123,12 +122,12 @@ namespace TLSharp.Core
|
||||||
var port = reader.ReadInt32();
|
var port = reader.ReadInt32();
|
||||||
|
|
||||||
var isAuthExsist = reader.ReadInt32() == 1;
|
var isAuthExsist = reader.ReadInt32() == 1;
|
||||||
int sessionExpires = 0;
|
var sessionExpires = 0;
|
||||||
TLUser TLUser = null;
|
TLUser TLUser = null;
|
||||||
if (isAuthExsist)
|
if (isAuthExsist)
|
||||||
{
|
{
|
||||||
sessionExpires = reader.ReadInt32();
|
sessionExpires = reader.ReadInt32();
|
||||||
TLUser = (TLUser)ObjectUtils.DeserializeObject(reader);
|
TLUser = (TLUser) ObjectUtils.DeserializeObject(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
var authData = Serializers.Bytes.read(reader);
|
var authData = Serializers.Bytes.read(reader);
|
||||||
|
|
@ -169,22 +168,20 @@ namespace TLSharp.Core
|
||||||
private static ulong GenerateRandomUlong()
|
private static ulong GenerateRandomUlong()
|
||||||
{
|
{
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
ulong rand = (((ulong)random.Next()) << 32) | ((ulong)random.Next());
|
var rand = ((ulong) random.Next() << 32) | (ulong) random.Next();
|
||||||
return rand;
|
return rand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetNewMessageId()
|
public long GetNewMessageId()
|
||||||
{
|
{
|
||||||
long time = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
var time = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
||||||
long newMessageId = ((time / 1000 + TimeOffset) << 32) |
|
var newMessageId = ((time / 1000 + TimeOffset) << 32) |
|
||||||
((time % 1000) << 22) |
|
((time % 1000) << 22) |
|
||||||
(random.Next(524288) << 2); // 2^19
|
(random.Next(524288) << 2); // 2^19
|
||||||
// [ unix timestamp : 32 bit] [ milliseconds : 10 bit ] [ buffer space : 1 bit ] [ random : 19 bit ] [ msg_id type : 2 bit ] = [ msg_id : 64 bit ]
|
// [ unix timestamp : 32 bit] [ milliseconds : 10 bit ] [ buffer space : 1 bit ] [ random : 19 bit ] [ msg_id type : 2 bit ] = [ msg_id : 64 bit ]
|
||||||
|
|
||||||
if (LastMessageId >= newMessageId)
|
if (LastMessageId >= newMessageId)
|
||||||
{
|
|
||||||
newMessageId = LastMessageId + 4;
|
newMessageId = LastMessageId + 4;
|
||||||
}
|
|
||||||
|
|
||||||
LastMessageId = newMessageId;
|
LastMessageId = newMessageId;
|
||||||
return newMessageId;
|
return newMessageId;
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,20 @@ using TLSharp.Core.MTProto.Crypto;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
|
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
|
||||||
|
using TLRequestSearch = TeleSharp.TL.Contacts.TLRequestSearch;
|
||||||
|
|
||||||
namespace TLSharp.Core
|
namespace TLSharp.Core
|
||||||
{
|
{
|
||||||
public class TelegramClient : IDisposable
|
public class TelegramClient : IDisposable
|
||||||
{
|
{
|
||||||
private MtProtoSender _sender;
|
private readonly string _apiHash = "";
|
||||||
|
private readonly int _apiId;
|
||||||
|
private readonly TcpClientConnectionHandler _handler;
|
||||||
private AuthKey _key;
|
private AuthKey _key;
|
||||||
|
private MtProtoSender _sender;
|
||||||
|
private readonly Session _session;
|
||||||
private TcpTransport _transport;
|
private TcpTransport _transport;
|
||||||
private string _apiHash = "";
|
|
||||||
private int _apiId = 0;
|
|
||||||
private Session _session;
|
|
||||||
private List<TLDcOption> dcOptions;
|
private List<TLDcOption> dcOptions;
|
||||||
private TcpClientConnectionHandler _handler;
|
|
||||||
|
|
||||||
public TelegramClient(int apiId, string apiHash,
|
public TelegramClient(int apiId, string apiHash,
|
||||||
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
|
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
|
||||||
|
|
@ -50,6 +51,15 @@ namespace TLSharp.Core
|
||||||
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
|
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_transport != null)
|
||||||
|
{
|
||||||
|
_transport.Dispose();
|
||||||
|
_transport = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> ConnectAsync(bool reconnect = false)
|
public async Task<bool> ConnectAsync(bool reconnect = false)
|
||||||
{
|
{
|
||||||
if (_session.AuthKey == null || reconnect)
|
if (_session.AuthKey == null || reconnect)
|
||||||
|
|
@ -63,7 +73,7 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
//set-up layer
|
//set-up layer
|
||||||
var config = new TLRequestGetConfig();
|
var config = new TLRequestGetConfig();
|
||||||
var request = new TLRequestInitConnection()
|
var request = new TLRequestInitConnection
|
||||||
{
|
{
|
||||||
api_id = _apiId,
|
api_id = _apiId,
|
||||||
app_version = "1.0.0",
|
app_version = "1.0.0",
|
||||||
|
|
@ -72,11 +82,11 @@ namespace TLSharp.Core
|
||||||
query = config,
|
query = config,
|
||||||
system_version = "Win 10.0"
|
system_version = "Win 10.0"
|
||||||
};
|
};
|
||||||
var invokewithLayer = new TLRequestInvokeWithLayer() { layer = 57, query = request };
|
var invokewithLayer = new TLRequestInvokeWithLayer {layer = 57, query = request};
|
||||||
await _sender.Send(invokewithLayer);
|
await _sender.Send(invokewithLayer);
|
||||||
await _sender.Receive(invokewithLayer);
|
await _sender.Receive(invokewithLayer);
|
||||||
|
|
||||||
dcOptions = ((TLConfig)invokewithLayer.Response).dc_options.lists;
|
dcOptions = ((TLConfig) invokewithLayer.Response).dc_options.lists;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -102,33 +112,31 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
|
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(phoneNumber))
|
if (string.IsNullOrWhiteSpace(phoneNumber))
|
||||||
throw new ArgumentNullException(nameof(phoneNumber));
|
throw new ArgumentNullException(nameof(phoneNumber));
|
||||||
|
|
||||||
if (_sender == null)
|
if (_sender == null)
|
||||||
throw new InvalidOperationException("Not connected!");
|
throw new InvalidOperationException("Not connected!");
|
||||||
|
|
||||||
var authCheckPhoneRequest = new TLRequestCheckPhone() { phone_number = phoneNumber };
|
var authCheckPhoneRequest = new TLRequestCheckPhone {phone_number = phoneNumber};
|
||||||
var completed = false;
|
var completed = false;
|
||||||
while(!completed)
|
while (!completed)
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _sender.Send(authCheckPhoneRequest);
|
await _sender.Send(authCheckPhoneRequest);
|
||||||
await _sender.Receive(authCheckPhoneRequest);
|
await _sender.Receive(authCheckPhoneRequest);
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
catch(PhoneMigrationException e)
|
catch (PhoneMigrationException e)
|
||||||
{
|
{
|
||||||
await ReconnectToDcAsync(e.DC);
|
await ReconnectToDcAsync(e.DC);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return authCheckPhoneRequest.Response.phone_registered;
|
return authCheckPhoneRequest.Response.phone_registered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> SendCodeRequestAsync(string phoneNumber)
|
public async Task<string> SendCodeRequestAsync(string phoneNumber)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(phoneNumber))
|
if (string.IsNullOrWhiteSpace(phoneNumber))
|
||||||
throw new ArgumentNullException(nameof(phoneNumber));
|
throw new ArgumentNullException(nameof(phoneNumber));
|
||||||
|
|
||||||
var completed = false;
|
var completed = false;
|
||||||
|
|
@ -137,7 +145,7 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
while (!completed)
|
while (!completed)
|
||||||
{
|
{
|
||||||
request = new TLRequestSendCode() { phone_number = phoneNumber, api_id = _apiId, api_hash = _apiHash };
|
request = new TLRequestSendCode {phone_number = phoneNumber, api_id = _apiId, api_hash = _apiHash};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _sender.Send(request);
|
await _sender.Send(request);
|
||||||
|
|
@ -156,23 +164,29 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
|
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(phoneNumber))
|
if (string.IsNullOrWhiteSpace(phoneNumber))
|
||||||
throw new ArgumentNullException(nameof(phoneNumber));
|
throw new ArgumentNullException(nameof(phoneNumber));
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(phoneCodeHash))
|
if (string.IsNullOrWhiteSpace(phoneCodeHash))
|
||||||
throw new ArgumentNullException(nameof(phoneCodeHash));
|
throw new ArgumentNullException(nameof(phoneCodeHash));
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(code))
|
if (string.IsNullOrWhiteSpace(code))
|
||||||
throw new ArgumentNullException(nameof(code));
|
throw new ArgumentNullException(nameof(code));
|
||||||
|
|
||||||
var request = new TLRequestSignIn() { phone_number = phoneNumber, phone_code_hash = phoneCodeHash, phone_code = code };
|
var request = new TLRequestSignIn
|
||||||
|
{
|
||||||
|
phone_number = phoneNumber,
|
||||||
|
phone_code_hash = phoneCodeHash,
|
||||||
|
phone_code = code
|
||||||
|
};
|
||||||
await _sender.Send(request);
|
await _sender.Send(request);
|
||||||
await _sender.Receive(request);
|
await _sender.Receive(request);
|
||||||
|
|
||||||
OnUserAuthenticated(((TLUser)request.Response.user));
|
OnUserAuthenticated((TLUser) request.Response.user);
|
||||||
|
|
||||||
return ((TLUser)request.Response.user);
|
return (TLUser) request.Response.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLPassword> GetPasswordSetting()
|
public async Task<TLPassword> GetPasswordSetting()
|
||||||
{
|
{
|
||||||
var request = new TLRequestGetPassword();
|
var request = new TLRequestGetPassword();
|
||||||
|
|
@ -180,37 +194,45 @@ namespace TLSharp.Core
|
||||||
await _sender.Send(request);
|
await _sender.Send(request);
|
||||||
await _sender.Receive(request);
|
await _sender.Receive(request);
|
||||||
|
|
||||||
return ((TLPassword)request.Response);
|
return (TLPassword) request.Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
|
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
|
||||||
{
|
{
|
||||||
|
var password_bytes = Encoding.UTF8.GetBytes(password_str);
|
||||||
|
var rv = password.current_salt.Concat(password_bytes).Concat(password.current_salt);
|
||||||
|
|
||||||
byte[] password_bytes = Encoding.UTF8.GetBytes(password_str);
|
var hashstring = new SHA256Managed();
|
||||||
IEnumerable<byte> rv = password.current_salt.Concat(password_bytes).Concat(password.current_salt);
|
|
||||||
|
|
||||||
SHA256Managed hashstring = new SHA256Managed();
|
|
||||||
var password_hash = hashstring.ComputeHash(rv.ToArray());
|
var password_hash = hashstring.ComputeHash(rv.ToArray());
|
||||||
|
|
||||||
var request = new TLRequestCheckPassword() { password_hash = password_hash };
|
var request = new TLRequestCheckPassword {password_hash = password_hash};
|
||||||
await _sender.Send(request);
|
await _sender.Send(request);
|
||||||
await _sender.Receive(request);
|
await _sender.Receive(request);
|
||||||
|
|
||||||
OnUserAuthenticated(((TLUser)request.Response.user));
|
OnUserAuthenticated((TLUser) request.Response.user);
|
||||||
|
|
||||||
return ((TLUser)request.Response.user);
|
return (TLUser) request.Response.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
|
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName,
|
||||||
|
string lastName)
|
||||||
{
|
{
|
||||||
var request = new TLRequestSignUp() { phone_number = phoneNumber, phone_code = code, phone_code_hash = phoneCodeHash, first_name = firstName, last_name = lastName };
|
var request = new TLRequestSignUp
|
||||||
|
{
|
||||||
|
phone_number = phoneNumber,
|
||||||
|
phone_code = code,
|
||||||
|
phone_code_hash = phoneCodeHash,
|
||||||
|
first_name = firstName,
|
||||||
|
last_name = lastName
|
||||||
|
};
|
||||||
await _sender.Send(request);
|
await _sender.Send(request);
|
||||||
await _sender.Receive(request);
|
await _sender.Receive(request);
|
||||||
|
|
||||||
OnUserAuthenticated(((TLUser)request.Response.user));
|
OnUserAuthenticated((TLUser) request.Response.user);
|
||||||
|
|
||||||
return ((TLUser)request.Response.user);
|
return (TLUser) request.Response.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
|
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
|
||||||
{
|
{
|
||||||
await _sender.Send(methodToExecute);
|
await _sender.Send(methodToExecute);
|
||||||
|
|
@ -218,7 +240,7 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
|
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
|
||||||
|
|
||||||
return (T)result;
|
return (T) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLContacts> GetContactsAsync()
|
public async Task<TLContacts> GetContactsAsync()
|
||||||
|
|
@ -226,7 +248,7 @@ namespace TLSharp.Core
|
||||||
if (!IsUserAuthorized())
|
if (!IsUserAuthorized())
|
||||||
throw new InvalidOperationException("Authorize user first!");
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
var req = new TLRequestGetContacts() { hash = "" };
|
var req = new TLRequestGetContacts {hash = ""};
|
||||||
|
|
||||||
return await SendRequestAsync<TLContacts>(req);
|
return await SendRequestAsync<TLContacts>(req);
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +259,7 @@ namespace TLSharp.Core
|
||||||
throw new InvalidOperationException("Authorize user first!");
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
return await SendRequestAsync<TLAbsUpdates>(
|
return await SendRequestAsync<TLAbsUpdates>(
|
||||||
new TLRequestSendMessage()
|
new TLRequestSendMessage
|
||||||
{
|
{
|
||||||
peer = peer,
|
peer = peer,
|
||||||
message = message,
|
message = message,
|
||||||
|
|
@ -245,44 +267,45 @@ namespace TLSharp.Core
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Boolean> SendTypingAsync(TLAbsInputPeer peer)
|
public async Task<bool> SendTypingAsync(TLAbsInputPeer peer)
|
||||||
{
|
{
|
||||||
var req = new TLRequestSetTyping()
|
var req = new TLRequestSetTyping
|
||||||
{
|
{
|
||||||
action = new TLSendMessageTypingAction(),
|
action = new TLSendMessageTypingAction(),
|
||||||
peer = peer
|
peer = peer
|
||||||
};
|
};
|
||||||
return await SendRequestAsync<Boolean>(req);
|
return await SendRequestAsync<bool>(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLAbsDialogs> GetUserDialogsAsync()
|
public async Task<TLAbsDialogs> GetUserDialogsAsync()
|
||||||
{
|
{
|
||||||
var peer = new TLInputPeerSelf();
|
var peer = new TLInputPeerSelf();
|
||||||
return await SendRequestAsync<TLAbsDialogs>(
|
return await SendRequestAsync<TLAbsDialogs>(
|
||||||
new TLRequestGetDialogs() { offset_date = 0, offset_peer = peer, limit = 100 });
|
new TLRequestGetDialogs {offset_date = 0, offset_peer = peer, limit = 100});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
|
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
|
||||||
{
|
{
|
||||||
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
|
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia
|
||||||
{
|
{
|
||||||
random_id = Helpers.GenerateRandomLong(),
|
random_id = Helpers.GenerateRandomLong(),
|
||||||
background = false,
|
background = false,
|
||||||
clear_draft = false,
|
clear_draft = false,
|
||||||
media = new TLInputMediaUploadedPhoto() { file = file, caption = caption },
|
media = new TLInputMediaUploadedPhoto {file = file, caption = caption},
|
||||||
peer = peer
|
peer = peer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TLAbsUpdates> SendUploadedDocument(
|
public async Task<TLAbsUpdates> SendUploadedDocument(
|
||||||
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes)
|
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType,
|
||||||
|
TLVector<TLAbsDocumentAttribute> attributes)
|
||||||
{
|
{
|
||||||
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
|
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia
|
||||||
{
|
{
|
||||||
random_id = Helpers.GenerateRandomLong(),
|
random_id = Helpers.GenerateRandomLong(),
|
||||||
background = false,
|
background = false,
|
||||||
clear_draft = false,
|
clear_draft = false,
|
||||||
media = new TLInputMediaUploadedDocument()
|
media = new TLInputMediaUploadedDocument
|
||||||
{
|
{
|
||||||
file = file,
|
file = file,
|
||||||
caption = caption,
|
caption = caption,
|
||||||
|
|
@ -298,7 +321,7 @@ namespace TLSharp.Core
|
||||||
TLFile result = null;
|
TLFile result = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = await SendRequestAsync<TLFile>(new TLRequestGetFile()
|
result = await SendRequestAsync<TLFile>(new TLRequestGetFile
|
||||||
{
|
{
|
||||||
location = location,
|
location = location,
|
||||||
limit = filePartSize,
|
limit = filePartSize,
|
||||||
|
|
@ -307,7 +330,8 @@ namespace TLSharp.Core
|
||||||
}
|
}
|
||||||
catch (FileMigrationException ex)
|
catch (FileMigrationException ex)
|
||||||
{
|
{
|
||||||
var exportedAuth = await SendRequestAsync<TLExportedAuthorization>(new TLRequestExportAuthorization() { dc_id = ex.DC });
|
var exportedAuth =
|
||||||
|
await SendRequestAsync<TLExportedAuthorization>(new TLRequestExportAuthorization {dc_id = ex.DC});
|
||||||
|
|
||||||
var authKey = _session.AuthKey;
|
var authKey = _session.AuthKey;
|
||||||
var timeOffset = _session.TimeOffset;
|
var timeOffset = _session.TimeOffset;
|
||||||
|
|
@ -328,7 +352,6 @@ namespace TLSharp.Core
|
||||||
_session.ServerAddress = serverAddress;
|
_session.ServerAddress = serverAddress;
|
||||||
_session.Port = serverPort;
|
_session.Port = serverPort;
|
||||||
await ConnectAsync();
|
await ConnectAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -344,7 +367,7 @@ namespace TLSharp.Core
|
||||||
if (!IsUserAuthorized())
|
if (!IsUserAuthorized())
|
||||||
throw new InvalidOperationException("Authorize user first!");
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
var req = new TLRequestGetHistory()
|
var req = new TLRequestGetHistory
|
||||||
{
|
{
|
||||||
peer = peer,
|
peer = peer,
|
||||||
add_offset = offset,
|
add_offset = offset,
|
||||||
|
|
@ -362,7 +385,7 @@ namespace TLSharp.Core
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
|
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
|
||||||
{
|
{
|
||||||
var r = new TeleSharp.TL.Contacts.TLRequestSearch
|
var r = new TLRequestSearch
|
||||||
{
|
{
|
||||||
q = q,
|
q = q,
|
||||||
limit = limit
|
limit = limit
|
||||||
|
|
@ -378,15 +401,6 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
_session.Save();
|
_session.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_transport != null)
|
|
||||||
{
|
|
||||||
_transport.Dispose();
|
|
||||||
_transport = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MissingApiConfigurationException : Exception
|
public class MissingApiConfigurationException : Exception
|
||||||
|
|
@ -401,10 +415,15 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
public class InvalidPhoneCodeException : Exception
|
public class InvalidPhoneCodeException : Exception
|
||||||
{
|
{
|
||||||
internal InvalidPhoneCodeException(string msg) : base(msg) { }
|
internal InvalidPhoneCodeException(string msg) : base(msg)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class CloudPasswordNeededException : Exception
|
public class CloudPasswordNeededException : Exception
|
||||||
{
|
{
|
||||||
internal CloudPasswordNeededException(string msg) : base(msg) { }
|
internal CloudPasswordNeededException(string msg) : base(msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,55 +6,55 @@ namespace TLSharp.Core.Utils
|
||||||
{
|
{
|
||||||
public class Helpers
|
public class Helpers
|
||||||
{
|
{
|
||||||
private static Random random = new Random();
|
private static readonly Random random = new Random();
|
||||||
|
|
||||||
public static ulong GenerateRandomUlong()
|
public static ulong GenerateRandomUlong()
|
||||||
{
|
{
|
||||||
ulong rand = (((ulong)random.Next()) << 32) | ((ulong)random.Next());
|
var rand = ((ulong) random.Next() << 32) | (ulong) random.Next();
|
||||||
return rand;
|
return rand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long GenerateRandomLong()
|
public static long GenerateRandomLong()
|
||||||
{
|
{
|
||||||
long rand = (((long)random.Next()) << 32) | ((long)random.Next());
|
var rand = ((long) random.Next() << 32) | random.Next();
|
||||||
return rand;
|
return rand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] GenerateRandomBytes(int num)
|
public static byte[] GenerateRandomBytes(int num)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[num];
|
var data = new byte[num];
|
||||||
random.NextBytes(data);
|
random.NextBytes(data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AESKeyData CalcKey(byte[] sharedKey, byte[] msgKey, bool client)
|
public static AESKeyData CalcKey(byte[] sharedKey, byte[] msgKey, bool client)
|
||||||
{
|
{
|
||||||
int x = client ? 0 : 8;
|
var x = client ? 0 : 8;
|
||||||
byte[] buffer = new byte[48];
|
var buffer = new byte[48];
|
||||||
|
|
||||||
Array.Copy(msgKey, 0, buffer, 0, 16); // buffer[0:16] = msgKey
|
Array.Copy(msgKey, 0, buffer, 0, 16); // buffer[0:16] = msgKey
|
||||||
Array.Copy(sharedKey, x, buffer, 16, 32); // buffer[16:48] = authKey[x:x+32]
|
Array.Copy(sharedKey, x, buffer, 16, 32); // buffer[16:48] = authKey[x:x+32]
|
||||||
byte[] sha1a = sha1(buffer); // sha1a = sha1(buffer)
|
var sha1a = sha1(buffer); // sha1a = sha1(buffer)
|
||||||
|
|
||||||
Array.Copy(sharedKey, 32 + x, buffer, 0, 16); // buffer[0:16] = authKey[x+32:x+48]
|
Array.Copy(sharedKey, 32 + x, buffer, 0, 16); // buffer[0:16] = authKey[x+32:x+48]
|
||||||
Array.Copy(msgKey, 0, buffer, 16, 16); // buffer[16:32] = msgKey
|
Array.Copy(msgKey, 0, buffer, 16, 16); // buffer[16:32] = msgKey
|
||||||
Array.Copy(sharedKey, 48 + x, buffer, 32, 16); // buffer[32:48] = authKey[x+48:x+64]
|
Array.Copy(sharedKey, 48 + x, buffer, 32, 16); // buffer[32:48] = authKey[x+48:x+64]
|
||||||
byte[] sha1b = sha1(buffer); // sha1b = sha1(buffer)
|
var sha1b = sha1(buffer); // sha1b = sha1(buffer)
|
||||||
|
|
||||||
Array.Copy(sharedKey, 64 + x, buffer, 0, 32); // buffer[0:32] = authKey[x+64:x+96]
|
Array.Copy(sharedKey, 64 + x, buffer, 0, 32); // buffer[0:32] = authKey[x+64:x+96]
|
||||||
Array.Copy(msgKey, 0, buffer, 32, 16); // buffer[32:48] = msgKey
|
Array.Copy(msgKey, 0, buffer, 32, 16); // buffer[32:48] = msgKey
|
||||||
byte[] sha1c = sha1(buffer); // sha1c = sha1(buffer)
|
var sha1c = sha1(buffer); // sha1c = sha1(buffer)
|
||||||
|
|
||||||
Array.Copy(msgKey, 0, buffer, 0, 16); // buffer[0:16] = msgKey
|
Array.Copy(msgKey, 0, buffer, 0, 16); // buffer[0:16] = msgKey
|
||||||
Array.Copy(sharedKey, 96 + x, buffer, 16, 32); // buffer[16:48] = authKey[x+96:x+128]
|
Array.Copy(sharedKey, 96 + x, buffer, 16, 32); // buffer[16:48] = authKey[x+96:x+128]
|
||||||
byte[] sha1d = sha1(buffer); // sha1d = sha1(buffer)
|
var sha1d = sha1(buffer); // sha1d = sha1(buffer)
|
||||||
|
|
||||||
byte[] key = new byte[32]; // key = sha1a[0:8] + sha1b[8:20] + sha1c[4:16]
|
var key = new byte[32]; // key = sha1a[0:8] + sha1b[8:20] + sha1c[4:16]
|
||||||
Array.Copy(sha1a, 0, key, 0, 8);
|
Array.Copy(sha1a, 0, key, 0, 8);
|
||||||
Array.Copy(sha1b, 8, key, 8, 12);
|
Array.Copy(sha1b, 8, key, 8, 12);
|
||||||
Array.Copy(sha1c, 4, key, 20, 12);
|
Array.Copy(sha1c, 4, key, 20, 12);
|
||||||
|
|
||||||
byte[] iv = new byte[32]; // iv = sha1a[8:20] + sha1b[0:8] + sha1c[16:20] + sha1d[0:8]
|
var iv = new byte[32]; // iv = sha1a[8:20] + sha1b[0:8] + sha1c[16:20] + sha1d[0:8]
|
||||||
Array.Copy(sha1a, 8, iv, 0, 12);
|
Array.Copy(sha1a, 8, iv, 0, 12);
|
||||||
Array.Copy(sha1b, 0, iv, 12, 8);
|
Array.Copy(sha1b, 0, iv, 12, 8);
|
||||||
Array.Copy(sha1c, 16, iv, 20, 4);
|
Array.Copy(sha1c, 16, iv, 20, 4);
|
||||||
|
|
@ -65,14 +65,14 @@ namespace TLSharp.Core.Utils
|
||||||
|
|
||||||
public static byte[] CalcMsgKey(byte[] data)
|
public static byte[] CalcMsgKey(byte[] data)
|
||||||
{
|
{
|
||||||
byte[] msgKey = new byte[16];
|
var msgKey = new byte[16];
|
||||||
Array.Copy(sha1(data), 4, msgKey, 0, 16);
|
Array.Copy(sha1(data), 4, msgKey, 0, 16);
|
||||||
return msgKey;
|
return msgKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] CalcMsgKey(byte[] data, int offset, int limit)
|
public static byte[] CalcMsgKey(byte[] data, int offset, int limit)
|
||||||
{
|
{
|
||||||
byte[] msgKey = new byte[16];
|
var msgKey = new byte[16];
|
||||||
Array.Copy(sha1(data, offset, limit), 4, msgKey, 0, 16);
|
Array.Copy(sha1(data, offset, limit), 4, msgKey, 0, 16);
|
||||||
return msgKey;
|
return msgKey;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -20,7 +19,7 @@ namespace TLSharp.Core.Utils
|
||||||
var hash = md5.ComputeHash(data);
|
var hash = md5.ComputeHash(data);
|
||||||
var hashResult = new StringBuilder(hash.Length * 2);
|
var hashResult = new StringBuilder(hash.Length * 2);
|
||||||
|
|
||||||
foreach (byte t in hash)
|
foreach (var t in hash)
|
||||||
hashResult.Append(t.ToString("x2"));
|
hashResult.Append(t.ToString("x2"));
|
||||||
|
|
||||||
md5_checksum = hashResult.ToString();
|
md5_checksum = hashResult.ToString();
|
||||||
|
|
@ -29,7 +28,8 @@ namespace TLSharp.Core.Utils
|
||||||
return md5_checksum;
|
return md5_checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<TLAbsInputFile> UploadFile(this TelegramClient client, string name, StreamReader reader)
|
public static async Task<TLAbsInputFile> UploadFile(this TelegramClient client, string name,
|
||||||
|
StreamReader reader)
|
||||||
{
|
{
|
||||||
const long tenMb = 10 * 1024 * 1024;
|
const long tenMb = 10 * 1024 * 1024;
|
||||||
return await UploadFile(name, reader, client, reader.BaseStream.Length >= tenMb);
|
return await UploadFile(name, reader, client, reader.BaseStream.Length >= tenMb);
|
||||||
|
|
@ -41,7 +41,7 @@ namespace TLSharp.Core.Utils
|
||||||
|
|
||||||
using (reader)
|
using (reader)
|
||||||
{
|
{
|
||||||
reader.BaseStream.Read(file, 0, (int)reader.BaseStream.Length);
|
reader.BaseStream.Read(file, 0, (int) reader.BaseStream.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
|
@ -56,8 +56,7 @@ namespace TLSharp.Core.Utils
|
||||||
using (var stream = new MemoryStream(file))
|
using (var stream = new MemoryStream(file))
|
||||||
{
|
{
|
||||||
while (stream.Position != stream.Length)
|
while (stream.Position != stream.Length)
|
||||||
{
|
if (stream.Length - stream.Position > maxFilePart)
|
||||||
if ((stream.Length - stream.Position) > maxFilePart)
|
|
||||||
{
|
{
|
||||||
var temp = new byte[maxFilePart];
|
var temp = new byte[maxFilePart];
|
||||||
stream.Read(temp, 0, maxFilePart);
|
stream.Read(temp, 0, maxFilePart);
|
||||||
|
|
@ -67,11 +66,10 @@ namespace TLSharp.Core.Utils
|
||||||
{
|
{
|
||||||
var length = stream.Length - stream.Position;
|
var length = stream.Length - stream.Position;
|
||||||
var temp = new byte[length];
|
var temp = new byte[length];
|
||||||
stream.Read(temp, 0, (int)(length));
|
stream.Read(temp, 0, (int) length);
|
||||||
fileParts.Enqueue(temp);
|
fileParts.Enqueue(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return fileParts;
|
return fileParts;
|
||||||
}
|
}
|
||||||
|
|
@ -82,15 +80,14 @@ namespace TLSharp.Core.Utils
|
||||||
var file = GetFile(reader);
|
var file = GetFile(reader);
|
||||||
var fileParts = GetFileParts(file);
|
var fileParts = GetFileParts(file);
|
||||||
|
|
||||||
int partNumber = 0;
|
var partNumber = 0;
|
||||||
int partsCount = fileParts.Count;
|
var partsCount = fileParts.Count;
|
||||||
long file_id = BitConverter.ToInt64(Helpers.GenerateRandomBytes(8), 0);
|
var file_id = BitConverter.ToInt64(Helpers.GenerateRandomBytes(8), 0);
|
||||||
while (fileParts.Count != 0)
|
while (fileParts.Count != 0)
|
||||||
{
|
{
|
||||||
var part = fileParts.Dequeue();
|
var part = fileParts.Dequeue();
|
||||||
|
|
||||||
if (isBigFileUpload)
|
if (isBigFileUpload)
|
||||||
{
|
|
||||||
await client.SendRequestAsync<bool>(new TLRequestSaveBigFilePart
|
await client.SendRequestAsync<bool>(new TLRequestSaveBigFilePart
|
||||||
{
|
{
|
||||||
file_id = file_id,
|
file_id = file_id,
|
||||||
|
|
@ -98,30 +95,23 @@ namespace TLSharp.Core.Utils
|
||||||
bytes = part,
|
bytes = part,
|
||||||
file_total_parts = partsCount
|
file_total_parts = partsCount
|
||||||
});
|
});
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
await client.SendRequestAsync<bool>(new TLRequestSaveFilePart
|
await client.SendRequestAsync<bool>(new TLRequestSaveFilePart
|
||||||
{
|
{
|
||||||
file_id = file_id,
|
file_id = file_id,
|
||||||
file_part = partNumber,
|
file_part = partNumber,
|
||||||
bytes = part
|
bytes = part
|
||||||
});
|
});
|
||||||
}
|
|
||||||
partNumber++;
|
partNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBigFileUpload)
|
if (isBigFileUpload)
|
||||||
{
|
|
||||||
return new TLInputFileBig
|
return new TLInputFileBig
|
||||||
{
|
{
|
||||||
id = file_id,
|
id = file_id,
|
||||||
name = name,
|
name = name,
|
||||||
parts = partsCount
|
parts = partsCount
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new TLInputFile
|
return new TLInputFile
|
||||||
{
|
{
|
||||||
id = file_id,
|
id = file_id,
|
||||||
|
|
@ -131,5 +121,4 @@ namespace TLSharp.Core.Utils
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="DotNetZip" version="1.9.3" targetFramework="net451" />
|
|
||||||
<package id="MarkerMetro.Unity.Ionic.Zlib" version="2.0.0.14" targetFramework="net452" />
|
<package id="MarkerMetro.Unity.Ionic.Zlib" version="2.0.0.14" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace TLSharp.Tests
|
namespace TLSharp.Tests
|
||||||
|
|
@ -16,7 +13,7 @@ namespace TLSharp.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async override Task AuthUser()
|
public override async Task AuthUser()
|
||||||
{
|
{
|
||||||
await base.AuthUser();
|
await base.AuthUser();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace TLSharp.Tests
|
namespace TLSharp.Tests
|
||||||
|
|
@ -67,6 +65,7 @@ namespace TLSharp.Tests
|
||||||
{
|
{
|
||||||
await base.CheckPhones();
|
await base.CheckPhones();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public override async Task FloodExceptionShouldNotCauseCannotReadPackageLengthError()
|
public override async Task FloodExceptionShouldNotCauseCannotReadPackageLengthError()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,22 @@
|
||||||
|
using System;
|
||||||
using System;
|
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TeleSharp.TL.Messages;
|
using TeleSharp.TL.Messages;
|
||||||
using TLSharp.Core;
|
using TLSharp.Core;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
using TLSharp.Core.Requests;
|
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
|
|
||||||
namespace TLSharp.Tests
|
namespace TLSharp.Tests
|
||||||
{
|
{
|
||||||
public class TLSharpTests
|
public class TLSharpTests
|
||||||
{
|
{
|
||||||
|
internal static Action<object> IsNotNullHanlder;
|
||||||
|
internal static Action<bool> IsTrueHandler;
|
||||||
private string NumberToSendMessage { get; set; }
|
private string NumberToSendMessage { get; set; }
|
||||||
|
|
||||||
private string NumberToAuthenticate { get; set; }
|
private string NumberToAuthenticate { get; set; }
|
||||||
|
|
@ -38,22 +37,6 @@ namespace TLSharp.Tests
|
||||||
|
|
||||||
private int ApiId { get; set; }
|
private int ApiId { get; set; }
|
||||||
|
|
||||||
class Assert
|
|
||||||
{
|
|
||||||
static internal void IsNotNull(object obj)
|
|
||||||
{
|
|
||||||
IsNotNullHanlder(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static internal void IsTrue(bool cond)
|
|
||||||
{
|
|
||||||
IsTrueHandler(cond);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static Action<object> IsNotNullHanlder;
|
|
||||||
internal static Action<bool> IsTrueHandler;
|
|
||||||
|
|
||||||
protected void Init(Action<object> notNullHandler, Action<bool> trueHandler)
|
protected void Init(Action<object> notNullHandler, Action<bool> trueHandler)
|
||||||
{
|
{
|
||||||
IsNotNullHanlder = notNullHandler;
|
IsNotNullHanlder = notNullHandler;
|
||||||
|
|
@ -71,14 +54,15 @@ namespace TLSharp.Tests
|
||||||
}
|
}
|
||||||
catch (MissingApiConfigurationException ex)
|
catch (MissingApiConfigurationException ex)
|
||||||
{
|
{
|
||||||
throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})",
|
throw new Exception(
|
||||||
|
$"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GatherTestConfiguration()
|
private void GatherTestConfiguration()
|
||||||
{
|
{
|
||||||
string appConfigMsgWarning = "{0} not configured in app.config! Some tests may fail.";
|
var appConfigMsgWarning = "{0} not configured in app.config! Some tests may fail.";
|
||||||
|
|
||||||
ApiHash = ConfigurationManager.AppSettings[nameof(ApiHash)];
|
ApiHash = ConfigurationManager.AppSettings[nameof(ApiHash)];
|
||||||
if (string.IsNullOrEmpty(ApiHash))
|
if (string.IsNullOrEmpty(ApiHash))
|
||||||
|
|
@ -128,10 +112,9 @@ namespace TLSharp.Tests
|
||||||
var hash = await client.SendCodeRequestAsync(NumberToAuthenticate);
|
var hash = await client.SendCodeRequestAsync(NumberToAuthenticate);
|
||||||
var code = CodeToAuthenticate; // you can change code in debugger too
|
var code = CodeToAuthenticate; // you can change code in debugger too
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(code))
|
if (string.IsNullOrWhiteSpace(code))
|
||||||
{
|
throw new Exception(
|
||||||
throw new Exception("CodeToAuthenticate is empty in the app.config file, fill it with the code you just got now by SMS/Telegram");
|
"CodeToAuthenticate is empty in the app.config file, fill it with the code you just got now by SMS/Telegram");
|
||||||
}
|
|
||||||
|
|
||||||
TLUser user = null;
|
TLUser user = null;
|
||||||
try
|
try
|
||||||
|
|
@ -143,11 +126,12 @@ namespace TLSharp.Tests
|
||||||
var password = await client.GetPasswordSetting();
|
var password = await client.GetPasswordSetting();
|
||||||
var password_str = PasswordToAuthenticate;
|
var password_str = PasswordToAuthenticate;
|
||||||
|
|
||||||
user = await client.MakeAuthWithPasswordAsync(password,password_str);
|
user = await client.MakeAuthWithPasswordAsync(password, password_str);
|
||||||
}
|
}
|
||||||
catch (InvalidPhoneCodeException ex)
|
catch (InvalidPhoneCodeException ex)
|
||||||
{
|
{
|
||||||
throw new Exception("CodeToAuthenticate is wrong in the app.config file, fill it with the code you just got now by SMS/Telegram",
|
throw new Exception(
|
||||||
|
"CodeToAuthenticate is wrong in the app.config file, fill it with the code you just got now by SMS/Telegram",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
Assert.IsNotNull(user);
|
Assert.IsNotNull(user);
|
||||||
|
|
@ -158,12 +142,13 @@ namespace TLSharp.Tests
|
||||||
{
|
{
|
||||||
NumberToSendMessage = ConfigurationManager.AppSettings[nameof(NumberToSendMessage)];
|
NumberToSendMessage = ConfigurationManager.AppSettings[nameof(NumberToSendMessage)];
|
||||||
if (string.IsNullOrWhiteSpace(NumberToSendMessage))
|
if (string.IsNullOrWhiteSpace(NumberToSendMessage))
|
||||||
throw new Exception($"Please fill the '{nameof(NumberToSendMessage)}' setting in app.config file first");
|
throw new Exception(
|
||||||
|
$"Please fill the '{nameof(NumberToSendMessage)}' setting in app.config file first");
|
||||||
|
|
||||||
// this is because the contacts in the address come without the "+" prefix
|
// this is because the contacts in the address come without the "+" prefix
|
||||||
var normalizedNumber = NumberToSendMessage.StartsWith("+") ?
|
var normalizedNumber = NumberToSendMessage.StartsWith("+")
|
||||||
NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1) :
|
? NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1)
|
||||||
NumberToSendMessage;
|
: NumberToSendMessage;
|
||||||
|
|
||||||
var client = NewClient();
|
var client = NewClient();
|
||||||
|
|
||||||
|
|
@ -176,13 +161,11 @@ namespace TLSharp.Tests
|
||||||
.FirstOrDefault(x => x.phone == normalizedNumber);
|
.FirstOrDefault(x => x.phone == normalizedNumber);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
throw new Exception("Number was not found in Contacts List of user: " + NumberToSendMessage);
|
||||||
throw new System.Exception("Number was not found in Contacts List of user: " + NumberToSendMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id });
|
await client.SendTypingAsync(new TLInputPeerUser {user_id = user.id});
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(3000);
|
||||||
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
await client.SendMessageAsync(new TLInputPeerUser {user_id = user.id}, "TEST");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task SendMessageToChannelTest()
|
public virtual async Task SendMessageToChannelTest()
|
||||||
|
|
@ -196,7 +179,8 @@ namespace TLSharp.Tests
|
||||||
.OfType<TLChannel>()
|
.OfType<TLChannel>()
|
||||||
.FirstOrDefault(c => c.title == "TestGroup");
|
.FirstOrDefault(c => c.title == "TestGroup");
|
||||||
|
|
||||||
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "TEST MSG");
|
await client.SendMessageAsync(
|
||||||
|
new TLInputPeerChannel {channel_id = chat.id, access_hash = chat.access_hash.Value}, "TEST MSG");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task SendPhotoToContactTest()
|
public virtual async Task SendPhotoToContactTest()
|
||||||
|
|
@ -211,8 +195,8 @@ namespace TLSharp.Tests
|
||||||
.OfType<TLUser>()
|
.OfType<TLUser>()
|
||||||
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
var fileResult = (TLInputFile)await client.UploadFile("cat.jpg", new StreamReader("data/cat.jpg"));
|
var fileResult = (TLInputFile) await client.UploadFile("cat.jpg", new StreamReader("data/cat.jpg"));
|
||||||
await client.SendUploadedPhoto(new TLInputPeerUser() { user_id = user.id }, fileResult, "kitty");
|
await client.SendUploadedPhoto(new TLInputPeerUser {user_id = user.id}, fileResult, "kitty");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task SendBigFileToContactTest()
|
public virtual async Task SendBigFileToContactTest()
|
||||||
|
|
@ -227,10 +211,11 @@ namespace TLSharp.Tests
|
||||||
.OfType<TLUser>()
|
.OfType<TLUser>()
|
||||||
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
var fileResult = (TLInputFileBig)await client.UploadFile("some.zip", new StreamReader("<some big file path>"));
|
var fileResult =
|
||||||
|
(TLInputFileBig) await client.UploadFile("some.zip", new StreamReader("<some big file path>"));
|
||||||
|
|
||||||
await client.SendUploadedDocument(
|
await client.SendUploadedDocument(
|
||||||
new TLInputPeerUser() { user_id = user.id },
|
new TLInputPeerUser {user_id = user.id},
|
||||||
fileResult,
|
fileResult,
|
||||||
"some zips",
|
"some zips",
|
||||||
"application/zip",
|
"application/zip",
|
||||||
|
|
@ -249,8 +234,8 @@ namespace TLSharp.Tests
|
||||||
.OfType<TLUser>()
|
.OfType<TLUser>()
|
||||||
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
var inputPeer = new TLInputPeerUser() { user_id = user.id };
|
var inputPeer = new TLInputPeerUser {user_id = user.id};
|
||||||
var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory() { peer = inputPeer });
|
var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory {peer = inputPeer});
|
||||||
var document = res.messages.lists
|
var document = res.messages.lists
|
||||||
.OfType<TLMessage>()
|
.OfType<TLMessage>()
|
||||||
.Where(m => m.media != null)
|
.Where(m => m.media != null)
|
||||||
|
|
@ -261,7 +246,7 @@ namespace TLSharp.Tests
|
||||||
.First();
|
.First();
|
||||||
|
|
||||||
var resFile = await client.GetFile(
|
var resFile = await client.GetFile(
|
||||||
new TLInputDocumentFileLocation()
|
new TLInputDocumentFileLocation
|
||||||
{
|
{
|
||||||
access_hash = document.access_hash,
|
access_hash = document.access_hash,
|
||||||
id = document.id,
|
id = document.id,
|
||||||
|
|
@ -284,10 +269,10 @@ namespace TLSharp.Tests
|
||||||
.OfType<TLUser>()
|
.OfType<TLUser>()
|
||||||
.FirstOrDefault(x => x.id == 5880094);
|
.FirstOrDefault(x => x.id == 5880094);
|
||||||
|
|
||||||
var photo = ((TLUserProfilePhoto)user.photo);
|
var photo = (TLUserProfilePhoto) user.photo;
|
||||||
var photoLocation = (TLFileLocation) photo.photo_big;
|
var photoLocation = (TLFileLocation) photo.photo_big;
|
||||||
|
|
||||||
var resFile = await client.GetFile(new TLInputFileLocation()
|
var resFile = await client.GetFile(new TLInputFileLocation
|
||||||
{
|
{
|
||||||
local_id = photoLocation.local_id,
|
local_id = photoLocation.local_id,
|
||||||
secret = photoLocation.secret,
|
secret = photoLocation.secret,
|
||||||
|
|
@ -326,8 +311,7 @@ namespace TLSharp.Tests
|
||||||
|
|
||||||
public virtual async Task FloodExceptionShouldNotCauseCannotReadPackageLengthError()
|
public virtual async Task FloodExceptionShouldNotCauseCannotReadPackageLengthError()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 50; i++)
|
for (var i = 0; i < 50; i++)
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await CheckPhones();
|
await CheckPhones();
|
||||||
|
|
@ -338,13 +322,13 @@ namespace TLSharp.Tests
|
||||||
Thread.Sleep(floodException.TimeToWait);
|
Thread.Sleep(floodException.TimeToWait);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public virtual async Task SendMessageByUserNameTest()
|
public virtual async Task SendMessageByUserNameTest()
|
||||||
{
|
{
|
||||||
UserNameToSendMessage = ConfigurationManager.AppSettings[nameof(UserNameToSendMessage)];
|
UserNameToSendMessage = ConfigurationManager.AppSettings[nameof(UserNameToSendMessage)];
|
||||||
if (string.IsNullOrWhiteSpace(UserNameToSendMessage))
|
if (string.IsNullOrWhiteSpace(UserNameToSendMessage))
|
||||||
throw new Exception($"Please fill the '{nameof(UserNameToSendMessage)}' setting in app.config file first");
|
throw new Exception(
|
||||||
|
$"Please fill the '{nameof(UserNameToSendMessage)}' setting in app.config file first");
|
||||||
|
|
||||||
var client = NewClient();
|
var client = NewClient();
|
||||||
|
|
||||||
|
|
@ -368,13 +352,24 @@ namespace TLSharp.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
throw new Exception("Username was not found: " + UserNameToSendMessage);
|
||||||
throw new System.Exception("Username was not found: " + UserNameToSendMessage);
|
|
||||||
|
await client.SendTypingAsync(new TLInputPeerUser {user_id = user.id});
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
await client.SendMessageAsync(new TLInputPeerUser {user_id = user.id}, "TEST");
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id });
|
private class Assert
|
||||||
Thread.Sleep(3000);
|
{
|
||||||
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
internal static void IsNotNull(object obj)
|
||||||
|
{
|
||||||
|
IsNotNullHanlder(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void IsTrue(bool cond)
|
||||||
|
{
|
||||||
|
IsTrueHandler(cond);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="ApiHash" value="" />
|
<add key="ApiHash" value="" />
|
||||||
<add key="ApiId" value="" />
|
<add key="ApiId" value="" />
|
||||||
<add key="NumberToAuthenticate" value="" />
|
<add key="NumberToAuthenticate" value="" />
|
||||||
<add key="CodeToAuthenticate" value="" />
|
<add key="CodeToAuthenticate" value="" />
|
||||||
<add key="PasswordToAuthenticate" value=""/>
|
<add key="PasswordToAuthenticate" value="" />
|
||||||
<add key="NotRegisteredNumberToSignUp" value=""/>
|
<add key="NotRegisteredNumberToSignUp" value="" />
|
||||||
<add key="NumberToSendMessage" value=""/>
|
<add key="NumberToSendMessage" value="" />
|
||||||
<add key="UserNameToSendMessage" value=""/>
|
<add key="UserNameToSendMessage" value="" />
|
||||||
<add key="NumberToGetUserFull" value=""/>
|
<add key="NumberToGetUserFull" value="" />
|
||||||
<add key="NumberToAddToChat" value=""/>
|
<add key="NumberToAddToChat" value="" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,36 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json.Schema;
|
|
||||||
namespace TeleSharp.Generator
|
namespace TeleSharp.Generator
|
||||||
{
|
{
|
||||||
class Method
|
internal class Method
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string method { get; set; }
|
public string method { get; set; }
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("params")]
|
[Newtonsoft.Json.JsonProperty("params")]
|
||||||
public List<Param> Params { get; set; }
|
public List<Param> Params { get; set; }
|
||||||
public string type { get; set; }
|
|
||||||
|
|
||||||
|
public string type { get; set; }
|
||||||
}
|
}
|
||||||
class Param
|
|
||||||
|
internal class Param
|
||||||
{
|
{
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
}
|
}
|
||||||
class Constructor
|
|
||||||
|
internal class Constructor
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string predicate { get; set; }
|
public string predicate { get; set; }
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonProperty("params")]
|
[Newtonsoft.Json.JsonProperty("params")]
|
||||||
public List<Param> Params { get; set; }
|
public List<Param> Params { get; set; }
|
||||||
|
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
}
|
}
|
||||||
class Schema
|
|
||||||
|
internal class Schema
|
||||||
{
|
{
|
||||||
public List<Constructor> constructors { get; set; }
|
public List<Constructor> constructors { get; set; }
|
||||||
public List<Method> methods { get; set; }
|
public List<Method> methods { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,44 @@
|
||||||
using Newtonsoft.Json;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using Newtonsoft.Json;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.CodeDom;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace TeleSharp.Generator
|
namespace TeleSharp.Generator
|
||||||
{
|
{
|
||||||
class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
static List<String> keywords = new List<string>(new string[] { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into", "join", "let", "orderby", "partial", "partial", "remove", "select", "set", "value", "var", "where", "where", "yield" });
|
private static readonly List<string> keywords = new List<string>(new[]
|
||||||
static List<String> interfacesList = new List<string>();
|
|
||||||
static List<String> classesList = new List<string>();
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
{
|
||||||
|
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const",
|
||||||
|
"continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern",
|
||||||
|
"false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "in", "int",
|
||||||
|
"interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out",
|
||||||
|
"out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte",
|
||||||
|
"sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true",
|
||||||
|
"try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile",
|
||||||
|
"while", "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global",
|
||||||
|
"group", "into", "join", "let", "orderby", "partial", "partial", "remove", "select", "set", "value", "var",
|
||||||
|
"where", "where", "yield"
|
||||||
|
});
|
||||||
|
|
||||||
string AbsStyle = File.ReadAllText("ConstructorAbs.tmp");
|
private static readonly List<string> interfacesList = new List<string>();
|
||||||
string NormalStyle = File.ReadAllText("Constructor.tmp");
|
private static readonly List<string> classesList = new List<string>();
|
||||||
string MethodStyle = File.ReadAllText("Method.tmp");
|
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var AbsStyle = File.ReadAllText("ConstructorAbs.tmp");
|
||||||
|
var NormalStyle = File.ReadAllText("Constructor.tmp");
|
||||||
|
var MethodStyle = File.ReadAllText("Method.tmp");
|
||||||
//string method = File.ReadAllText("constructor.tt");
|
//string method = File.ReadAllText("constructor.tt");
|
||||||
string Json = "";
|
var Json = "";
|
||||||
string url;
|
string url;
|
||||||
if (args.Count() == 0) url = "tl-schema.json"; else url = args[0];
|
if (args.Count() == 0) url = "tl-schema.json";
|
||||||
|
else url = args[0];
|
||||||
|
|
||||||
Json = File.ReadAllText(url);
|
Json = File.ReadAllText(url);
|
||||||
FileStream file = File.OpenWrite("Result.cs");
|
var file = File.OpenWrite("Result.cs");
|
||||||
StreamWriter sw = new StreamWriter(file);
|
var sw = new StreamWriter(file);
|
||||||
Schema schema = JsonConvert.DeserializeObject<Schema>(Json);
|
Schema schema = JsonConvert.DeserializeObject<Schema>(Json);
|
||||||
foreach (var c in schema.constructors)
|
foreach (var c in schema.constructors)
|
||||||
{
|
{
|
||||||
|
|
@ -41,14 +50,19 @@ namespace TeleSharp.Generator
|
||||||
var list = schema.constructors.Where(x => x.type == c.type);
|
var list = schema.constructors.Where(x => x.type == c.type);
|
||||||
if (list.Count() > 1)
|
if (list.Count() > 1)
|
||||||
{
|
{
|
||||||
string path = (GetNameSpace(c.type).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" + GetNameofClass(c.type, true) + ".cs").Replace("\\\\", "\\");
|
var path = (GetNameSpace(c.type).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" +
|
||||||
FileStream classFile = MakeFile(path);
|
GetNameofClass(c.type, true) + ".cs").Replace("\\\\", "\\");
|
||||||
using (StreamWriter writer = new StreamWriter(classFile))
|
var classFile = MakeFile(path);
|
||||||
|
using (var writer = new StreamWriter(classFile))
|
||||||
{
|
{
|
||||||
string nspace = (GetNameSpace(c.type).Replace("TeleSharp.TL", "TL\\").Replace(".", "")).Replace("\\\\", "\\").Replace("\\", ".");
|
var nspace = GetNameSpace(c.type)
|
||||||
|
.Replace("TeleSharp.TL", "TL\\")
|
||||||
|
.Replace(".", "")
|
||||||
|
.Replace("\\\\", "\\")
|
||||||
|
.Replace("\\", ".");
|
||||||
if (nspace.EndsWith("."))
|
if (nspace.EndsWith("."))
|
||||||
nspace = nspace.Remove(nspace.Length - 1, 1);
|
nspace = nspace.Remove(nspace.Length - 1, 1);
|
||||||
string temp = AbsStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
var temp = AbsStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
||||||
temp = temp.Replace("/* NAME */", GetNameofClass(c.type, true));
|
temp = temp.Replace("/* NAME */", GetNameofClass(c.type, true));
|
||||||
writer.Write(temp);
|
writer.Write(temp);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
|
|
@ -63,65 +77,85 @@ namespace TeleSharp.Generator
|
||||||
}
|
}
|
||||||
foreach (var c in schema.constructors)
|
foreach (var c in schema.constructors)
|
||||||
{
|
{
|
||||||
string path = (GetNameSpace(c.predicate).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" + GetNameofClass(c.predicate, false) + ".cs").Replace("\\\\", "\\");
|
var path = (GetNameSpace(c.predicate).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" +
|
||||||
FileStream classFile = MakeFile(path);
|
GetNameofClass(c.predicate, false) + ".cs").Replace("\\\\", "\\");
|
||||||
using (StreamWriter writer = new StreamWriter(classFile))
|
var classFile = MakeFile(path);
|
||||||
|
using (var writer = new StreamWriter(classFile))
|
||||||
{
|
{
|
||||||
#region About Class
|
#region About Class
|
||||||
string nspace = (GetNameSpace(c.predicate).Replace("TeleSharp.TL", "TL\\").Replace(".", "")).Replace("\\\\", "\\").Replace("\\", ".");
|
|
||||||
|
var nspace = GetNameSpace(c.predicate)
|
||||||
|
.Replace("TeleSharp.TL", "TL\\")
|
||||||
|
.Replace(".", "")
|
||||||
|
.Replace("\\\\", "\\")
|
||||||
|
.Replace("\\", ".");
|
||||||
if (nspace.EndsWith("."))
|
if (nspace.EndsWith("."))
|
||||||
nspace = nspace.Remove(nspace.Length - 1, 1);
|
nspace = nspace.Remove(nspace.Length - 1, 1);
|
||||||
string temp = NormalStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
var temp = NormalStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
||||||
temp = (c.type == "himself") ? temp.Replace("/* PARENT */", "TLObject") : temp.Replace("/* PARENT */", GetNameofClass(c.type, true));
|
temp = c.type == "himself"
|
||||||
|
? temp.Replace("/* PARENT */", "TLObject")
|
||||||
|
: temp.Replace("/* PARENT */", GetNameofClass(c.type, true));
|
||||||
temp = temp.Replace("/*Constructor*/", c.id.ToString());
|
temp = temp.Replace("/*Constructor*/", c.id.ToString());
|
||||||
temp = temp.Replace("/* NAME */", GetNameofClass(c.predicate, false));
|
temp = temp.Replace("/* NAME */", GetNameofClass(c.predicate, false));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
string fields = "";
|
|
||||||
|
var fields = "";
|
||||||
foreach (var tmp in c.Params)
|
foreach (var tmp in c.Params)
|
||||||
{
|
fields +=
|
||||||
fields += $" public {CheckForFlagBase(tmp.type, GetTypeName(tmp.type))} {CheckForKeyword(tmp.name)} " + "{get;set;}" + Environment.NewLine;
|
$" public {CheckForFlagBase(tmp.type, GetTypeName(tmp.type))} {CheckForKeyword(tmp.name)} " +
|
||||||
}
|
"{get;set;}" + Environment.NewLine;
|
||||||
temp = temp.Replace("/* PARAMS */", fields);
|
temp = temp.Replace("/* PARAMS */", fields);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ComputeFlagFunc
|
#region ComputeFlagFunc
|
||||||
if (!c.Params.Any(x => x.name == "flags")) temp = temp.Replace("/* COMPUTE */", "");
|
|
||||||
|
if (!c.Params.Any(x => x.name == "flags"))
|
||||||
|
{
|
||||||
|
temp = temp.Replace("/* COMPUTE */", "");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var compute = "flags = 0;" + Environment.NewLine;
|
var compute = "flags = 0;" + Environment.NewLine;
|
||||||
foreach (var param in c.Params.Where(x => IsFlagBase(x.type)))
|
foreach (var param in c.Params.Where(x => IsFlagBase(x.type)))
|
||||||
{
|
|
||||||
if (IsTrueFlag(param.type))
|
if (IsTrueFlag(param.type))
|
||||||
{
|
compute +=
|
||||||
compute += $"flags = {CheckForKeyword(param.name)} ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" + Environment.NewLine;
|
$"flags = {CheckForKeyword(param.name)} ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" +
|
||||||
}
|
Environment.NewLine;
|
||||||
else
|
else
|
||||||
{
|
compute +=
|
||||||
compute += $"flags = {CheckForKeyword(param.name)} != null ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" + Environment.NewLine;
|
$"flags = {CheckForKeyword(param.name)} != null ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" +
|
||||||
}
|
Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* COMPUTE */", compute);
|
temp = temp.Replace("/* COMPUTE */", compute);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SerializeFunc
|
#region SerializeFunc
|
||||||
|
|
||||||
var serialize = "";
|
var serialize = "";
|
||||||
|
|
||||||
if (c.Params.Any(x => x.name == "flags")) serialize += "ComputeFlags();" + Environment.NewLine + "bw.Write(flags);" + Environment.NewLine;
|
if (c.Params.Any(x => x.name == "flags"))
|
||||||
|
serialize += "ComputeFlags();" + Environment.NewLine + "bw.Write(flags);" + Environment.NewLine;
|
||||||
foreach (var p in c.Params.Where(x => x.name != "flags"))
|
foreach (var p in c.Params.Where(x => x.name != "flags"))
|
||||||
{
|
|
||||||
serialize += WriteWriteCode(p) + Environment.NewLine;
|
serialize += WriteWriteCode(p) + Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* SERIALIZE */", serialize);
|
temp = temp.Replace("/* SERIALIZE */", serialize);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeSerializeFunc
|
#region DeSerializeFunc
|
||||||
|
|
||||||
var deserialize = "";
|
var deserialize = "";
|
||||||
|
|
||||||
foreach (var p in c.Params)
|
foreach (var p in c.Params)
|
||||||
{
|
|
||||||
deserialize += WriteReadCode(p) + Environment.NewLine;
|
deserialize += WriteReadCode(p) + Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* DESERIALIZE */", deserialize);
|
temp = temp.Replace("/* DESERIALIZE */", deserialize);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
writer.Write(temp);
|
writer.Write(temp);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
classFile.Close();
|
classFile.Close();
|
||||||
|
|
@ -129,151 +163,174 @@ namespace TeleSharp.Generator
|
||||||
}
|
}
|
||||||
foreach (var c in schema.methods)
|
foreach (var c in schema.methods)
|
||||||
{
|
{
|
||||||
string path = (GetNameSpace(c.method).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" + GetNameofClass(c.method, false, true) + ".cs").Replace("\\\\", "\\");
|
var path = (GetNameSpace(c.method).Replace("TeleSharp.TL", "TL\\").Replace(".", "") + "\\" +
|
||||||
FileStream classFile = MakeFile(path);
|
GetNameofClass(c.method, false, true) + ".cs").Replace("\\\\", "\\");
|
||||||
using (StreamWriter writer = new StreamWriter(classFile))
|
var classFile = MakeFile(path);
|
||||||
|
using (var writer = new StreamWriter(classFile))
|
||||||
{
|
{
|
||||||
#region About Class
|
#region About Class
|
||||||
string nspace = (GetNameSpace(c.method).Replace("TeleSharp.TL", "TL\\").Replace(".", "")).Replace("\\\\", "\\").Replace("\\", ".");
|
|
||||||
|
var nspace = GetNameSpace(c.method)
|
||||||
|
.Replace("TeleSharp.TL", "TL\\")
|
||||||
|
.Replace(".", "")
|
||||||
|
.Replace("\\\\", "\\")
|
||||||
|
.Replace("\\", ".");
|
||||||
if (nspace.EndsWith("."))
|
if (nspace.EndsWith("."))
|
||||||
nspace = nspace.Remove(nspace.Length - 1, 1);
|
nspace = nspace.Remove(nspace.Length - 1, 1);
|
||||||
string temp = MethodStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
var temp = MethodStyle.Replace("/* NAMESPACE */", "TeleSharp." + nspace);
|
||||||
temp = temp.Replace("/* PARENT */", "TLMethod");
|
temp = temp.Replace("/* PARENT */", "TLMethod");
|
||||||
temp = temp.Replace("/*Constructor*/", c.id.ToString());
|
temp = temp.Replace("/*Constructor*/", c.id.ToString());
|
||||||
temp = temp.Replace("/* NAME */", GetNameofClass(c.method, false, true));
|
temp = temp.Replace("/* NAME */", GetNameofClass(c.method, false, true));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
string fields = "";
|
|
||||||
|
var fields = "";
|
||||||
foreach (var tmp in c.Params)
|
foreach (var tmp in c.Params)
|
||||||
{
|
fields +=
|
||||||
fields += $" public {CheckForFlagBase(tmp.type, GetTypeName(tmp.type))} {CheckForKeyword(tmp.name)} " + "{get;set;}" + Environment.NewLine;
|
$" public {CheckForFlagBase(tmp.type, GetTypeName(tmp.type))} {CheckForKeyword(tmp.name)} " +
|
||||||
}
|
"{get;set;}" + Environment.NewLine;
|
||||||
fields += $" public {CheckForFlagBase(c.type, GetTypeName(c.type))} Response" + "{ get; set;}" + Environment.NewLine;
|
fields += $" public {CheckForFlagBase(c.type, GetTypeName(c.type))} Response" +
|
||||||
|
"{ get; set;}" + Environment.NewLine;
|
||||||
temp = temp.Replace("/* PARAMS */", fields);
|
temp = temp.Replace("/* PARAMS */", fields);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ComputeFlagFunc
|
#region ComputeFlagFunc
|
||||||
if (!c.Params.Any(x => x.name == "flags")) temp = temp.Replace("/* COMPUTE */", "");
|
|
||||||
|
if (!c.Params.Any(x => x.name == "flags"))
|
||||||
|
{
|
||||||
|
temp = temp.Replace("/* COMPUTE */", "");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var compute = "flags = 0;" + Environment.NewLine;
|
var compute = "flags = 0;" + Environment.NewLine;
|
||||||
foreach (var param in c.Params.Where(x => IsFlagBase(x.type)))
|
foreach (var param in c.Params.Where(x => IsFlagBase(x.type)))
|
||||||
{
|
|
||||||
if (IsTrueFlag(param.type))
|
if (IsTrueFlag(param.type))
|
||||||
{
|
compute +=
|
||||||
compute += $"flags = {CheckForKeyword(param.name)} ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" + Environment.NewLine;
|
$"flags = {CheckForKeyword(param.name)} ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" +
|
||||||
}
|
Environment.NewLine;
|
||||||
else
|
else
|
||||||
{
|
compute +=
|
||||||
compute += $"flags = {CheckForKeyword(param.name)} != null ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" + Environment.NewLine;
|
$"flags = {CheckForKeyword(param.name)} != null ? (flags | {GetBitMask(param.type)}) : (flags & ~{GetBitMask(param.type)});" +
|
||||||
}
|
Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* COMPUTE */", compute);
|
temp = temp.Replace("/* COMPUTE */", compute);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SerializeFunc
|
#region SerializeFunc
|
||||||
|
|
||||||
var serialize = "";
|
var serialize = "";
|
||||||
|
|
||||||
if (c.Params.Any(x => x.name == "flags")) serialize += "ComputeFlags();" + Environment.NewLine + "bw.Write(flags);" + Environment.NewLine;
|
if (c.Params.Any(x => x.name == "flags"))
|
||||||
|
serialize += "ComputeFlags();" + Environment.NewLine + "bw.Write(flags);" + Environment.NewLine;
|
||||||
foreach (var p in c.Params.Where(x => x.name != "flags"))
|
foreach (var p in c.Params.Where(x => x.name != "flags"))
|
||||||
{
|
|
||||||
serialize += WriteWriteCode(p) + Environment.NewLine;
|
serialize += WriteWriteCode(p) + Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* SERIALIZE */", serialize);
|
temp = temp.Replace("/* SERIALIZE */", serialize);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeSerializeFunc
|
#region DeSerializeFunc
|
||||||
|
|
||||||
var deserialize = "";
|
var deserialize = "";
|
||||||
|
|
||||||
foreach (var p in c.Params)
|
foreach (var p in c.Params)
|
||||||
{
|
|
||||||
deserialize += WriteReadCode(p) + Environment.NewLine;
|
deserialize += WriteReadCode(p) + Environment.NewLine;
|
||||||
}
|
|
||||||
temp = temp.Replace("/* DESERIALIZE */", deserialize);
|
temp = temp.Replace("/* DESERIALIZE */", deserialize);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeSerializeRespFunc
|
#region DeSerializeRespFunc
|
||||||
|
|
||||||
var deserializeResp = "";
|
var deserializeResp = "";
|
||||||
Param p2 = new Param() { name = "Response", type = c.type };
|
var p2 = new Param {name = "Response", type = c.type};
|
||||||
deserializeResp += WriteReadCode(p2) + Environment.NewLine;
|
deserializeResp += WriteReadCode(p2) + Environment.NewLine;
|
||||||
temp = temp.Replace("/* DESERIALIZEResp */", deserializeResp);
|
temp = temp.Replace("/* DESERIALIZEResp */", deserializeResp);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
writer.Write(temp);
|
writer.Write(temp);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
classFile.Close();
|
classFile.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatName(string input)
|
public static string FormatName(string input)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(input))
|
if (string.IsNullOrEmpty(input))
|
||||||
throw new ArgumentException("ARGH!");
|
throw new ArgumentException("ARGH!");
|
||||||
if (input.IndexOf('.') != -1)
|
if (input.IndexOf('.') != -1)
|
||||||
{
|
{
|
||||||
input = input.Replace(".", " ");
|
input = input.Replace(".", " ");
|
||||||
var temp = "";
|
var temp = "";
|
||||||
foreach (var s in input.Split(' '))
|
foreach (var s in input.Split(' '))
|
||||||
{
|
|
||||||
temp += FormatName(s) + " ";
|
temp += FormatName(s) + " ";
|
||||||
}
|
|
||||||
input = temp.Trim();
|
input = temp.Trim();
|
||||||
}
|
}
|
||||||
return input.First().ToString().ToUpper() + input.Substring(1);
|
return input.First().ToString().ToUpper() + input.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CheckForKeyword(string name)
|
public static string CheckForKeyword(string name)
|
||||||
{
|
{
|
||||||
if (keywords.Contains(name)) return "@" + name;
|
if (keywords.Contains(name)) return "@" + name;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetNameofClass(string type, bool isinterface = false, bool ismethod = false)
|
public static string GetNameofClass(string type, bool isinterface = false, bool ismethod = false)
|
||||||
{
|
{
|
||||||
if (!ismethod)
|
if (!ismethod)
|
||||||
{
|
|
||||||
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
||||||
return isinterface ? "TLAbs" + FormatName(type.Split('.')[1]) : "TL" + FormatName(type.Split('.')[1]);
|
return isinterface
|
||||||
|
? "TLAbs" + FormatName(type.Split('.')[1])
|
||||||
|
: "TL" + FormatName(type.Split('.')[1]);
|
||||||
else if (type.IndexOf('.') != -1 && type.IndexOf('?') != -1)
|
else if (type.IndexOf('.') != -1 && type.IndexOf('?') != -1)
|
||||||
return isinterface ? "TLAbs" + FormatName(type.Split('?')[1]) : "TL" + FormatName(type.Split('?')[1]);
|
return isinterface
|
||||||
|
? "TLAbs" + FormatName(type.Split('?')[1])
|
||||||
|
: "TL" + FormatName(type.Split('?')[1]);
|
||||||
else
|
else
|
||||||
return isinterface ? "TLAbs" + FormatName(type) : "TL" + FormatName(type);
|
return isinterface ? "TLAbs" + FormatName(type) : "TL" + FormatName(type);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
||||||
return "TLRequest" + FormatName(type.Split('.')[1]);
|
return "TLRequest" + FormatName(type.Split('.')[1]);
|
||||||
else if (type.IndexOf('.') != -1 && type.IndexOf('?') != -1)
|
if (type.IndexOf('.') != -1 && type.IndexOf('?') != -1)
|
||||||
return "TLRequest" + FormatName(type.Split('?')[1]);
|
return "TLRequest" + FormatName(type.Split('?')[1]);
|
||||||
else
|
|
||||||
return "TLRequest" + FormatName(type);
|
return "TLRequest" + FormatName(type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private static bool IsFlagBase(string type)
|
private static bool IsFlagBase(string type)
|
||||||
{
|
{
|
||||||
return type.IndexOf("?") != -1;
|
return type.IndexOf("?") != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetBitMask(string type)
|
private static int GetBitMask(string type)
|
||||||
{
|
{
|
||||||
return (int)Math.Pow((double)2, (double)int.Parse(type.Split('?')[0].Split('.')[1]));
|
return (int) Math.Pow(2, int.Parse(type.Split('?')[0].Split('.')[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsTrueFlag(string type)
|
private static bool IsTrueFlag(string type)
|
||||||
{
|
{
|
||||||
return type.Split('?')[1] == "true";
|
return type.Split('?')[1] == "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetNameSpace(string type)
|
public static string GetNameSpace(string type)
|
||||||
{
|
{
|
||||||
if (type.IndexOf('.') != -1)
|
if (type.IndexOf('.') != -1)
|
||||||
return "TeleSharp.TL" + FormatName(type.Split('.')[0]);
|
return "TeleSharp.TL" + FormatName(type.Split('.')[0]);
|
||||||
else
|
|
||||||
return "TeleSharp.TL";
|
return "TeleSharp.TL";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CheckForFlagBase(string type, string result)
|
public static string CheckForFlagBase(string type, string result)
|
||||||
{
|
{
|
||||||
if (type.IndexOf('?') == -1)
|
if (type.IndexOf('?') == -1)
|
||||||
return result;
|
return result;
|
||||||
else
|
var innerType = type.Split('?')[1];
|
||||||
{
|
|
||||||
string innerType = type.Split('?')[1];
|
|
||||||
if (innerType == "true") return result;
|
if (innerType == "true") return result;
|
||||||
else if ((new string[] { "bool", "int", "uint", "long", "double" }).Contains(result)) return result + "?";
|
if (new[] {"bool", "int", "uint", "long", "double"}.Contains(result)) return result + "?";
|
||||||
else return result;
|
return result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetTypeName(string type)
|
public static string GetTypeName(string type)
|
||||||
{
|
{
|
||||||
switch (type.ToLower())
|
switch (type.ToLower())
|
||||||
|
|
@ -308,75 +365,74 @@ namespace TeleSharp.Generator
|
||||||
|
|
||||||
|
|
||||||
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
if (type.IndexOf('.') != -1 && type.IndexOf('?') == -1)
|
||||||
{
|
if (interfacesList.Any(x => x.ToLower() == type.ToLower()))
|
||||||
|
|
||||||
if (interfacesList.Any(x => x.ToLower() == (type).ToLower()))
|
|
||||||
return FormatName(type.Split('.')[0]) + "." + "TLAbs" + type.Split('.')[1];
|
return FormatName(type.Split('.')[0]) + "." + "TLAbs" + type.Split('.')[1];
|
||||||
else if (classesList.Any(x => x.ToLower() == (type).ToLower()))
|
else if (classesList.Any(x => x.ToLower() == type.ToLower()))
|
||||||
return FormatName(type.Split('.')[0]) + "." + "TL" + type.Split('.')[1];
|
return FormatName(type.Split('.')[0]) + "." + "TL" + type.Split('.')[1];
|
||||||
else
|
else
|
||||||
return FormatName(type.Split('.')[1]);
|
return FormatName(type.Split('.')[1]);
|
||||||
}
|
if (type.IndexOf('?') == -1)
|
||||||
else if (type.IndexOf('?') == -1)
|
|
||||||
{
|
|
||||||
if (interfacesList.Any(x => x.ToLower() == type.ToLower()))
|
if (interfacesList.Any(x => x.ToLower() == type.ToLower()))
|
||||||
return "TLAbs" + type;
|
return "TLAbs" + type;
|
||||||
else if (classesList.Any(x => x.ToLower() == type.ToLower()))
|
else if (classesList.Any(x => x.ToLower() == type.ToLower()))
|
||||||
return "TL" + type;
|
return "TL" + type;
|
||||||
else
|
else
|
||||||
return type;
|
return type;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return GetTypeName(type.Split('?')[1]);
|
return GetTypeName(type.Split('?')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public static string LookTypeInLists(string src)
|
public static string LookTypeInLists(string src)
|
||||||
{
|
{
|
||||||
if (interfacesList.Any(x => x.ToLower() == src.ToLower()))
|
if (interfacesList.Any(x => x.ToLower() == src.ToLower()))
|
||||||
return "TLAbs" + FormatName(src);
|
return "TLAbs" + FormatName(src);
|
||||||
else if (classesList.Any(x => x.ToLower() == src.ToLower()))
|
if (classesList.Any(x => x.ToLower() == src.ToLower()))
|
||||||
return "TL" + FormatName(src);
|
return "TL" + FormatName(src);
|
||||||
else
|
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string WriteWriteCode(Param p, bool flag = false)
|
public static string WriteWriteCode(Param p, bool flag = false)
|
||||||
{
|
{
|
||||||
switch (p.type.ToLower())
|
switch (p.type.ToLower())
|
||||||
{
|
{
|
||||||
case "#":
|
case "#":
|
||||||
case "int":
|
case "int":
|
||||||
return flag ? $"bw.Write({CheckForKeyword(p.name)}.Value);" : $"bw.Write({CheckForKeyword(p.name)});";
|
return flag
|
||||||
|
? $"bw.Write({CheckForKeyword(p.name)}.Value);"
|
||||||
|
: $"bw.Write({CheckForKeyword(p.name)});";
|
||||||
case "long":
|
case "long":
|
||||||
return flag ? $"bw.Write({CheckForKeyword(p.name)}.Value);" : $"bw.Write({CheckForKeyword(p.name)});";
|
return flag
|
||||||
|
? $"bw.Write({CheckForKeyword(p.name)}.Value);"
|
||||||
|
: $"bw.Write({CheckForKeyword(p.name)});";
|
||||||
case "string":
|
case "string":
|
||||||
return $"StringUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
return $"StringUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
||||||
case "bool":
|
case "bool":
|
||||||
return flag ? $"BoolUtil.Serialize({CheckForKeyword(p.name)}.Value,bw);" : $"BoolUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
return flag
|
||||||
|
? $"BoolUtil.Serialize({CheckForKeyword(p.name)}.Value,bw);"
|
||||||
|
: $"BoolUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
||||||
case "true":
|
case "true":
|
||||||
return $"BoolUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
return $"BoolUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
||||||
case "bytes":
|
case "bytes":
|
||||||
return $"BytesUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
return $"BytesUtil.Serialize({CheckForKeyword(p.name)},bw);";
|
||||||
case "double":
|
case "double":
|
||||||
return flag ? $"bw.Write({CheckForKeyword(p.name)}.Value);" : $"bw.Write({CheckForKeyword(p.name)});";
|
return flag
|
||||||
|
? $"bw.Write({CheckForKeyword(p.name)}.Value);"
|
||||||
|
: $"bw.Write({CheckForKeyword(p.name)});";
|
||||||
default:
|
default:
|
||||||
if (!IsFlagBase(p.type))
|
if (!IsFlagBase(p.type))
|
||||||
|
{
|
||||||
return $"ObjectUtils.SerializeObject({CheckForKeyword(p.name)},bw);";
|
return $"ObjectUtils.SerializeObject({CheckForKeyword(p.name)},bw);";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsTrueFlag(p.type))
|
if (IsTrueFlag(p.type))
|
||||||
return $"";
|
return $"";
|
||||||
else
|
var p2 = new Param {name = p.name, type = p.type.Split('?')[1]};
|
||||||
{
|
return $"if ((flags & {GetBitMask(p.type)}) != 0)" + Environment.NewLine +
|
||||||
Param p2 = new Param() { name = p.name, type = p.type.Split('?')[1] };
|
|
||||||
return $"if ((flags & {GetBitMask(p.type).ToString()}) != 0)" + Environment.NewLine +
|
|
||||||
WriteWriteCode(p2, true);
|
WriteWriteCode(p2, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static string WriteReadCode(Param p)
|
public static string WriteReadCode(Param p)
|
||||||
{
|
{
|
||||||
switch (p.type.ToLower())
|
switch (p.type.ToLower())
|
||||||
|
|
@ -399,26 +455,25 @@ namespace TeleSharp.Generator
|
||||||
if (!IsFlagBase(p.type))
|
if (!IsFlagBase(p.type))
|
||||||
{
|
{
|
||||||
if (p.type.ToLower().Contains("vector"))
|
if (p.type.ToLower().Contains("vector"))
|
||||||
{
|
return
|
||||||
return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeVector<{GetTypeName(p.type).Replace("TLVector<", "").Replace(">", "")}>(br);";
|
$"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeVector<{GetTypeName(p.type).Replace("TLVector<", "").Replace(">", "")}>(br);";
|
||||||
}
|
return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeObject(br);";
|
||||||
else return $"{CheckForKeyword(p.name)} = ({GetTypeName(p.type)})ObjectUtils.DeserializeObject(br);";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsTrueFlag(p.type))
|
if (IsTrueFlag(p.type))
|
||||||
return $"{CheckForKeyword(p.name)} = (flags & {GetBitMask(p.type).ToString()}) != 0;";
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Param p2 = new Param() { name = p.name, type = p.type.Split('?')[1] };
|
return $"{CheckForKeyword(p.name)} = (flags & {GetBitMask(p.type)}) != 0;";
|
||||||
return $"if ((flags & {GetBitMask(p.type).ToString()}) != 0)" + Environment.NewLine +
|
}
|
||||||
|
var p2 = new Param {name = p.name, type = p.type.Split('?')[1]};
|
||||||
|
return $"if ((flags & {GetBitMask(p.type)}) != 0)" + Environment.NewLine +
|
||||||
WriteReadCode(p2) + Environment.NewLine +
|
WriteReadCode(p2) + Environment.NewLine +
|
||||||
"else" + Environment.NewLine +
|
"else" + Environment.NewLine +
|
||||||
$"{CheckForKeyword(p.name)} = null;" + Environment.NewLine;
|
$"{CheckForKeyword(p.name)} = null;" + Environment.NewLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static FileStream MakeFile(string path)
|
public static FileStream MakeFile(string path)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.GetDirectoryName(path)))
|
if (!Directory.Exists(Path.GetDirectoryName(path)))
|
||||||
|
|
@ -428,5 +483,4 @@ namespace TeleSharp.Generator
|
||||||
return File.OpenWrite(path);
|
return File.OpenWrite(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -1,48 +1,46 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL
|
namespace TeleSharp.TL
|
||||||
{
|
{
|
||||||
public class ObjectUtils
|
public class ObjectUtils
|
||||||
{
|
{
|
||||||
public static object DeserializeObject(BinaryReader reader)
|
public static object DeserializeObject(BinaryReader reader)
|
||||||
{
|
{
|
||||||
int Constructor = reader.ReadInt32();
|
var Constructor = reader.ReadInt32();
|
||||||
object obj;
|
object obj;
|
||||||
Type t =null;
|
Type t = null;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
t = TLContext.getType(Constructor);
|
t = TLContext.getType(Constructor);
|
||||||
obj = Activator.CreateInstance(t);
|
obj = Activator.CreateInstance(t);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
|
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
|
||||||
}
|
}
|
||||||
if (t.IsSubclassOf(typeof(TLMethod)))
|
if (t.IsSubclassOf(typeof(TLMethod)))
|
||||||
{
|
{
|
||||||
((TLMethod)obj).deserializeResponse(reader);
|
((TLMethod) obj).deserializeResponse(reader);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
else if (t.IsSubclassOf(typeof(TLObject)))
|
if (t.IsSubclassOf(typeof(TLObject)))
|
||||||
{
|
{
|
||||||
((TLObject)obj).DeserializeBody(reader);
|
((TLObject) obj).DeserializeBody(reader);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
else throw new NotImplementedException("Weird Type : " + t.Namespace + " | " + t.Name);
|
throw new NotImplementedException("Weird Type : " + t.Namespace + " | " + t.Name);
|
||||||
}
|
}
|
||||||
public static void SerializeObject(object obj,BinaryWriter writer)
|
|
||||||
|
public static void SerializeObject(object obj, BinaryWriter writer)
|
||||||
{
|
{
|
||||||
((TLObject)obj).SerializeBody(writer);
|
((TLObject) obj).SerializeBody(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TLVector<T> DeserializeVector<T>(BinaryReader reader)
|
public static TLVector<T> DeserializeVector<T>(BinaryReader reader)
|
||||||
{
|
{
|
||||||
if (reader.ReadInt32() != 481674261) throw new InvalidDataException("Bad Constructor");
|
if (reader.ReadInt32() != 481674261) throw new InvalidDataException("Bad Constructor");
|
||||||
TLVector<T> t = new TLVector<T>();
|
var t = new TLVector<T>();
|
||||||
t.DeserializeBody(reader);
|
t.DeserializeBody(reader);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
public abstract class TLAbsPassword : TLObject
|
public abstract class TLAbsPassword : TLObject
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(307276766)]
|
[TLObject(307276766)]
|
||||||
public class TLAuthorizations : TLObject
|
public class TLAuthorizations : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 307276766;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 307276766;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLVector<TLAuthorization> authorizations {get;set;}
|
public TLVector<TLAuthorization> authorizations { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
authorizations = (TLVector<TLAuthorization>)ObjectUtils.DeserializeVector<TLAuthorization>(br);
|
authorizations = ObjectUtils.DeserializeVector<TLAuthorization>(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(authorizations,bw);
|
ObjectUtils.SerializeObject(authorizations, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-1764049896)]
|
[TLObject(-1764049896)]
|
||||||
public class TLNoPassword : TLAbsPassword
|
public class TLNoPassword : TLAbsPassword
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1764049896;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1764049896;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] new_salt {get;set;}
|
public byte[] new_salt { get; set; }
|
||||||
public string email_unconfirmed_pattern {get;set;}
|
public string email_unconfirmed_pattern { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
new_salt = BytesUtil.Deserialize(br);
|
new_salt = BytesUtil.Deserialize(br);
|
||||||
email_unconfirmed_pattern = StringUtil.Deserialize(br);
|
email_unconfirmed_pattern = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BytesUtil.Serialize(new_salt,bw);
|
BytesUtil.Serialize(new_salt, bw);
|
||||||
StringUtil.Serialize(email_unconfirmed_pattern,bw);
|
StringUtil.Serialize(email_unconfirmed_pattern, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,54 +1,40 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(2081952796)]
|
[TLObject(2081952796)]
|
||||||
public class TLPassword : TLAbsPassword
|
public class TLPassword : TLAbsPassword
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 2081952796;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 2081952796;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] current_salt {get;set;}
|
public byte[] current_salt { get; set; }
|
||||||
public byte[] new_salt {get;set;}
|
public byte[] new_salt { get; set; }
|
||||||
public string hint {get;set;}
|
public string hint { get; set; }
|
||||||
public bool has_recovery {get;set;}
|
public bool has_recovery { get; set; }
|
||||||
public string email_unconfirmed_pattern {get;set;}
|
public string email_unconfirmed_pattern { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
current_salt = BytesUtil.Deserialize(br);
|
current_salt = BytesUtil.Deserialize(br);
|
||||||
new_salt = BytesUtil.Deserialize(br);
|
new_salt = BytesUtil.Deserialize(br);
|
||||||
hint = StringUtil.Deserialize(br);
|
hint = StringUtil.Deserialize(br);
|
||||||
has_recovery = BoolUtil.Deserialize(br);
|
has_recovery = BoolUtil.Deserialize(br);
|
||||||
email_unconfirmed_pattern = StringUtil.Deserialize(br);
|
email_unconfirmed_pattern = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BytesUtil.Serialize(current_salt,bw);
|
BytesUtil.Serialize(current_salt, bw);
|
||||||
BytesUtil.Serialize(new_salt,bw);
|
BytesUtil.Serialize(new_salt, bw);
|
||||||
StringUtil.Serialize(hint,bw);
|
StringUtil.Serialize(hint, bw);
|
||||||
BoolUtil.Serialize(has_recovery,bw);
|
BoolUtil.Serialize(has_recovery, bw);
|
||||||
StringUtil.Serialize(email_unconfirmed_pattern,bw);
|
StringUtil.Serialize(email_unconfirmed_pattern, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,80 +1,65 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-2037289493)]
|
[TLObject(-2037289493)]
|
||||||
public class TLPasswordInputSettings : TLObject
|
public class TLPasswordInputSettings : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -2037289493;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -2037289493;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public byte[] new_salt {get;set;}
|
public byte[] new_salt { get; set; }
|
||||||
public byte[] new_password_hash {get;set;}
|
public byte[] new_password_hash { get; set; }
|
||||||
public string hint {get;set;}
|
public string hint { get; set; }
|
||||||
public string email {get;set;}
|
public string email { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = new_salt != null ? (flags | 1) : (flags & ~1);
|
flags = new_salt != null ? flags | 1 : flags & ~1;
|
||||||
flags = new_password_hash != null ? (flags | 1) : (flags & ~1);
|
flags = new_password_hash != null ? flags | 1 : flags & ~1;
|
||||||
flags = hint != null ? (flags | 1) : (flags & ~1);
|
flags = hint != null ? flags | 1 : flags & ~1;
|
||||||
flags = email != null ? (flags | 2) : (flags & ~2);
|
flags = email != null ? flags | 2 : flags & ~2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
new_salt = BytesUtil.Deserialize(br);
|
new_salt = BytesUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
new_salt = null;
|
new_salt = null;
|
||||||
|
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
new_password_hash = BytesUtil.Deserialize(br);
|
new_password_hash = BytesUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
new_password_hash = null;
|
new_password_hash = null;
|
||||||
|
|
||||||
if ((flags & 1) != 0)
|
|
||||||
hint = StringUtil.Deserialize(br);
|
|
||||||
else
|
|
||||||
hint = null;
|
|
||||||
|
|
||||||
if ((flags & 2) != 0)
|
|
||||||
email = StringUtil.Deserialize(br);
|
|
||||||
else
|
|
||||||
email = null;
|
|
||||||
|
|
||||||
|
if ((flags & 1) != 0)
|
||||||
|
hint = StringUtil.Deserialize(br);
|
||||||
|
else
|
||||||
|
hint = null;
|
||||||
|
|
||||||
|
if ((flags & 2) != 0)
|
||||||
|
email = StringUtil.Deserialize(br);
|
||||||
|
else
|
||||||
|
email = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
BytesUtil.Serialize(new_salt,bw);
|
BytesUtil.Serialize(new_salt, bw);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
BytesUtil.Serialize(new_password_hash,bw);
|
BytesUtil.Serialize(new_password_hash, bw);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
StringUtil.Serialize(hint,bw);
|
StringUtil.Serialize(hint, bw);
|
||||||
if ((flags & 2) != 0)
|
if ((flags & 2) != 0)
|
||||||
StringUtil.Serialize(email,bw);
|
StringUtil.Serialize(email, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-1212732749)]
|
[TLObject(-1212732749)]
|
||||||
public class TLPasswordSettings : TLObject
|
public class TLPasswordSettings : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1212732749;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1212732749;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string email {get;set;}
|
public string email { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
email = StringUtil.Deserialize(br);
|
email = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(email,bw);
|
StringUtil.Serialize(email, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1430961007)]
|
[TLObject(1430961007)]
|
||||||
public class TLPrivacyRules : TLObject
|
public class TLPrivacyRules : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1430961007;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1430961007;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLVector<TLAbsPrivacyRule> rules {get;set;}
|
public TLVector<TLAbsPrivacyRule> rules { get; set; }
|
||||||
public TLVector<TLAbsUser> users {get;set;}
|
public TLVector<TLAbsUser> users { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
rules = (TLVector<TLAbsPrivacyRule>)ObjectUtils.DeserializeVector<TLAbsPrivacyRule>(br);
|
rules = ObjectUtils.DeserializeVector<TLAbsPrivacyRule>(br);
|
||||||
users = (TLVector<TLAbsUser>)ObjectUtils.DeserializeVector<TLAbsUser>(br);
|
users = ObjectUtils.DeserializeVector<TLAbsUser>(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(rules,bw);
|
ObjectUtils.SerializeObject(rules, bw);
|
||||||
ObjectUtils.SerializeObject(users,bw);
|
ObjectUtils.SerializeObject(users, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,54 +1,40 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1891839707)]
|
[TLObject(1891839707)]
|
||||||
public class TLRequestChangePhone : TLMethod
|
public class TLRequestChangePhone : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1891839707;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1891839707;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public string phone_code {get;set;}
|
public string phone_code { get; set; }
|
||||||
public TLAbsUser Response{ get; set;}
|
public TLAbsUser Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
phone_code = StringUtil.Deserialize(br);
|
phone_code = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
StringUtil.Serialize(phone_code,bw);
|
StringUtil.Serialize(phone_code, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLAbsUser)ObjectUtils.DeserializeObject(br);
|
Response = (TLAbsUser) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(655677548)]
|
[TLObject(655677548)]
|
||||||
public class TLRequestCheckUsername : TLMethod
|
public class TLRequestCheckUsername : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 655677548;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 655677548;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string username {get;set;}
|
public string username { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
username = StringUtil.Deserialize(br);
|
username = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(username,bw);
|
StringUtil.Serialize(username, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1596029123)]
|
[TLObject(1596029123)]
|
||||||
public class TLRequestConfirmPhone : TLMethod
|
public class TLRequestConfirmPhone : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1596029123;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1596029123;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public string phone_code {get;set;}
|
public string phone_code { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
phone_code = StringUtil.Deserialize(br);
|
phone_code = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
StringUtil.Serialize(phone_code,bw);
|
StringUtil.Serialize(phone_code, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1099779595)]
|
[TLObject(1099779595)]
|
||||||
public class TLRequestDeleteAccount : TLMethod
|
public class TLRequestDeleteAccount : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1099779595;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1099779595;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string reason {get;set;}
|
public string reason { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
reason = StringUtil.Deserialize(br);
|
reason = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(reason,bw);
|
StringUtil.Serialize(reason, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(150761757)]
|
[TLObject(150761757)]
|
||||||
public class TLRequestGetAccountTTL : TLMethod
|
public class TLRequestGetAccountTTL : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 150761757;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 150761757;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAccountDaysTTL Response{ get; set;}
|
public TLAccountDaysTTL Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLAccountDaysTTL)ObjectUtils.DeserializeObject(br);
|
Response = (TLAccountDaysTTL) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-484392616)]
|
[TLObject(-484392616)]
|
||||||
public class TLRequestGetAuthorizations : TLMethod
|
public class TLRequestGetAuthorizations : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -484392616;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -484392616;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Account.TLAuthorizations Response{ get; set;}
|
public TLAuthorizations Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Account.TLAuthorizations)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorizations) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(313765169)]
|
[TLObject(313765169)]
|
||||||
public class TLRequestGetNotifySettings : TLMethod
|
public class TLRequestGetNotifySettings : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 313765169;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 313765169;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAbsInputNotifyPeer peer {get;set;}
|
public TLAbsInputNotifyPeer peer { get; set; }
|
||||||
public TLAbsPeerNotifySettings Response{ get; set;}
|
public TLAbsPeerNotifySettings Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
peer = (TLAbsInputNotifyPeer)ObjectUtils.DeserializeObject(br);
|
peer = (TLAbsInputNotifyPeer) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(peer,bw);
|
ObjectUtils.SerializeObject(peer, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLAbsPeerNotifySettings)ObjectUtils.DeserializeObject(br);
|
Response = (TLAbsPeerNotifySettings) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1418342645)]
|
[TLObject(1418342645)]
|
||||||
public class TLRequestGetPassword : TLMethod
|
public class TLRequestGetPassword : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1418342645;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1418342645;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Account.TLAbsPassword Response{ get; set;}
|
public TLAbsPassword Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Account.TLAbsPassword)ObjectUtils.DeserializeObject(br);
|
Response = (TLAbsPassword) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-1131605573)]
|
[TLObject(-1131605573)]
|
||||||
public class TLRequestGetPasswordSettings : TLMethod
|
public class TLRequestGetPasswordSettings : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1131605573;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1131605573;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] current_password_hash {get;set;}
|
public byte[] current_password_hash { get; set; }
|
||||||
public Account.TLPasswordSettings Response{ get; set;}
|
public TLPasswordSettings Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
current_password_hash = BytesUtil.Deserialize(br);
|
current_password_hash = BytesUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BytesUtil.Serialize(current_password_hash,bw);
|
BytesUtil.Serialize(current_password_hash, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Account.TLPasswordSettings)ObjectUtils.DeserializeObject(br);
|
Response = (TLPasswordSettings) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-623130288)]
|
[TLObject(-623130288)]
|
||||||
public class TLRequestGetPrivacy : TLMethod
|
public class TLRequestGetPrivacy : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -623130288;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -623130288;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAbsInputPrivacyKey key {get;set;}
|
public TLAbsInputPrivacyKey key { get; set; }
|
||||||
public Account.TLPrivacyRules Response{ get; set;}
|
public TLPrivacyRules Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
key = (TLAbsInputPrivacyKey)ObjectUtils.DeserializeObject(br);
|
key = (TLAbsInputPrivacyKey) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(key,bw);
|
ObjectUtils.SerializeObject(key, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Account.TLPrivacyRules)ObjectUtils.DeserializeObject(br);
|
Response = (TLPrivacyRules) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-1068696894)]
|
[TLObject(-1068696894)]
|
||||||
public class TLRequestGetWallPapers : TLMethod
|
public class TLRequestGetWallPapers : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1068696894;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1068696894;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLVector<TLAbsWallPaper> Response{ get; set;}
|
public TLVector<TLAbsWallPaper> Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLVector<TLAbsWallPaper>)ObjectUtils.DeserializeVector<TLAbsWallPaper>(br);
|
Response = ObjectUtils.DeserializeVector<TLAbsWallPaper>(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1669245048)]
|
[TLObject(1669245048)]
|
||||||
public class TLRequestRegisterDevice : TLMethod
|
public class TLRequestRegisterDevice : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1669245048;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1669245048;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int token_type {get;set;}
|
public int token_type { get; set; }
|
||||||
public string token {get;set;}
|
public string token { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
token_type = br.ReadInt32();
|
token_type = br.ReadInt32();
|
||||||
token = StringUtil.Deserialize(br);
|
token = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(token_type);
|
bw.Write(token_type);
|
||||||
StringUtil.Serialize(token,bw);
|
StringUtil.Serialize(token, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-1374118561)]
|
[TLObject(-1374118561)]
|
||||||
public class TLRequestReportPeer : TLMethod
|
public class TLRequestReportPeer : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1374118561;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1374118561;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAbsInputPeer peer {get;set;}
|
public TLAbsInputPeer peer { get; set; }
|
||||||
public TLAbsReportReason reason {get;set;}
|
public TLAbsReportReason reason { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
peer = (TLAbsInputPeer)ObjectUtils.DeserializeObject(br);
|
peer = (TLAbsInputPeer) ObjectUtils.DeserializeObject(br);
|
||||||
reason = (TLAbsReportReason)ObjectUtils.DeserializeObject(br);
|
reason = (TLAbsReportReason) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(peer,bw);
|
ObjectUtils.SerializeObject(peer, bw);
|
||||||
ObjectUtils.SerializeObject(reason,bw);
|
ObjectUtils.SerializeObject(reason, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-545786948)]
|
[TLObject(-545786948)]
|
||||||
public class TLRequestResetAuthorization : TLMethod
|
public class TLRequestResetAuthorization : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -545786948;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -545786948;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long hash {get;set;}
|
public long hash { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
hash = br.ReadInt64();
|
hash = br.ReadInt64();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(hash);
|
bw.Write(hash);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-612493497)]
|
[TLObject(-612493497)]
|
||||||
public class TLRequestResetNotifySettings : TLMethod
|
public class TLRequestResetNotifySettings : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -612493497;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -612493497;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,66 +1,52 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using TeleSharp.TL.Auth;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(149257707)]
|
[TLObject(149257707)]
|
||||||
public class TLRequestSendChangePhoneCode : TLMethod
|
public class TLRequestSendChangePhoneCode : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 149257707;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 149257707;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public bool allow_flashcall {get;set;}
|
public bool allow_flashcall { get; set; }
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public bool? current_number {get;set;}
|
public bool? current_number { get; set; }
|
||||||
public Auth.TLSentCode Response{ get; set;}
|
public TLSentCode Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = allow_flashcall ? (flags | 1) : (flags & ~1);
|
flags = allow_flashcall ? flags | 1 : flags & ~1;
|
||||||
flags = current_number != null ? (flags | 1) : (flags & ~1);
|
flags = current_number != null ? flags | 1 : flags & ~1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
allow_flashcall = (flags & 1) != 0;
|
allow_flashcall = (flags & 1) != 0;
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
current_number = BoolUtil.Deserialize(br);
|
current_number = BoolUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
current_number = null;
|
current_number = null;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
|
|
||||||
StringUtil.Serialize(phone_number,bw);
|
|
||||||
if ((flags & 1) != 0)
|
|
||||||
BoolUtil.Serialize(current_number.Value,bw);
|
|
||||||
|
|
||||||
|
StringUtil.Serialize(phone_number, bw);
|
||||||
|
if ((flags & 1) != 0)
|
||||||
|
BoolUtil.Serialize(current_number.Value, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLSentCode)ObjectUtils.DeserializeObject(br);
|
Response = (TLSentCode) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,66 +1,52 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using TeleSharp.TL.Auth;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(353818557)]
|
[TLObject(353818557)]
|
||||||
public class TLRequestSendConfirmPhoneCode : TLMethod
|
public class TLRequestSendConfirmPhoneCode : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 353818557;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 353818557;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public bool allow_flashcall {get;set;}
|
public bool allow_flashcall { get; set; }
|
||||||
public string hash {get;set;}
|
public string hash { get; set; }
|
||||||
public bool? current_number {get;set;}
|
public bool? current_number { get; set; }
|
||||||
public Auth.TLSentCode Response{ get; set;}
|
public TLSentCode Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = allow_flashcall ? (flags | 1) : (flags & ~1);
|
flags = allow_flashcall ? flags | 1 : flags & ~1;
|
||||||
flags = current_number != null ? (flags | 1) : (flags & ~1);
|
flags = current_number != null ? flags | 1 : flags & ~1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
allow_flashcall = (flags & 1) != 0;
|
allow_flashcall = (flags & 1) != 0;
|
||||||
hash = StringUtil.Deserialize(br);
|
hash = StringUtil.Deserialize(br);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
current_number = BoolUtil.Deserialize(br);
|
current_number = BoolUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
current_number = null;
|
current_number = null;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
|
|
||||||
StringUtil.Serialize(hash,bw);
|
|
||||||
if ((flags & 1) != 0)
|
|
||||||
BoolUtil.Serialize(current_number.Value,bw);
|
|
||||||
|
|
||||||
|
StringUtil.Serialize(hash, bw);
|
||||||
|
if ((flags & 1) != 0)
|
||||||
|
BoolUtil.Serialize(current_number.Value, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLSentCode)ObjectUtils.DeserializeObject(br);
|
Response = (TLSentCode) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(608323678)]
|
[TLObject(608323678)]
|
||||||
public class TLRequestSetAccountTTL : TLMethod
|
public class TLRequestSetAccountTTL : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 608323678;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 608323678;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAccountDaysTTL ttl {get;set;}
|
public TLAccountDaysTTL ttl { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
ttl = (TLAccountDaysTTL)ObjectUtils.DeserializeObject(br);
|
ttl = (TLAccountDaysTTL) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(ttl,bw);
|
ObjectUtils.SerializeObject(ttl, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-906486552)]
|
[TLObject(-906486552)]
|
||||||
public class TLRequestSetPrivacy : TLMethod
|
public class TLRequestSetPrivacy : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -906486552;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -906486552;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAbsInputPrivacyKey key {get;set;}
|
public TLAbsInputPrivacyKey key { get; set; }
|
||||||
public TLVector<TLAbsInputPrivacyRule> rules {get;set;}
|
public TLVector<TLAbsInputPrivacyRule> rules { get; set; }
|
||||||
public Account.TLPrivacyRules Response{ get; set;}
|
public TLPrivacyRules Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
key = (TLAbsInputPrivacyKey)ObjectUtils.DeserializeObject(br);
|
key = (TLAbsInputPrivacyKey) ObjectUtils.DeserializeObject(br);
|
||||||
rules = (TLVector<TLAbsInputPrivacyRule>)ObjectUtils.DeserializeVector<TLAbsInputPrivacyRule>(br);
|
rules = ObjectUtils.DeserializeVector<TLAbsInputPrivacyRule>(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(key,bw);
|
ObjectUtils.SerializeObject(key, bw);
|
||||||
ObjectUtils.SerializeObject(rules,bw);
|
ObjectUtils.SerializeObject(rules, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Account.TLPrivacyRules)ObjectUtils.DeserializeObject(br);
|
Response = (TLPrivacyRules) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1707432768)]
|
[TLObject(1707432768)]
|
||||||
public class TLRequestUnregisterDevice : TLMethod
|
public class TLRequestUnregisterDevice : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1707432768;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1707432768;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int token_type {get;set;}
|
public int token_type { get; set; }
|
||||||
public string token {get;set;}
|
public string token { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
token_type = br.ReadInt32();
|
token_type = br.ReadInt32();
|
||||||
token = StringUtil.Deserialize(br);
|
token = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(token_type);
|
bw.Write(token_type);
|
||||||
StringUtil.Serialize(token,bw);
|
StringUtil.Serialize(token, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(954152242)]
|
[TLObject(954152242)]
|
||||||
public class TLRequestUpdateDeviceLocked : TLMethod
|
public class TLRequestUpdateDeviceLocked : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 954152242;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 954152242;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int period {get;set;}
|
public int period { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
period = br.ReadInt32();
|
period = br.ReadInt32();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(period);
|
bw.Write(period);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-2067899501)]
|
[TLObject(-2067899501)]
|
||||||
public class TLRequestUpdateNotifySettings : TLMethod
|
public class TLRequestUpdateNotifySettings : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -2067899501;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -2067899501;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLAbsInputNotifyPeer peer {get;set;}
|
public TLAbsInputNotifyPeer peer { get; set; }
|
||||||
public TLInputPeerNotifySettings settings {get;set;}
|
public TLInputPeerNotifySettings settings { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
peer = (TLAbsInputNotifyPeer)ObjectUtils.DeserializeObject(br);
|
peer = (TLAbsInputNotifyPeer) ObjectUtils.DeserializeObject(br);
|
||||||
settings = (TLInputPeerNotifySettings)ObjectUtils.DeserializeObject(br);
|
settings = (TLInputPeerNotifySettings) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(peer,bw);
|
ObjectUtils.SerializeObject(peer, bw);
|
||||||
ObjectUtils.SerializeObject(settings,bw);
|
ObjectUtils.SerializeObject(settings, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(-92517498)]
|
[TLObject(-92517498)]
|
||||||
public class TLRequestUpdatePasswordSettings : TLMethod
|
public class TLRequestUpdatePasswordSettings : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -92517498;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -92517498;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] current_password_hash {get;set;}
|
public byte[] current_password_hash { get; set; }
|
||||||
public Account.TLPasswordInputSettings new_settings {get;set;}
|
public TLPasswordInputSettings new_settings { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
current_password_hash = BytesUtil.Deserialize(br);
|
current_password_hash = BytesUtil.Deserialize(br);
|
||||||
new_settings = (Account.TLPasswordInputSettings)ObjectUtils.DeserializeObject(br);
|
new_settings = (TLPasswordInputSettings) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BytesUtil.Serialize(current_password_hash,bw);
|
BytesUtil.Serialize(current_password_hash, bw);
|
||||||
ObjectUtils.SerializeObject(new_settings,bw);
|
ObjectUtils.SerializeObject(new_settings, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,77 +1,62 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(2018596725)]
|
[TLObject(2018596725)]
|
||||||
public class TLRequestUpdateProfile : TLMethod
|
public class TLRequestUpdateProfile : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 2018596725;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 2018596725;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public string first_name {get;set;}
|
public string first_name { get; set; }
|
||||||
public string last_name {get;set;}
|
public string last_name { get; set; }
|
||||||
public string about {get;set;}
|
public string about { get; set; }
|
||||||
public TLAbsUser Response{ get; set;}
|
public TLAbsUser Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = first_name != null ? (flags | 1) : (flags & ~1);
|
flags = first_name != null ? flags | 1 : flags & ~1;
|
||||||
flags = last_name != null ? (flags | 2) : (flags & ~2);
|
flags = last_name != null ? flags | 2 : flags & ~2;
|
||||||
flags = about != null ? (flags | 4) : (flags & ~4);
|
flags = about != null ? flags | 4 : flags & ~4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
first_name = StringUtil.Deserialize(br);
|
first_name = StringUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
first_name = null;
|
first_name = null;
|
||||||
|
|
||||||
if ((flags & 2) != 0)
|
|
||||||
last_name = StringUtil.Deserialize(br);
|
|
||||||
else
|
|
||||||
last_name = null;
|
|
||||||
|
|
||||||
if ((flags & 4) != 0)
|
|
||||||
about = StringUtil.Deserialize(br);
|
|
||||||
else
|
|
||||||
about = null;
|
|
||||||
|
|
||||||
|
if ((flags & 2) != 0)
|
||||||
|
last_name = StringUtil.Deserialize(br);
|
||||||
|
else
|
||||||
|
last_name = null;
|
||||||
|
|
||||||
|
if ((flags & 4) != 0)
|
||||||
|
about = StringUtil.Deserialize(br);
|
||||||
|
else
|
||||||
|
about = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
StringUtil.Serialize(first_name,bw);
|
StringUtil.Serialize(first_name, bw);
|
||||||
if ((flags & 2) != 0)
|
if ((flags & 2) != 0)
|
||||||
StringUtil.Serialize(last_name,bw);
|
StringUtil.Serialize(last_name, bw);
|
||||||
if ((flags & 4) != 0)
|
if ((flags & 4) != 0)
|
||||||
StringUtil.Serialize(about,bw);
|
StringUtil.Serialize(about, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLAbsUser)ObjectUtils.DeserializeObject(br);
|
Response = (TLAbsUser) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1713919532)]
|
[TLObject(1713919532)]
|
||||||
public class TLRequestUpdateStatus : TLMethod
|
public class TLRequestUpdateStatus : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1713919532;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1713919532;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool offline {get;set;}
|
public bool offline { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
offline = BoolUtil.Deserialize(br);
|
offline = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BoolUtil.Serialize(offline,bw);
|
BoolUtil.Serialize(offline, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Account
|
namespace TeleSharp.TL.Account
|
||||||
{
|
{
|
||||||
[TLObject(1040964988)]
|
[TLObject(1040964988)]
|
||||||
public class TLRequestUpdateUsername : TLMethod
|
public class TLRequestUpdateUsername : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1040964988;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1040964988;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string username {get;set;}
|
public string username { get; set; }
|
||||||
public TLAbsUser Response{ get; set;}
|
public TLAbsUser Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
username = StringUtil.Deserialize(br);
|
username = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(username,bw);
|
StringUtil.Serialize(username, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (TLAbsUser)ObjectUtils.DeserializeObject(br);
|
Response = (TLAbsUser) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
public abstract class TLAbsCodeType : TLObject
|
public abstract class TLAbsCodeType : TLObject
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
public abstract class TLAbsSentCodeType : TLObject
|
public abstract class TLAbsSentCodeType : TLObject
|
||||||
|
|
|
||||||
|
|
@ -1,56 +1,42 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-855308010)]
|
[TLObject(-855308010)]
|
||||||
public class TLAuthorization : TLObject
|
public class TLAuthorization : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -855308010;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -855308010;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public int? tmp_sessions {get;set;}
|
public int? tmp_sessions { get; set; }
|
||||||
public TLAbsUser user {get;set;}
|
public TLAbsUser user { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = tmp_sessions != null ? (flags | 1) : (flags & ~1);
|
flags = tmp_sessions != null ? flags | 1 : flags & ~1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
tmp_sessions = br.ReadInt32();
|
tmp_sessions = br.ReadInt32();
|
||||||
else
|
else
|
||||||
tmp_sessions = null;
|
tmp_sessions = null;
|
||||||
|
|
||||||
user = (TLAbsUser)ObjectUtils.DeserializeObject(br);
|
|
||||||
|
|
||||||
|
user = (TLAbsUser) ObjectUtils.DeserializeObject(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
bw.Write(tmp_sessions.Value);
|
bw.Write(tmp_sessions.Value);
|
||||||
ObjectUtils.SerializeObject(user,bw);
|
ObjectUtils.SerializeObject(user, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-2128698738)]
|
[TLObject(-2128698738)]
|
||||||
public class TLCheckedPhone : TLObject
|
public class TLCheckedPhone : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -2128698738;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -2128698738;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool phone_registered {get;set;}
|
public bool phone_registered { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_registered = BoolUtil.Deserialize(br);
|
phone_registered = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BoolUtil.Serialize(phone_registered,bw);
|
BoolUtil.Serialize(phone_registered, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,39 +1,24 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1948046307)]
|
[TLObject(1948046307)]
|
||||||
public class TLCodeTypeCall : TLAbsCodeType
|
public class TLCodeTypeCall : TLAbsCodeType
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1948046307;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1948046307;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,39 +1,24 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(577556219)]
|
[TLObject(577556219)]
|
||||||
public class TLCodeTypeFlashCall : TLAbsCodeType
|
public class TLCodeTypeFlashCall : TLAbsCodeType
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 577556219;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 577556219;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,39 +1,24 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1923290508)]
|
[TLObject(1923290508)]
|
||||||
public class TLCodeTypeSms : TLAbsCodeType
|
public class TLCodeTypeSms : TLAbsCodeType
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1923290508;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1923290508;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-543777747)]
|
[TLObject(-543777747)]
|
||||||
public class TLExportedAuthorization : TLObject
|
public class TLExportedAuthorization : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -543777747;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -543777747;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int id {get;set;}
|
public int id { get; set; }
|
||||||
public byte[] bytes {get;set;}
|
public byte[] bytes { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
id = br.ReadInt32();
|
id = br.ReadInt32();
|
||||||
bytes = BytesUtil.Deserialize(br);
|
bytes = BytesUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(id);
|
bw.Write(id);
|
||||||
BytesUtil.Serialize(bytes,bw);
|
BytesUtil.Serialize(bytes, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(326715557)]
|
[TLObject(326715557)]
|
||||||
public class TLPasswordRecovery : TLObject
|
public class TLPasswordRecovery : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 326715557;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 326715557;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string email_pattern {get;set;}
|
public string email_pattern { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
email_pattern = StringUtil.Deserialize(br);
|
email_pattern = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(email_pattern,bw);
|
StringUtil.Serialize(email_pattern, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,57 +1,43 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-841733627)]
|
[TLObject(-841733627)]
|
||||||
public class TLRequestBindTempAuthKey : TLMethod
|
public class TLRequestBindTempAuthKey : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -841733627;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -841733627;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long perm_auth_key_id {get;set;}
|
public long perm_auth_key_id { get; set; }
|
||||||
public long nonce {get;set;}
|
public long nonce { get; set; }
|
||||||
public int expires_at {get;set;}
|
public int expires_at { get; set; }
|
||||||
public byte[] encrypted_message {get;set;}
|
public byte[] encrypted_message { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
perm_auth_key_id = br.ReadInt64();
|
perm_auth_key_id = br.ReadInt64();
|
||||||
nonce = br.ReadInt64();
|
nonce = br.ReadInt64();
|
||||||
expires_at = br.ReadInt32();
|
expires_at = br.ReadInt32();
|
||||||
encrypted_message = BytesUtil.Deserialize(br);
|
encrypted_message = BytesUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(perm_auth_key_id);
|
bw.Write(perm_auth_key_id);
|
||||||
bw.Write(nonce);
|
bw.Write(nonce);
|
||||||
bw.Write(expires_at);
|
bw.Write(expires_at);
|
||||||
BytesUtil.Serialize(encrypted_message,bw);
|
BytesUtil.Serialize(encrypted_message, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(520357240)]
|
[TLObject(520357240)]
|
||||||
public class TLRequestCancelCode : TLMethod
|
public class TLRequestCancelCode : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 520357240;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 520357240;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(174260510)]
|
[TLObject(174260510)]
|
||||||
public class TLRequestCheckPassword : TLMethod
|
public class TLRequestCheckPassword : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 174260510;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 174260510;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] password_hash {get;set;}
|
public byte[] password_hash { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
password_hash = BytesUtil.Deserialize(br);
|
password_hash = BytesUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
BytesUtil.Serialize(password_hash,bw);
|
BytesUtil.Serialize(password_hash, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1877286395)]
|
[TLObject(1877286395)]
|
||||||
public class TLRequestCheckPhone : TLMethod
|
public class TLRequestCheckPhone : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1877286395;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1877286395;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public Auth.TLCheckedPhone Response{ get; set;}
|
public TLCheckedPhone Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLCheckedPhone)ObjectUtils.DeserializeObject(br);
|
Response = (TLCheckedPhone) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-1907842680)]
|
[TLObject(-1907842680)]
|
||||||
public class TLRequestDropTempAuthKeys : TLMethod
|
public class TLRequestDropTempAuthKeys : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1907842680;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1907842680;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLVector<long> except_auth_keys {get;set;}
|
public TLVector<long> except_auth_keys { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
except_auth_keys = (TLVector<long>)ObjectUtils.DeserializeVector<long>(br);
|
except_auth_keys = ObjectUtils.DeserializeVector<long>(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(except_auth_keys,bw);
|
ObjectUtils.SerializeObject(except_auth_keys, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-440401971)]
|
[TLObject(-440401971)]
|
||||||
public class TLRequestExportAuthorization : TLMethod
|
public class TLRequestExportAuthorization : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -440401971;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -440401971;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int dc_id {get;set;}
|
public int dc_id { get; set; }
|
||||||
public Auth.TLExportedAuthorization Response{ get; set;}
|
public TLExportedAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
dc_id = br.ReadInt32();
|
dc_id = br.ReadInt32();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(dc_id);
|
bw.Write(dc_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLExportedAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLExportedAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-470837741)]
|
[TLObject(-470837741)]
|
||||||
public class TLRequestImportAuthorization : TLMethod
|
public class TLRequestImportAuthorization : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -470837741;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -470837741;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int id {get;set;}
|
public int id { get; set; }
|
||||||
public byte[] bytes {get;set;}
|
public byte[] bytes { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
id = br.ReadInt32();
|
id = br.ReadInt32();
|
||||||
bytes = BytesUtil.Deserialize(br);
|
bytes = BytesUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(id);
|
bw.Write(id);
|
||||||
BytesUtil.Serialize(bytes,bw);
|
BytesUtil.Serialize(bytes, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,59 +1,45 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1738800940)]
|
[TLObject(1738800940)]
|
||||||
public class TLRequestImportBotAuthorization : TLMethod
|
public class TLRequestImportBotAuthorization : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1738800940;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1738800940;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public int api_id {get;set;}
|
public int api_id { get; set; }
|
||||||
public string api_hash {get;set;}
|
public string api_hash { get; set; }
|
||||||
public string bot_auth_token {get;set;}
|
public string bot_auth_token { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
api_id = br.ReadInt32();
|
api_id = br.ReadInt32();
|
||||||
api_hash = StringUtil.Deserialize(br);
|
api_hash = StringUtil.Deserialize(br);
|
||||||
bot_auth_token = StringUtil.Deserialize(br);
|
bot_auth_token = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
bw.Write(api_id);
|
bw.Write(api_id);
|
||||||
StringUtil.Serialize(api_hash,bw);
|
StringUtil.Serialize(api_hash, bw);
|
||||||
StringUtil.Serialize(bot_auth_token,bw);
|
StringUtil.Serialize(bot_auth_token, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1461180992)]
|
[TLObject(1461180992)]
|
||||||
public class TLRequestLogOut : TLMethod
|
public class TLRequestLogOut : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1461180992;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1461180992;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,48 +1,34 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1319464594)]
|
[TLObject(1319464594)]
|
||||||
public class TLRequestRecoverPassword : TLMethod
|
public class TLRequestRecoverPassword : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1319464594;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1319464594;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string code {get;set;}
|
public string code { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
code = StringUtil.Deserialize(br);
|
code = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(code,bw);
|
StringUtil.Serialize(code, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-661144474)]
|
[TLObject(-661144474)]
|
||||||
public class TLRequestRequestPasswordRecovery : TLMethod
|
public class TLRequestRequestPasswordRecovery : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -661144474;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -661144474;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Auth.TLPasswordRecovery Response{ get; set;}
|
public TLPasswordRecovery Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLPasswordRecovery)ObjectUtils.DeserializeObject(br);
|
Response = (TLPasswordRecovery) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1056025023)]
|
[TLObject(1056025023)]
|
||||||
public class TLRequestResendCode : TLMethod
|
public class TLRequestResendCode : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1056025023;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1056025023;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public Auth.TLSentCode Response{ get; set;}
|
public TLSentCode Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLSentCode)ObjectUtils.DeserializeObject(br);
|
Response = (TLSentCode) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,31 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-1616179942)]
|
[TLObject(-1616179942)]
|
||||||
public class TLRequestResetAuthorizations : TLMethod
|
public class TLRequestResetAuthorizations : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1616179942;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1616179942;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,72 +1,58 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-2035355412)]
|
[TLObject(-2035355412)]
|
||||||
public class TLRequestSendCode : TLMethod
|
public class TLRequestSendCode : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -2035355412;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -2035355412;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public bool allow_flashcall {get;set;}
|
public bool allow_flashcall { get; set; }
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public bool? current_number {get;set;}
|
public bool? current_number { get; set; }
|
||||||
public int api_id {get;set;}
|
public int api_id { get; set; }
|
||||||
public string api_hash {get;set;}
|
public string api_hash { get; set; }
|
||||||
public Auth.TLSentCode Response{ get; set;}
|
public TLSentCode Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = allow_flashcall ? (flags | 1) : (flags & ~1);
|
flags = allow_flashcall ? flags | 1 : flags & ~1;
|
||||||
flags = current_number != null ? (flags | 1) : (flags & ~1);
|
flags = current_number != null ? flags | 1 : flags & ~1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
allow_flashcall = (flags & 1) != 0;
|
allow_flashcall = (flags & 1) != 0;
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
current_number = BoolUtil.Deserialize(br);
|
current_number = BoolUtil.Deserialize(br);
|
||||||
else
|
else
|
||||||
current_number = null;
|
current_number = null;
|
||||||
|
|
||||||
api_id = br.ReadInt32();
|
|
||||||
api_hash = StringUtil.Deserialize(br);
|
|
||||||
|
|
||||||
|
api_id = br.ReadInt32();
|
||||||
|
api_hash = StringUtil.Deserialize(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
|
|
||||||
StringUtil.Serialize(phone_number,bw);
|
|
||||||
if ((flags & 1) != 0)
|
|
||||||
BoolUtil.Serialize(current_number.Value,bw);
|
|
||||||
bw.Write(api_id);
|
|
||||||
StringUtil.Serialize(api_hash,bw);
|
|
||||||
|
|
||||||
|
StringUtil.Serialize(phone_number, bw);
|
||||||
|
if ((flags & 1) != 0)
|
||||||
|
BoolUtil.Serialize(current_number.Value, bw);
|
||||||
|
bw.Write(api_id);
|
||||||
|
StringUtil.Serialize(api_hash, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLSentCode)ObjectUtils.DeserializeObject(br);
|
Response = (TLSentCode) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1998331287)]
|
[TLObject(1998331287)]
|
||||||
public class TLRequestSendInvites : TLMethod
|
public class TLRequestSendInvites : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1998331287;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1998331287;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TLVector<string> phone_numbers {get;set;}
|
public TLVector<string> phone_numbers { get; set; }
|
||||||
public string message {get;set;}
|
public string message { get; set; }
|
||||||
public bool Response{ get; set;}
|
public bool Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_numbers = (TLVector<string>)ObjectUtils.DeserializeVector<string>(br);
|
phone_numbers = ObjectUtils.DeserializeVector<string>(br);
|
||||||
message = StringUtil.Deserialize(br);
|
message = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ObjectUtils.SerializeObject(phone_numbers,bw);
|
ObjectUtils.SerializeObject(phone_numbers, bw);
|
||||||
StringUtil.Serialize(message,bw);
|
StringUtil.Serialize(message, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = BoolUtil.Deserialize(br);
|
Response = BoolUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,54 +1,40 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(-1126886015)]
|
[TLObject(-1126886015)]
|
||||||
public class TLRequestSignIn : TLMethod
|
public class TLRequestSignIn : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => -1126886015;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return -1126886015;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public string phone_code {get;set;}
|
public string phone_code { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
phone_code = StringUtil.Deserialize(br);
|
phone_code = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
StringUtil.Serialize(phone_code,bw);
|
StringUtil.Serialize(phone_code, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,60 +1,46 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(453408308)]
|
[TLObject(453408308)]
|
||||||
public class TLRequestSignUp : TLMethod
|
public class TLRequestSignUp : TLMethod
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 453408308;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 453408308;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string phone_number {get;set;}
|
public string phone_number { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public string phone_code {get;set;}
|
public string phone_code { get; set; }
|
||||||
public string first_name {get;set;}
|
public string first_name { get; set; }
|
||||||
public string last_name {get;set;}
|
public string last_name { get; set; }
|
||||||
public Auth.TLAuthorization Response{ get; set;}
|
public TLAuthorization Response { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
phone_number = StringUtil.Deserialize(br);
|
phone_number = StringUtil.Deserialize(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
phone_code = StringUtil.Deserialize(br);
|
phone_code = StringUtil.Deserialize(br);
|
||||||
first_name = StringUtil.Deserialize(br);
|
first_name = StringUtil.Deserialize(br);
|
||||||
last_name = StringUtil.Deserialize(br);
|
last_name = StringUtil.Deserialize(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
StringUtil.Serialize(phone_number,bw);
|
StringUtil.Serialize(phone_number, bw);
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
StringUtil.Serialize(phone_code,bw);
|
StringUtil.Serialize(phone_code, bw);
|
||||||
StringUtil.Serialize(first_name,bw);
|
StringUtil.Serialize(first_name, bw);
|
||||||
StringUtil.Serialize(last_name,bw);
|
StringUtil.Serialize(last_name, bw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void deserializeResponse(BinaryReader br)
|
public override void deserializeResponse(BinaryReader br)
|
||||||
{
|
{
|
||||||
Response = (Auth.TLAuthorization)ObjectUtils.DeserializeObject(br);
|
Response = (TLAuthorization) ObjectUtils.DeserializeObject(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,72 +1,57 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1577067778)]
|
[TLObject(1577067778)]
|
||||||
public class TLSentCode : TLObject
|
public class TLSentCode : TLObject
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1577067778;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1577067778;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int flags {get;set;}
|
public int flags { get; set; }
|
||||||
public bool phone_registered {get;set;}
|
public bool phone_registered { get; set; }
|
||||||
public Auth.TLAbsSentCodeType type {get;set;}
|
public TLAbsSentCodeType type { get; set; }
|
||||||
public string phone_code_hash {get;set;}
|
public string phone_code_hash { get; set; }
|
||||||
public Auth.TLAbsCodeType next_type {get;set;}
|
public TLAbsCodeType next_type { get; set; }
|
||||||
public int? timeout {get;set;}
|
public int? timeout { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
flags = 0;
|
flags = 0;
|
||||||
flags = phone_registered ? (flags | 1) : (flags & ~1);
|
flags = phone_registered ? flags | 1 : flags & ~1;
|
||||||
flags = next_type != null ? (flags | 2) : (flags & ~2);
|
flags = next_type != null ? flags | 2 : flags & ~2;
|
||||||
flags = timeout != null ? (flags | 4) : (flags & ~4);
|
flags = timeout != null ? flags | 4 : flags & ~4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
flags = br.ReadInt32();
|
flags = br.ReadInt32();
|
||||||
phone_registered = (flags & 1) != 0;
|
phone_registered = (flags & 1) != 0;
|
||||||
type = (Auth.TLAbsSentCodeType)ObjectUtils.DeserializeObject(br);
|
type = (TLAbsSentCodeType) ObjectUtils.DeserializeObject(br);
|
||||||
phone_code_hash = StringUtil.Deserialize(br);
|
phone_code_hash = StringUtil.Deserialize(br);
|
||||||
if ((flags & 2) != 0)
|
if ((flags & 2) != 0)
|
||||||
next_type = (Auth.TLAbsCodeType)ObjectUtils.DeserializeObject(br);
|
next_type = (TLAbsCodeType) ObjectUtils.DeserializeObject(br);
|
||||||
else
|
else
|
||||||
next_type = null;
|
next_type = null;
|
||||||
|
|
||||||
if ((flags & 4) != 0)
|
|
||||||
timeout = br.ReadInt32();
|
|
||||||
else
|
|
||||||
timeout = null;
|
|
||||||
|
|
||||||
|
|
||||||
|
if ((flags & 4) != 0)
|
||||||
|
timeout = br.ReadInt32();
|
||||||
|
else
|
||||||
|
timeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
ComputeFlags();
|
ComputeFlags();
|
||||||
bw.Write(flags);
|
bw.Write(flags);
|
||||||
|
|
||||||
ObjectUtils.SerializeObject(type,bw);
|
|
||||||
StringUtil.Serialize(phone_code_hash,bw);
|
|
||||||
if ((flags & 2) != 0)
|
|
||||||
ObjectUtils.SerializeObject(next_type,bw);
|
|
||||||
if ((flags & 4) != 0)
|
|
||||||
bw.Write(timeout.Value);
|
|
||||||
|
|
||||||
|
ObjectUtils.SerializeObject(type, bw);
|
||||||
|
StringUtil.Serialize(phone_code_hash, bw);
|
||||||
|
if ((flags & 2) != 0)
|
||||||
|
ObjectUtils.SerializeObject(next_type, bw);
|
||||||
|
if ((flags & 4) != 0)
|
||||||
|
bw.Write(timeout.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL.Auth
|
namespace TeleSharp.TL.Auth
|
||||||
{
|
{
|
||||||
[TLObject(1035688326)]
|
[TLObject(1035688326)]
|
||||||
public class TLSentCodeTypeApp : TLAbsSentCodeType
|
public class TLSentCodeTypeApp : TLAbsSentCodeType
|
||||||
{
|
{
|
||||||
public override int Constructor
|
public override int Constructor => 1035688326;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 1035688326;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int length {get;set;}
|
public int length { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
public void ComputeFlags()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
public override void DeserializeBody(BinaryReader br)
|
||||||
{
|
{
|
||||||
length = br.ReadInt32();
|
length = br.ReadInt32();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
bw.Write(length);
|
bw.Write(length);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue