Merge branch 'develop' into feature/Search_Refactoring

This commit is contained in:
J-Jamet
2022-02-02 12:39:59 +01:00
9 changed files with 20 additions and 48 deletions

View File

@@ -12,8 +12,8 @@ android {
applicationId "com.kunzisoft.keepass"
minSdkVersion 15
targetSdkVersion 31
versionCode = 96
versionName = "3.2.0_beta4"
versionCode = 97
versionName = "3.2.0"
multiDexEnabled true
testApplicationId = "com.kunzisoft.keepass.tests"

View File

@@ -991,20 +991,25 @@ class Database {
return null
}
fun createGroup(): Group? {
fun createGroup(virtual: Boolean = false): Group? {
if (!virtual) {
dataModifiedSinceLastLoading = true
}
var group: Group? = null
mDatabaseKDB?.let { database ->
return Group(database.createGroup()).apply {
group = Group(database.createGroup()).apply {
setNodeId(database.newGroupId())
}
}
mDatabaseKDBX?.let { database ->
return Group(database.createGroup()).apply {
group = Group(database.createGroup()).apply {
setNodeId(database.newGroupId())
}
}
if (virtual)
group?.isVirtual = virtual
return null
return group
}
fun getEntryById(id: NodeId<UUID>): Entry? {

View File

@@ -49,7 +49,6 @@ import com.kunzisoft.keepass.database.element.node.NodeVersioned
import com.kunzisoft.keepass.database.element.security.MemoryProtectionConfig
import com.kunzisoft.keepass.database.element.template.Template
import com.kunzisoft.keepass.database.element.template.TemplateEngineCompatible
import com.kunzisoft.keepass.database.exception.UnknownKDF
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_31
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_40
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_41
@@ -92,12 +91,7 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
var kdfParameters: KdfParameters? = null
override var kdfEngine: KdfEngine?
get() = try {
getEngineKDBX4(kdfParameters)
} catch (unknownKDF: UnknownKDF) {
Log.i(TAG, "Unable to retrieve KDF engine", unknownKDF)
null
}
get() = getKdfEngineFromParameters(kdfParameters)
set(value) {
value?.let {
if (kdfParameters?.uuid != value.defaultParameters.uuid)
@@ -108,18 +102,16 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
}
}
@Throws(UnknownKDF::class)
fun getEngineKDBX4(kdfParameters: KdfParameters?): KdfEngine {
val unknownKDFException = UnknownKDF()
private fun getKdfEngineFromParameters(kdfParameters: KdfParameters?): KdfEngine? {
if (kdfParameters == null) {
throw unknownKDFException
return null
}
for (engine in kdfAvailableList) {
if (engine.uuid == kdfParameters.uuid) {
return engine
}
}
throw unknownKDFException
return null
}
fun randomizeKdfParameters() {
@@ -553,7 +545,8 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
fun makeFinalKey(masterSeed: ByteArray) {
kdfParameters?.let { keyDerivationFunctionParameters ->
val kdfEngine = getEngineKDBX4(keyDerivationFunctionParameters)
val kdfEngine = getKdfEngineFromParameters(keyDerivationFunctionParameters)
?: throw IOException("Unknown key derivation function")
var transformedMasterKey = kdfEngine.transform(masterKey, keyDerivationFunctionParameters)
if (transformedMasterKey.size != 32) {

View File

@@ -1,24 +0,0 @@
/*
* Copyright 2019 Jeremy Jamet / Kunzisoft.
*
* This file is part of KeePassDX.
*
* KeePassDX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KeePassDX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.kunzisoft.keepass.database.exception
import java.io.IOException
class UnknownKDF : IOException("Unknown key derivation function")

View File

@@ -37,7 +37,6 @@ import com.kunzisoft.keepass.database.element.group.GroupKDBX
import com.kunzisoft.keepass.database.element.node.NodeKDBXInterface
import com.kunzisoft.keepass.database.element.security.MemoryProtectionConfig
import com.kunzisoft.keepass.database.exception.DatabaseOutputException
import com.kunzisoft.keepass.database.exception.UnknownKDF
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_40
import com.kunzisoft.keepass.database.file.DatabaseHeaderKDBX.Companion.FILE_VERSION_41

View File

@@ -39,8 +39,7 @@ class SearchHelper {
searchParameters: SearchParameters,
max: Int): Group? {
val searchGroup = database.createGroup()
searchGroup?.isVirtual = true
val searchGroup = database.createGroup(virtual = true)
searchGroup?.title = "\"" + searchParameters.searchQuery + "\""
// Search all entries

View File

@@ -90,7 +90,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/breadcrumb_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="horizontal" />
</androidx.appcompat.widget.Toolbar>