mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-30 13:52:58 -08:00
feat: Derive master key exception
This commit is contained in:
1 parent
99e9a92953
commit
8b6af6fd8a
3 files changed
+18
-4
No files matched your search
@@ -25,6 +25,7 @@ import com.kunzisoft.encrypt.aes.AESTransformer
|
||||
import com.kunzisoft.keepass.database.crypto.EncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.database.crypto.kdf.KdfEngine
|
||||
import com.kunzisoft.keepass.database.crypto.kdf.KdfFactory
|
||||
import com.kunzisoft.keepass.database.element.MainCredential
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.database.element.entry.EntryKDB
|
||||
import com.kunzisoft.keepass.database.element.group.GroupKDB
|
||||
@@ -32,7 +33,8 @@ import com.kunzisoft.keepass.database.element.icon.IconImageStandard
|
||||
import com.kunzisoft.keepass.database.element.node.NodeIdInt
|
||||
import com.kunzisoft.keepass.database.element.node.NodeIdUUID
|
||||
import com.kunzisoft.keepass.database.element.node.NodeVersioned
|
||||
import com.kunzisoft.keepass.database.element.MainCredential
|
||||
import com.kunzisoft.keepass.database.exception.EmptyKeyDatabaseException
|
||||
import com.kunzisoft.keepass.database.exception.HardwareKeyDatabaseException
|
||||
import java.io.IOException
|
||||
import java.nio.charset.Charset
|
||||
import java.util.*
|
||||
@@ -131,10 +133,10 @@ class DatabaseKDB : DatabaseVersioned<Int, UUID, GroupKDB, EntryKDB>() {
|
||||
mainCredential: MainCredential
|
||||
) {
|
||||
// Exception when no password
|
||||
if (mainCredential.password == null && mainCredential.keyFileUri == null)
|
||||
throw IllegalArgumentException("Key cannot be empty.")
|
||||
if (mainCredential.hardwareKey != null)
|
||||
throw IllegalArgumentException("Hardware key is not supported.")
|
||||
throw HardwareKeyDatabaseException()
|
||||
if (mainCredential.password == null && mainCredential.keyFileUri == null)
|
||||
throw EmptyKeyDatabaseException()
|
||||
|
||||
// Retrieve plain data
|
||||
val password = mainCredential.password
|
||||
|
||||
@@ -105,6 +105,16 @@ class UnknownDatabaseLocationException : DatabaseException() {
|
||||
override var errorId: Int = R.string.error_location_unknown
|
||||
}
|
||||
|
||||
class HardwareKeyDatabaseException : DatabaseException() {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_hardware_key_unsupported
|
||||
}
|
||||
|
||||
class EmptyKeyDatabaseException : DatabaseException() {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.error_empty_key
|
||||
}
|
||||
|
||||
class SignatureDatabaseException : DatabaseInputException() {
|
||||
@StringRes
|
||||
override var errorId: Int = R.string.invalid_db_sig
|
||||
|
||||
Reference in new issue
Block a user