コード例 #1
0
 protected override void OnSucceded(TLPasswordSettings passwordSettings)
 {
     NavigateToPassportCommon(
         passwordSettings, PasswordBase, new TLString(Password),
         _authorizationForm, _secureValues,
         MTProtoService, StateService, NavigationService);
 }
コード例 #2
0
        private static void ResetSecureSecret(
            TLPasswordSettings passwordSettings, TLPassword passwordBase, TLString password,
            TLAuthorizationForm authorizationForm, IList <TLSecureValue> secureValues,
            IMTProtoService mtProtoService, IStateService stateService, INavigationService navigationService)
        {
            var passwordSettings83 = passwordSettings as TLPasswordSettings83;

            if (passwordSettings83 == null)
            {
                return;
            }

            var password84 = passwordBase as TLPassword84;

            if (password84 == null)
            {
                return;
            }

            var newSecureSettings = new TLSecureSecretSettings
            {
                SecureAlgo     = new TLSecurePasswordKdfAlgoUnknown(),
                SecureSecret   = TLString.Empty,
                SecureSecretId = new TLLong(0)
            };

            var newSettings = new TLPasswordInputSettings83
            {
                Flags             = new TLInt(0),
                NewSecureSettings = newSecureSettings,
            };

            mtProtoService.GetPasswordAsync(
                resul1 =>
            {
                var srpParams = resul1 as IPasswordSRPParams;
                if (srpParams == null)
                {
                    return;
                }

                var currentPasswordHash = passwordBase.CurrentPasswordHash ?? TLString.Empty;
                mtProtoService.UpdatePasswordSettingsAsync(SRP.GetCheck(currentPasswordHash, srpParams.SRPId, srpParams.SRPB, srpParams.CurrentAlgo), newSettings,
                                                           result2 =>
                {
                    passwordSettings83.SecureSettings = newSettings.NewSecureSettings;

                    NavigateToPassportCommon(
                        passwordSettings83, passwordBase, password,
                        authorizationForm, secureValues,
                        mtProtoService, stateService, navigationService);
                },
                                                           error2 => { });
            },
                error1 => { });
        }
コード例 #3
0
        public static void NavigateToPassportCommon(
            TLPasswordSettings passwordSettings, TLPassword passwordBase, TLString password,
            TLAuthorizationForm authorizationForm, IList <TLSecureValue> secureValues,
            IMTProtoService mtProtoService, IStateService stateService, INavigationService navigationService)
        {
            var passwordSettings83 = passwordSettings as TLPasswordSettings83;

            if (passwordSettings83 == null)
            {
                return;
            }

            var secureSettings = passwordSettings83.SecureSettings;

            passwordBase.Settings = passwordSettings83;

            var password84 = passwordBase as TLPassword84;

            if (password84 == null)
            {
                return;
            }

            var algo = password84.CurrentAlgo as TLPasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow;

            if (algo == null)
            {
                return;
            }

            //passwordBase.CurrentPasswordHash = Utils.Password.GetHash(passwordBase.CurrentSalt, password);
            var passwordHash = SRP.GetX(password, algo);

            passwordBase.CurrentPasswordHash = passwordHash;

            // create secure_secret
            if (secureSettings == null || TLString.IsNullOrEmpty(secureSettings.SecureSecret))
            {
                AddSecureSecret(passwordSettings, passwordBase, password, authorizationForm, secureValues, mtProtoService, stateService, navigationService);
                return;
            }

            var values = authorizationForm != null ? authorizationForm.Values : secureValues;

            if (values == null)
            {
                return;
            }

            var decrypted = SetSecretAndDecryptSecureValues(passwordSettings83, password, values);

            if (!decrypted)
            {
                Execute.BeginOnUIThread(() =>
                {
                    ShellViewModel.ShowCustomMessageBox(
                        AppResources.PassportDataCorrupted, AppResources.AppName,
                        AppResources.Reset, AppResources.Cancel,
                        dismissed =>
                    {
                        if (dismissed == CustomMessageBoxResult.RightButton)
                        {
                            ResetSecureSecret(passwordSettings, passwordBase, password, authorizationForm, secureValues, mtProtoService, stateService, navigationService);
                            values.Clear();
                        }
                    });
                });

                return;
            }

            stateService.RemoveBackEntry   = true;
            stateService.AuthorizationForm = authorizationForm;
            stateService.SecureValues      = secureValues;
            stateService.Password          = passwordBase;
            Execute.BeginOnUIThread(() =>
            {
                if (authorizationForm != null)
                {
                    navigationService.UriFor <PassportViewModel>().Navigate();
                }
                else if (secureValues != null)
                {
                    navigationService.UriFor <PassportSettingsViewModel>().Navigate();
                }
            });
        }
コード例 #4
0
 protected virtual void OnSucceded(TLPasswordSettings passwordSettings)
 {
 }
コード例 #5
0
 protected override void OnSucceded(TLPasswordSettings passwordSettings)
 {
     StateService.RemoveBackEntry = true;
     StateService.Password        = PasswordBase;
     NavigationService.UriFor <PasswordViewModel>().Navigate();
 }