diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 7b4e862e8..17c68a639 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -503,8 +503,10 @@ class BackupService { Future _exportKeychainDumpV2(String password, {String keychainSalt = secrets.backupKeychainSalt}) async { final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword); - final encodedPin = await _flutterSecureStorage.read(key: key); - final decodedPin = decodedPinCode(pin: encodedPin!); + String pin = (await _flutterSecureStorage.read(key: key))!; + if (!pin.contains("argon2")) { + pin = decodedPinCode(pin: pin); + } final wallets = await Future.wait(_walletInfoSource.values.map((walletInfo) async { return { 'name': walletInfo.name, @@ -514,8 +516,8 @@ class BackupService { })); final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword); final backupPassword = await _flutterSecureStorage.read(key: backupPasswordKey); - final data = utf8.encode( - json.encode({'pin': decodedPin, 'wallets': wallets, backupPasswordKey: backupPassword})); + final data = utf8 + .encode(json.encode({'pin': pin, 'wallets': wallets, backupPasswordKey: backupPassword})); final encrypted = await _encryptV2(Uint8List.fromList(data), '$keychainSalt$password'); return encrypted; diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 8a916d7cc..0314031ee 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -391,9 +391,7 @@ Future pinEncryptionMigration({required FlutterSecureStorage secureStorage // we don't have a pin?!? if (encodedPin == null) { print("pinEncryptionMigration: no pin found in secure storage!"); - // this should never happen, but just in case let's just set the pin to "0000" - // as it's better than permanently locking the user out with an un-decryptable pin - encodedPin = encodedPinCode(pin: "0000"); + return; } // decode & re-encode the pin: