예제 #1
0
        private static byte[] ComposeSignUpRequest(string phone, TLString phoneCodeHash, TLString phoneCode, TLString firstName, TLString lastName)
        {
            TLUtils.WriteLine("--Compose SignUp request--");
            //#1b067634x
            var signature = new byte[] { 0x34, 0x76, 0x06, 0x1b };

            var phoneNumberBytes = Encoding.UTF8.GetBytes(phone);
            var phoneNumberStr   = TLString.FromBigEndianData(phoneNumberBytes.ToArray());

            TLUtils.WriteLine("Phone: " + BitConverter.ToString(phoneNumberBytes));
            TLUtils.WriteLine("Phone serialized: " + BitConverter.ToString(phoneNumberStr.ToBytes()));

            TLUtils.WriteLine("PhoneCodeHash: " + phoneCodeHash.ToString());
            TLUtils.WriteLine("PhoneCodeHash serialized: " + BitConverter.ToString(phoneCodeHash.ToBytes()));

            TLUtils.WriteLine("PhoneCode: " + phoneCode.ToString());
            TLUtils.WriteLine("PhoneCode serialized: " + BitConverter.ToString(phoneCode.ToBytes()));

            TLUtils.WriteLine("FirstName: " + firstName.ToString());
            TLUtils.WriteLine("FirstName serialized: " + BitConverter.ToString(firstName.ToBytes()));

            TLUtils.WriteLine("LastName: " + lastName.ToString());
            TLUtils.WriteLine("LastName serialized: " + BitConverter.ToString(lastName.ToBytes()));

            return(signature
                   .Concat(phoneNumberStr.ToBytes())
                   .Concat(phoneCodeHash.ToBytes())
                   .Concat(phoneCode.ToBytes())
                   .Concat(firstName.ToBytes())
                   .Concat(lastName.ToBytes())
                   .ToArray());
        }
        private static byte[] ComposeGetContactsRequest(TLString hash)
        {
            //#22c6aa08
            var signature = new byte[] { 0x08, 0xaa, 0xc6, 0x22 };

            TLUtils.WriteLine("Hash: " + hash.ToString());
            TLUtils.WriteLine("Hash: " + BitConverter.ToString(hash.ToBytes()));

            return(signature
                   .Concat(hash.ToBytes())
                   .ToArray());
        }
예제 #3
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                ChatId.ToBytes(),
                Title.ToBytes()));
 }
예제 #4
0
        private static byte[] ComposeSendCallRequest(TLString phone, TLString phoneCodeHash)
        {
            TLUtils.WriteLine("--Compose SendCallAsync request--");

            var signature = new byte[] { 0x64, 0x15, 0xc5, 0x03 };

            TLUtils.WriteLine("Phone: " + phone);
            TLUtils.WriteLine("Phone serialized: " + BitConverter.ToString(phone.ToBytes()));

            TLUtils.WriteLine("PhoneCodeHash: " + phoneCodeHash.ToString());
            TLUtils.WriteLine("PhoneCodeHash serialized: " + BitConverter.ToString(phoneCodeHash.ToBytes()));

            return(signature
                   .Concat(phone.ToBytes())
                   .Concat(phoneCodeHash.ToBytes())
                   .ToArray());
        }
예제 #5
0
        private static byte[] ComposeSendCodeRequest(TLString phone, TLSmsType type, int apiId, TLString apiHash)
        {
            TLUtils.WriteLine("--Compose TLSendCode request--");

            var signature = new byte[] { 0x72, 0xf3, 0x6f, 0xd1 };

            TLUtils.WriteLine("Phone: " + phone.ToString());
            TLUtils.WriteLine("Phone serialized: " + BitConverter.ToString(phone.ToBytes()));

            TLUtils.WriteLine("ApiHash: " + apiHash.ToString());
            TLUtils.WriteLine("ApiHash serialized: " + BitConverter.ToString(apiHash.ToBytes()));

            return(signature
                   .Concat(phone.ToBytes())
                   .Concat(BitConverter.GetBytes((int)type))
                   .Concat(BitConverter.GetBytes(apiId))
                   .Concat(apiHash.ToBytes())
                   .ToArray());
        }
예제 #6
0
        private static byte[] ComposeSignInRequest(TLString phone, TLString phoneCodeHash, TLString phoneCode)
        {
            TLUtils.WriteLine("--Compose SignInAsync request--");
            //#bcd51581
            var signature = new byte[] { 0x81, 0x15, 0xd5, 0xbc };

            TLUtils.WriteLine("Phone: " + phone.ToString());
            TLUtils.WriteLine("Phone serialized: " + BitConverter.ToString(phone.ToBytes()));

            TLUtils.WriteLine("PhoneCodeHash: " + phoneCodeHash.ToString());
            TLUtils.WriteLine("PhoneCodeHash serialized: " + BitConverter.ToString(phoneCodeHash.ToBytes()));

            TLUtils.WriteLine("PhoneCode: " + phoneCode.ToString());
            TLUtils.WriteLine("PhoneCode serialized: " + BitConverter.ToString(phoneCode.ToBytes()));

            return(signature
                   .Concat(phone.ToBytes())
                   .Concat(phoneCodeHash.ToBytes())
                   .Concat(phoneCode.ToBytes())
                   .ToArray());
        }
예제 #7
0
        private static byte[] ComposeSendMessageRequest(TLInputPeerBase peerBase, TLString message, TLLong randomId)
        {
            //#4cde0aab
            var signature = new byte[] { 0xab, 0x0a, 0xde, 0x4c };

            TLUtils.WriteLine("Peer: " + peerBase);
            TLUtils.WriteLine("Message: " + message);
            TLUtils.WriteLine("RandomId: " + randomId);

            return(signature
                   .Concat(peerBase.ToBytes())
                   .Concat(message.ToBytes())
                   .Concat(randomId.ToBytes())
                   .ToArray());
        }
예제 #8
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Username.ToBytes()));
 }
예제 #9
0
        private void ProcessAcceptedCall(TLPhoneCallAccepted phoneCallAccepted)
        {
            DispatchStateChanged(PhoneCallState.STATE_EXCHANGING_KEYS);

            if (!TLUtils.CheckGaAndGb(phoneCallAccepted.GB.Data, _secretP.Data))
            {
                CallFailed();
                return;
            }


            _authKey = MTProtoService.GetAuthKey(_aOrB, phoneCallAccepted.GB.ToBytes(), _secretP.ToBytes());
            var keyHash        = Utils.ComputeSHA1(_authKey);
            var keyFingerprint = new TLLong(BitConverter.ToInt64(keyHash, 12));

            var peer = new TLInputPhoneCall
            {
                Id         = phoneCallAccepted.Id,
                AccessHash = phoneCallAccepted.AccessHash
            };

            var protocol = new TLPhoneCallProtocol
            {
                Flags        = new TLInt(0),
                UdpP2P       = true,
                UdpReflector = true,
                MinLayer     = new TLInt(CALL_MIN_LAYER),
                MaxLayer     = new TLInt(CALL_MAX_LAYER)
            };

            _mtProtoService.ConfirmCallAsync(peer, TLString.FromBigEndianData(_ga), keyFingerprint, protocol,
                                             result =>
            {
                _call = result;
                InitiateActualEncryptedCall();
            },
                                             error =>
            {
                CallFailed();
            });
        }