mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-29 05:13:03 -08:00
fix: Clear MasterCredential when necessary #2485
This commit is contained in:
6 files changed
+66
-25
No files matched your search
@@ -45,17 +45,36 @@ import javax.xml.parsers.ParserConfigurationException
|
||||
import kotlin.math.min
|
||||
|
||||
data class MasterCredential(
|
||||
var password: CharArray? = null,
|
||||
var keyFileData: ByteArray? = null,
|
||||
private var mPassword: CharArray? = null,
|
||||
private var mKeyFileData: ByteArray? = null,
|
||||
var hardwareKey: HardwareKey? = null
|
||||
): Parcelable {
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
password = parcel.createCharArray()
|
||||
keyFileData = parcel.readByteArrayCompat()
|
||||
hardwareKey = parcel.readEnum<HardwareKey>()
|
||||
var password: CharArray?
|
||||
get() = mPassword
|
||||
set(value) {
|
||||
mPassword?.clear()
|
||||
mPassword = value?.copyOf()
|
||||
}
|
||||
|
||||
var keyFileData: ByteArray?
|
||||
get() = mKeyFileData
|
||||
set(value) {
|
||||
mKeyFileData?.fill(0)
|
||||
mKeyFileData = value?.copyOf()
|
||||
}
|
||||
|
||||
init {
|
||||
mPassword = mPassword?.copyOf()
|
||||
mKeyFileData = mKeyFileData?.copyOf()
|
||||
}
|
||||
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.createCharArray(),
|
||||
parcel.readByteArrayCompat(),
|
||||
parcel.readEnum<HardwareKey>()
|
||||
)
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeCharArray(password)
|
||||
parcel.writeByteArrayCompat(keyFileData)
|
||||
|
||||
@@ -12,7 +12,7 @@ enum class HardwareKey(val value: String) {
|
||||
val DEFAULT = CHALLENGE_RESPONSE_YUBIKEY
|
||||
|
||||
fun getStringValues(): List<String> {
|
||||
return values().map { it.value }
|
||||
return HardwareKey.entries.map { it.value }
|
||||
}
|
||||
|
||||
fun fromPosition(position: Int): HardwareKey {
|
||||
@@ -26,7 +26,7 @@ enum class HardwareKey(val value: String) {
|
||||
fun getHardwareKeyFromString(text: String?): HardwareKey? {
|
||||
if (text == null)
|
||||
return null
|
||||
values().find { it.value == text }?.let {
|
||||
HardwareKey.entries.find { it.value == text }?.let {
|
||||
return it
|
||||
}
|
||||
return DEFAULT
|
||||
|
||||
Reference in new issue
Block a user