mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 20:30:36 +00:00
Always try to decrypt the password slot first, before the fallback
This makes sure the case where a user set up Aegis v0.4 with a password of over 64 bytes is also covered.
This commit is contained in:
parent
8c658ac930
commit
ff584a323d
1 changed files with 10 additions and 6 deletions
|
@ -61,19 +61,23 @@ public class SlotListTask<T extends Slot> extends ProgressDialogTask<SlotListTas
|
|||
throws SlotIntegrityException, SlotException {
|
||||
MasterKey masterKey;
|
||||
SecretKey key = slot.deriveKey(password);
|
||||
|
||||
// a bug introduced in afb9e59 caused 64-byte passwords to produce a different key than before
|
||||
// so, try the old password encode function if the encoded password is longer than 64 bytes
|
||||
byte[] oldPasswordBytes = CryptoUtils.toBytesOld(password);
|
||||
if (!slot.isRepaired() && oldPasswordBytes.length > 64) {
|
||||
|
||||
try {
|
||||
masterKey = decryptPasswordSlot(slot, key);
|
||||
} catch (SlotIntegrityException e) {
|
||||
// a bug introduced in afb9e59 caused passwords longer than 64 bytes to produce a different key than before
|
||||
// so, try again with the old password encode function if the password is longer than 64 bytes
|
||||
if (slot.isRepaired() || oldPasswordBytes.length <= 64) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
ProgressDialog dialog = getDialog();
|
||||
dialog.setMessage(dialog.getContext().getString(R.string.unlocking_vault_repair));
|
||||
|
||||
// try to decrypt the password slot with the old key
|
||||
SecretKey oldKey = slot.deriveKey(oldPasswordBytes);
|
||||
masterKey = decryptPasswordSlot(slot, oldKey);
|
||||
} else {
|
||||
masterKey = decryptPasswordSlot(slot, key);
|
||||
}
|
||||
|
||||
// if necessary, repair the slot by re-encrypting the master key with the correct key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue