-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for new Authenticator Pro backup format
This adds support for Authenticator Pro's latest backup format changes. The format of the content itself has not changed as far as I can tell, but they do use a different cipher and KDF now: AES GCM and Argon2id, respectively. The memory cost is statically set at 64MiB. I suspect that this may cause OOM situations on some lower-end devices, but we'll see, not much we can do about that right now without making more changes.
- Loading branch information
1 parent
27e56d6
commit 9cabd9f
Showing
5 changed files
with
187 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/beemdevelopment/aegis/ui/tasks/Argon2Task.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.beemdevelopment.aegis.ui.tasks; | ||
|
||
import android.content.Context; | ||
|
||
import com.beemdevelopment.aegis.R; | ||
|
||
import org.bouncycastle.crypto.generators.Argon2BytesGenerator; | ||
import org.bouncycastle.crypto.params.Argon2Parameters; | ||
|
||
import javax.crypto.SecretKey; | ||
import javax.crypto.spec.SecretKeySpec; | ||
|
||
public class Argon2Task extends ProgressDialogTask<Argon2Task.Params, SecretKey> { | ||
private final Callback _cb; | ||
|
||
public Argon2Task(Context context, Callback cb) { | ||
super(context, context.getString(R.string.unlocking_vault)); | ||
_cb = cb; | ||
} | ||
|
||
@Override | ||
protected SecretKey doInBackground(Params... args) { | ||
setPriority(); | ||
|
||
Params params = args[0]; | ||
return deriveKey(params); | ||
} | ||
|
||
public static SecretKey deriveKey(Params params) { | ||
Argon2BytesGenerator gen = new Argon2BytesGenerator(); | ||
gen.init(params.getArgon2Params()); | ||
|
||
byte[] key = new byte[params.getKeySize()]; | ||
gen.generateBytes(params.getPassword(), key); | ||
return new SecretKeySpec(key, 0, key.length, "AES"); | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(SecretKey key) { | ||
super.onPostExecute(key); | ||
_cb.onTaskFinished(key); | ||
} | ||
|
||
public interface Callback { | ||
void onTaskFinished(SecretKey key); | ||
} | ||
|
||
public static class Params { | ||
private final char[] _password; | ||
private final Argon2Parameters _argon2Params; | ||
private final int _keySize; | ||
|
||
public Params(char[] password, Argon2Parameters argon2Params, int keySize) { | ||
_password = password; | ||
_argon2Params = argon2Params; | ||
_keySize = keySize; | ||
} | ||
|
||
public char[] getPassword() { | ||
return _password; | ||
} | ||
|
||
public Argon2Parameters getArgon2Params() { | ||
return _argon2Params; | ||
} | ||
|
||
public int getKeySize() { | ||
return _keySize; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+104 Bytes
(110%)
app/src/test/resources/com/beemdevelopment/aegis/importers/authpro_encrypted.bin
Binary file not shown.
Binary file added
BIN
+1.3 KB
app/src/test/resources/com/beemdevelopment/aegis/importers/authpro_encrypted_legacy.bin
Binary file not shown.