mirror of
https://github.com/bitwarden/mobile
synced 2025-12-10 05:13:31 +00:00
renaming bio key and fix build
This commit is contained in:
@@ -462,7 +462,7 @@ namespace Bit.App.Pages
|
|||||||
await _stateService.SetBiometricLockedAsync(!success);
|
await _stateService.SetBiometricLockedAsync(!success);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
var userKey = await _stateService.GetUserKeyBiometricUnlockAsync();
|
var userKey = await _cryptoService.GetBiometricUnlockKeyAsync();
|
||||||
await SetUserKeyAndContinueAsync(userKey);
|
await SetUserKeyAndContinueAsync(userKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace Bit.Core.Abstractions
|
|||||||
Task SetMasterKeyEncryptedUserKeyAsync(string value, string userId = null);
|
Task SetMasterKeyEncryptedUserKeyAsync(string value, string userId = null);
|
||||||
Task<UserKey> GetAutoUnlockKeyAsync(string userId = null);
|
Task<UserKey> GetAutoUnlockKeyAsync(string userId = null);
|
||||||
Task<bool> HasAutoUnlockKeyAsync(string userId = null);
|
Task<bool> HasAutoUnlockKeyAsync(string userId = null);
|
||||||
|
Task<UserKey> GetBiometricUnlockKeyAsync(string userId = null);
|
||||||
Task SetMasterKeyAsync(MasterKey masterKey, string userId = null);
|
Task SetMasterKeyAsync(MasterKey masterKey, string userId = null);
|
||||||
Task<MasterKey> GetMasterKeyAsync(string userId = null);
|
Task<MasterKey> GetMasterKeyAsync(string userId = null);
|
||||||
Task<MasterKey> MakeMasterKeyAsync(string password, string email, KdfConfig kdfConfig);
|
Task<MasterKey> MakeMasterKeyAsync(string password, string email, KdfConfig kdfConfig);
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ namespace Bit.Core.Services
|
|||||||
II18nService i18nService,
|
II18nService i18nService,
|
||||||
IPlatformUtilsService platformUtilsService,
|
IPlatformUtilsService platformUtilsService,
|
||||||
IMessagingService messagingService,
|
IMessagingService messagingService,
|
||||||
IKeyConnectorService keyConnectorService,
|
|
||||||
IPasswordGenerationService passwordGenerationService,
|
IPasswordGenerationService passwordGenerationService,
|
||||||
IPolicyService policyService,
|
IPolicyService policyService,
|
||||||
bool setCryptoKeys = true)
|
bool setCryptoKeys = true)
|
||||||
@@ -60,7 +59,6 @@ namespace Bit.Core.Services
|
|||||||
_i18nService = i18nService;
|
_i18nService = i18nService;
|
||||||
_platformUtilsService = platformUtilsService;
|
_platformUtilsService = platformUtilsService;
|
||||||
_messagingService = messagingService;
|
_messagingService = messagingService;
|
||||||
_keyConnectorService = keyConnectorService;
|
|
||||||
_passwordGenerationService = passwordGenerationService;
|
_passwordGenerationService = passwordGenerationService;
|
||||||
_policyService = policyService;
|
_policyService = policyService;
|
||||||
_setCryptoKeys = setCryptoKeys;
|
_setCryptoKeys = setCryptoKeys;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
public async Task<UserKey> GetAutoUnlockKeyAsync(string userId = null)
|
public async Task<UserKey> GetAutoUnlockKeyAsync(string userId = null)
|
||||||
{
|
{
|
||||||
await MigrateAutoUnlockKeyIfNeededAsync(userId);
|
await MigrateAutoAndBioKeysIfNeededAsync(userId);
|
||||||
return await _stateService.GetUserKeyAutoUnlockAsync(userId);
|
return await _stateService.GetUserKeyAutoUnlockAsync(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +110,12 @@ namespace Bit.Core.Services
|
|||||||
return await GetAutoUnlockKeyAsync(userId) != null;
|
return await GetAutoUnlockKeyAsync(userId) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<UserKey> GetBiometricUnlockKeyAsync(string userId = null)
|
||||||
|
{
|
||||||
|
await MigrateAutoAndBioKeysIfNeededAsync(userId);
|
||||||
|
return await _stateService.GetUserKeyBiometricUnlockAsync(userId);
|
||||||
|
}
|
||||||
|
|
||||||
public Task SetMasterKeyAsync(MasterKey masterKey, string userId = null)
|
public Task SetMasterKeyAsync(MasterKey masterKey, string userId = null)
|
||||||
{
|
{
|
||||||
return _stateService.SetMasterKeyAsync(masterKey, userId);
|
return _stateService.SetMasterKeyAsync(masterKey, userId);
|
||||||
@@ -982,23 +988,33 @@ namespace Bit.Core.Services
|
|||||||
// We previously used the master key for additional keys, but now we use the user key.
|
// We previously used the master key for additional keys, but now we use the user key.
|
||||||
// These methods support migrating the old keys to the new ones.
|
// These methods support migrating the old keys to the new ones.
|
||||||
|
|
||||||
private async Task MigrateAutoUnlockKeyIfNeededAsync(string userId = null)
|
private async Task MigrateAutoAndBioKeysIfNeededAsync(string userId = null)
|
||||||
{
|
{
|
||||||
var oldAutoKey = await _stateService.GetKeyEncryptedAsync(userId);
|
var oldKey = await _stateService.GetKeyEncryptedAsync(userId);
|
||||||
if (oldAutoKey == null)
|
if (oldKey == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt
|
// Decrypt
|
||||||
var masterKey = new MasterKey(Convert.FromBase64String(oldAutoKey));
|
var masterKey = new MasterKey(Convert.FromBase64String(oldKey));
|
||||||
var encryptedUserKey = await _stateService.GetEncKeyEncryptedAsync(userId);
|
var encryptedUserKey = await _stateService.GetEncKeyEncryptedAsync(userId);
|
||||||
var userKey = await DecryptUserKeyWithMasterKeyAsync(
|
var userKey = await DecryptUserKeyWithMasterKeyAsync(
|
||||||
masterKey,
|
masterKey,
|
||||||
new EncString(encryptedUserKey),
|
new EncString(encryptedUserKey),
|
||||||
userId);
|
userId);
|
||||||
|
|
||||||
// Migrate
|
// Migrate
|
||||||
await _stateService.SetUserKeyAutoUnlockAsync(userKey, userId);
|
if (await _stateService.GetVaultTimeoutAsync(userId) == null)
|
||||||
|
{
|
||||||
|
await _stateService.SetUserKeyAutoUnlockAsync(userKey, userId);
|
||||||
|
}
|
||||||
|
if ((await _stateService.GetBiometricUnlockAsync(userId)).GetValueOrDefault())
|
||||||
|
{
|
||||||
|
await _stateService.SetUserKeyBiometricUnlockAsync(userKey, userId);
|
||||||
|
}
|
||||||
await _stateService.SetKeyEncryptedAsync(null, userId);
|
await _stateService.SetKeyEncryptedAsync(null, userId);
|
||||||
|
|
||||||
// Set encrypted user key just in case the user locks without syncing
|
// Set encrypted user key just in case the user locks without syncing
|
||||||
await SetMasterKeyEncryptedUserKeyAsync(encryptedUserKey);
|
await SetMasterKeyEncryptedUserKeyAsync(encryptedUserKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace Bit.Core.Services
|
|||||||
public async Task SetUserKeyBiometricUnlockAsync(UserKey value, string userId = null)
|
public async Task SetUserKeyBiometricUnlockAsync(UserKey value, string userId = null)
|
||||||
{
|
{
|
||||||
await _storageMediatorService.SaveAsync(
|
await _storageMediatorService.SaveAsync(
|
||||||
await ComposeKeyAsync(Constants.UserKeyBiometricUnlockKey, userId), value, true);
|
await ComposeKeyAsync(Constants.UserKeyBiometricUnlockKey, userId), value?.KeyB64, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool?> GetBiometricUnlockAsync(string userId = null)
|
public async Task<bool?> GetBiometricUnlockAsync(string userId = null)
|
||||||
@@ -369,7 +369,7 @@ namespace Bit.Core.Services
|
|||||||
public async Task SetUserKeyAutoUnlockAsync(UserKey value, string userId = null)
|
public async Task SetUserKeyAutoUnlockAsync(UserKey value, string userId = null)
|
||||||
{
|
{
|
||||||
await _storageMediatorService.SaveAsync(
|
await _storageMediatorService.SaveAsync(
|
||||||
await ComposeKeyAsync(Constants.UserKeyAutoUnlockKey, userId), value.KeyB64, true);
|
await ComposeKeyAsync(Constants.UserKeyAutoUnlockKey, userId), value?.KeyB64, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> CanAccessPremiumAsync(string userId = null)
|
public async Task<bool> CanAccessPremiumAsync(string userId = null)
|
||||||
@@ -1478,6 +1478,7 @@ namespace Bit.Core.Services
|
|||||||
// Non-state storage
|
// Non-state storage
|
||||||
await Task.WhenAll(
|
await Task.WhenAll(
|
||||||
SetUserKeyAutoUnlockAsync(null, userId),
|
SetUserKeyAutoUnlockAsync(null, userId),
|
||||||
|
SetUserKeyBiometricUnlockAsync(null, userId),
|
||||||
SetProtectedPinAsync(null, userId),
|
SetProtectedPinAsync(null, userId),
|
||||||
SetKeyHashAsync(null, userId),
|
SetKeyHashAsync(null, userId),
|
||||||
SetOrgKeysEncryptedAsync(null, userId),
|
SetOrgKeysEncryptedAsync(null, userId),
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace Bit.Core.Utilities
|
|||||||
var totpService = new TotpService(cryptoFunctionService);
|
var totpService = new TotpService(cryptoFunctionService);
|
||||||
var authService = new AuthService(cryptoService, cryptoFunctionService, apiService, stateService,
|
var authService = new AuthService(cryptoService, cryptoFunctionService, apiService, stateService,
|
||||||
tokenService, appIdService, i18nService, platformUtilsService, messagingService,
|
tokenService, appIdService, i18nService, platformUtilsService, messagingService,
|
||||||
keyConnectorService, passwordGenerationService, policyService);
|
passwordGenerationService, policyService);
|
||||||
var exportService = new ExportService(folderService, cipherService, cryptoService);
|
var exportService = new ExportService(folderService, cipherService, cryptoService);
|
||||||
var auditService = new AuditService(cryptoFunctionService, apiService);
|
var auditService = new AuditService(cryptoFunctionService, apiService);
|
||||||
var environmentService = new EnvironmentService(apiService, stateService, conditionedRunner);
|
var environmentService = new EnvironmentService(apiService, stateService, conditionedRunner);
|
||||||
|
|||||||
Reference in New Issue
Block a user