This commit is contained in:
fosse 2023-12-15 13:29:58 -05:00
parent e699cb0335
commit 2cf4d51ccb
2 changed files with 7 additions and 7 deletions

View file

@ -503,8 +503,10 @@ class BackupService {
Future<Uint8List> _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;

View file

@ -391,9 +391,7 @@ Future<void> 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: