Fix algorithm and kdf function for database V3 and add small trad

This commit is contained in:
J-Jamet committed 2018-05-13 13:55:37 +02:00
1 parent 7bcc289518
commit 92eeccf84e
4 files changed
+15 -4

No files matched your search

@@ -360,11 +360,14 @@ public class Database {
return new ArrayList<>();
}
public boolean allowEncryptionAlgorithmModification() {
return getAvailableEncryptionAlgorithms().size() > 1;
}
public void assignEncryptionAlgorithm(PwEncryptionAlgorithm algorithm) {
switch (getPwDatabase().getVersion()) {
case V4:
((PwDatabaseV4) getPwDatabase()).setEncryptionAlgorithm(algorithm);
// TODO Simplify
((PwDatabaseV4) getPwDatabase()).setDataEngine(algorithm.getCipherEngine());
((PwDatabaseV4) getPwDatabase()).setDataCipher(algorithm.getDataCipher());
}
@@ -384,6 +387,10 @@ public class Database {
return new ArrayList<>();
}
public boolean allowKdfModification() {
return getAvailableKdfEngines().size() > 1;
}
public KdfEngine getKdfEngine() {
return getPwDatabase().getKdfEngine();
}
@@ -66,7 +66,8 @@ public class DatabaseEncryptionAlgorithmPreferenceDialogFragmentCompat extends D
@Override
public void onDialogClosed(boolean positiveResult) {
if ( positiveResult ) {
if ( positiveResult
&& database.allowEncryptionAlgorithmModification()) {
assert getContext() != null;
if (algorithmSelected != null) {
@@ -70,7 +70,8 @@ public class DatabaseKeyDerivationPreferenceDialogFragmentCompat extends Databas
@Override
public void onDialogClosed(boolean positiveResult) {
if ( positiveResult ) {
if ( positiveResult
&& database.allowKdfModification()) {
assert getContext() != null;
if (kdfEngineSelected != null) {