Skip to content

Commit

Permalink
don't clear key needed for bio/auto migration in pin migration (#2721)
Browse files Browse the repository at this point in the history
(cherry picked from commit 819aabb)
  • Loading branch information
jlf0dev authored and trmartin4 committed Aug 25, 2023
1 parent f489947 commit 8c58ed5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Core/Services/CryptoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,10 @@ private async Task MigrateAutoAndBioKeysIfNeededAsync(string userId = null)
// Decrypt
var masterKey = new MasterKey(Convert.FromBase64String(oldKey));
var encryptedUserKey = await _stateService.GetEncKeyEncryptedAsync(userId);
if (encryptedUserKey == null)
{
return;
}
var userKey = await DecryptUserKeyWithMasterKeyAsync(
masterKey,
new EncString(encryptedUserKey),
Expand Down Expand Up @@ -1070,8 +1074,11 @@ private async Task MigrateAutoAndBioKeysIfNeededAsync(string userId = null)
var encPin = await EncryptAsync(pin, userKey);
await _stateService.SetProtectedPinAsync(encPin.EncryptedString);
}
// Clear old key
await _stateService.SetEncKeyEncryptedAsync(null);
// Clear old key only if not needed for bio/auto migration
if (await _stateService.GetKeyEncryptedAsync() != null)
{
await _stateService.SetEncKeyEncryptedAsync(null);
}
return userKey;
}

Expand Down

0 comments on commit 8c58ed5

Please sign in to comment.