Exemplo n.º 1
0
        private async Task <Step3Response> DoAuthentication()
        {
            Log.Info("Try do authentication");

            var step1       = new Step1PqRequest();
            var step1Result = await MtProtoPlainSender.SendAndReceive(step1.ToBytes());

            var step1Response = step1.FromBytes(step1Result);

            Log.Debug("First step is done");

            var step2       = new Step2DhExchange();
            var step2Result = await MtProtoPlainSender.SendAndReceive(step2.ToBytes(
                                                                          step1Response.Nonce,
                                                                          step1Response.ServerNonce,
                                                                          step1Response.Fingerprints,
                                                                          step1Response.Pq));

            var step2Response = step2.FromBytes(step2Result);

            Log.Debug("Second step is done");

            var step3       = new Step3CompleteDhExchange();
            var step3Result = await MtProtoPlainSender.SendAndReceive(step3.ToBytes(
                                                                          step2Response.Nonce,
                                                                          step2Response.ServerNonce,
                                                                          step2Response.NewNonce,
                                                                          step2Response.EncryptedAnswer));

            var step3Response = step3.FromBytes(step3Result);

            Log.Debug("Third step is done");

            return(step3Response);
        }
Exemplo n.º 2
0
        public void ValidateTest()
        {
            var paramsOk = new TServerDHParamsOk
            {
                EncryptedAnswerAsBinary = _encryptedData,
                Nonce       = _nonce,
                ServerNonce = _serverNonce
            };

            var packageBuffer = Serializer.Serialize(paramsOk);
            var packageData   = packageBuffer.ToArray();

            var completeDhExchange = new Step3CompleteDhExchange();
            var oldResponse        = completeDhExchange.ToBytes(_nonce, _serverNonce, _newNonce, _encryptedData);


            var response = Step3ClientHelper.GetRequest(paramsOk, _newNonce, out var clientAgree, out var serviceTime);
        }