mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Select Twofish with KDB database
This commit is contained in:
@@ -238,9 +238,6 @@ class Database {
|
||||
val allowNoMasterKey: Boolean
|
||||
get() = mDatabaseKDBX != null
|
||||
|
||||
val allowEncryptionAlgorithmModification: Boolean
|
||||
get() = availableEncryptionAlgorithms.size > 1
|
||||
|
||||
fun getEncryptionAlgorithmName(): String {
|
||||
return mDatabaseKDB?.encryptionAlgorithm?.toString()
|
||||
?: mDatabaseKDBX?.encryptionAlgorithm?.toString()
|
||||
|
||||
@@ -77,6 +77,7 @@ class DatabaseKDB : DatabaseVersioned<Int, UUID, GroupKDB, EntryKDB>() {
|
||||
get() {
|
||||
val list = ArrayList<EncryptionAlgorithm>()
|
||||
list.add(EncryptionAlgorithm.AESRijndael)
|
||||
list.add(EncryptionAlgorithm.Twofish)
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
@@ -105,11 +105,11 @@ class DatabaseOutputKDB(private val mDatabaseKDB: DatabaseKDB,
|
||||
header.signature2 = DatabaseHeaderKDB.DBSIG_2
|
||||
header.flags = DatabaseHeaderKDB.FLAG_SHA2
|
||||
|
||||
when {
|
||||
mDatabaseKDB.encryptionAlgorithm === EncryptionAlgorithm.AESRijndael -> {
|
||||
when (mDatabaseKDB.encryptionAlgorithm) {
|
||||
EncryptionAlgorithm.AESRijndael -> {
|
||||
header.flags = UnsignedInt(header.flags.toKotlinInt() or DatabaseHeaderKDB.FLAG_RIJNDAEL.toKotlinInt())
|
||||
}
|
||||
mDatabaseKDB.encryptionAlgorithm === EncryptionAlgorithm.Twofish -> {
|
||||
EncryptionAlgorithm.Twofish -> {
|
||||
header.flags = UnsignedInt(header.flags.toKotlinInt() or DatabaseHeaderKDB.FLAG_TWOFISH.toKotlinInt())
|
||||
}
|
||||
else -> throw DatabaseOutputException("Unsupported algorithm.")
|
||||
|
||||
@@ -58,15 +58,13 @@ class DatabaseEncryptionAlgorithmPreferenceDialogFragmentCompat
|
||||
|
||||
if (positiveResult) {
|
||||
database?.let { database ->
|
||||
if (database.allowEncryptionAlgorithmModification) {
|
||||
if (algorithmSelected != null) {
|
||||
val newAlgorithm = algorithmSelected
|
||||
val oldAlgorithm = database.encryptionAlgorithm
|
||||
database.encryptionAlgorithm = newAlgorithm
|
||||
if (algorithmSelected != null) {
|
||||
val newAlgorithm = algorithmSelected
|
||||
val oldAlgorithm = database.encryptionAlgorithm
|
||||
database.encryptionAlgorithm = newAlgorithm
|
||||
|
||||
if (oldAlgorithm != null && newAlgorithm != null)
|
||||
mProgressDatabaseTaskProvider?.startDatabaseSaveEncryption(oldAlgorithm, newAlgorithm, mDatabaseAutoSaveEnable)
|
||||
}
|
||||
if (oldAlgorithm != null && newAlgorithm != null)
|
||||
mProgressDatabaseTaskProvider?.startDatabaseSaveEncryption(oldAlgorithm, newAlgorithm, mDatabaseAutoSaveEnable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user