From d1646e5aca42ae59562b96652f8468ef7a97bd22 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 31 May 2019 23:46:22 -0400 Subject: [PATCH] support old key on password unlock --- src/App/Pages/Accounts/LockPageViewModel.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/App/Pages/Accounts/LockPageViewModel.cs b/src/App/Pages/Accounts/LockPageViewModel.cs index beecf3e81..f54ae9631 100644 --- a/src/App/Pages/Accounts/LockPageViewModel.cs +++ b/src/App/Pages/Accounts/LockPageViewModel.cs @@ -21,6 +21,7 @@ namespace Bit.App.Pages private readonly IStorageService _storageService; private readonly IUserService _userService; private readonly IMessagingService _messagingService; + private readonly IStorageService _secureStorageService; private bool _hasKey; private string _email; @@ -42,6 +43,7 @@ namespace Bit.App.Pages _storageService = ServiceContainer.Resolve("storageService"); _userService = ServiceContainer.Resolve("userService"); _messagingService = ServiceContainer.Resolve("messagingService"); + _secureStorageService = ServiceContainer.Resolve("secureStorageService"); PageTitle = AppResources.VerifyMasterPassword; TogglePasswordCommand = new Command(TogglePassword); @@ -194,6 +196,16 @@ namespace Bit.App.Pages var key = await _cryptoService.MakeKeyAsync(MasterPassword, _email, kdf, kdfIterations); var keyHash = await _cryptoService.HashPasswordAsync(MasterPassword, key); var storedKeyHash = await _cryptoService.GetKeyHashAsync(); + if(storedKeyHash == null) + { + var oldKey = await _secureStorageService.GetAsync("oldKey"); + if(key.KeyB64 == oldKey) + { + await _secureStorageService.RemoveAsync("oldKey"); + await _cryptoService.SetKeyHashAsync(keyHash); + storedKeyHash = keyHash; + } + } if(storedKeyHash != null && keyHash != null && storedKeyHash == keyHash) { MasterPassword = string.Empty;