diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 20aeb4a19..51a6cfb8c 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -6434,6 +6434,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Unlocking may fail due to insufficient memory. Decrease your KDF memory settings to resolve. + /// + public static string UnlockingMayFailDueToInsufficientMemoryDecreaseYourKDFMemorySettingsToResolve { + get { + return ResourceManager.GetString("UnlockingMayFailDueToInsufficientMemoryDecreaseYourKDFMemorySettingsToResolve", resourceCulture); + } + } + /// /// Looks up a localized string similar to Unlock vault. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index a137e2384..f4bae0727 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -2634,4 +2634,7 @@ Do you want to switch to this account? Master password re-prompt help + + Unlocking may fail due to insufficient memory. Decrease your KDF memory settings to resolve + diff --git a/src/iOS.Core/Constants.cs b/src/iOS.Core/Constants.cs index 402988dd7..1c9896ec1 100644 --- a/src/iOS.Core/Constants.cs +++ b/src/iOS.Core/Constants.cs @@ -32,5 +32,6 @@ public const string UTTypeAppExtensionImage = "public.image"; public const string AutofillNeedsIdentityReplacementKey = "autofillNeedsIdentityReplacement"; + public const int MaximumArgon2IdMemoryBeforeExtensionCrashing = 48; } } diff --git a/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs b/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs index 855581b4b..db0a946c2 100644 --- a/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs +++ b/src/iOS.Core/Controllers/BaseLockPasswordViewController.cs @@ -225,6 +225,18 @@ namespace Bit.iOS.Core.Controllers var kdfConfig = await _stateService.GetActiveUserCustomDataAsync(a => new KdfConfig(a?.Profile)); var inputtedValue = MasterPasswordCell.TextField.Text; + // HACK: iOS extensions have constrained memory, given how it works Argon2Id, it's likely to crash + // the extension depending on the argon2id memory configured. + // So, we warn the user and advise to decrease the configured memory letting them the option to continue, if wanted. + if (kdfConfig.Type == KdfType.Argon2id + && + kdfConfig.Memory > Constants.MaximumArgon2IdMemoryBeforeExtensionCrashing + && + !await _platformUtilsService.ShowDialogAsync(AppResources.UnlockingMayFailDueToInsufficientMemoryDecreaseYourKDFMemorySettingsToResolve, AppResources.Warning, AppResources.Continue, AppResources.Cancel)) + { + return; + } + if (_pinLock) { var failed = true;