mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Rename input output utility class for db
This commit is contained in:
@@ -30,9 +30,9 @@ import junit.framework.TestCase
|
||||
import com.kunzisoft.keepass.database.element.PwDate
|
||||
import com.kunzisoft.keepass.stream.LEDataInputStream
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
class TypesTest : TestCase() {
|
||||
class DatabaseInputOutputUtilsTest : TestCase() {
|
||||
|
||||
fun testReadWriteLongZero() {
|
||||
testReadWriteLong(0.toByte())
|
||||
@@ -155,8 +155,8 @@ class TypesTest : TestCase() {
|
||||
|
||||
setArray(orig, value, 0, 1)
|
||||
|
||||
val one = Types.readUByte(orig, 0)
|
||||
Types.writeUByte(one, dest, 0)
|
||||
val one = DatabaseInputOutputUtils.readUByte(orig, 0)
|
||||
DatabaseInputOutputUtils.writeUByte(one, dest, 0)
|
||||
|
||||
assertArrayEquals(orig, dest)
|
||||
|
||||
@@ -185,8 +185,8 @@ class TypesTest : TestCase() {
|
||||
val bUUID = ByteArray(16)
|
||||
rnd.nextBytes(bUUID)
|
||||
|
||||
val uuid = Types.bytestoUUID(bUUID)
|
||||
val eUUID = Types.UUIDtoBytes(uuid)
|
||||
val uuid = DatabaseInputOutputUtils.bytestoUUID(bUUID)
|
||||
val eUUID = DatabaseInputOutputUtils.UUIDtoBytes(uuid)
|
||||
|
||||
assertArrayEquals("UUID match failed", bUUID, eUUID)
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class TypesTest : TestCase() {
|
||||
|
||||
val bos = ByteArrayOutputStream()
|
||||
val leos = LEDataOutputStream(bos)
|
||||
leos.writeLong(Types.ULONG_MAX_VALUE)
|
||||
leos.writeLong(DatabaseInputOutputUtils.ULONG_MAX_VALUE)
|
||||
leos.close()
|
||||
|
||||
val uLongMax = bos.toByteArray()
|
||||
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.crypto.engine
|
||||
|
||||
import com.kunzisoft.keepass.crypto.CipherFactory
|
||||
import com.kunzisoft.keepass.database.element.PwEncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import java.security.InvalidAlgorithmParameterException
|
||||
import java.security.InvalidKeyException
|
||||
import java.security.NoSuchAlgorithmException
|
||||
@@ -47,7 +47,7 @@ class AesEngine : CipherEngine() {
|
||||
|
||||
companion object {
|
||||
|
||||
val CIPHER_UUID: UUID = Types.bytestoUUID(
|
||||
val CIPHER_UUID: UUID = DatabaseInputOutputUtils.bytestoUUID(
|
||||
byteArrayOf(0x31.toByte(), 0xC1.toByte(), 0xF2.toByte(), 0xE6.toByte(), 0xBF.toByte(), 0x71.toByte(), 0x43.toByte(), 0x50.toByte(), 0xBE.toByte(), 0x58.toByte(), 0x05.toByte(), 0x21.toByte(), 0x6A.toByte(), 0xFC.toByte(), 0x5A.toByte(), 0xFF.toByte()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.kunzisoft.keepass.crypto.engine
|
||||
|
||||
import com.kunzisoft.keepass.database.element.PwEncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider
|
||||
import java.security.InvalidAlgorithmParameterException
|
||||
import java.security.InvalidKeyException
|
||||
@@ -50,7 +50,7 @@ class ChaCha20Engine : CipherEngine() {
|
||||
|
||||
companion object {
|
||||
|
||||
val CIPHER_UUID: UUID = Types.bytestoUUID(
|
||||
val CIPHER_UUID: UUID = DatabaseInputOutputUtils.bytestoUUID(
|
||||
byteArrayOf(0xD6.toByte(), 0x03.toByte(), 0x8A.toByte(), 0x2B.toByte(), 0x8B.toByte(), 0x6F.toByte(), 0x4C.toByte(), 0xB5.toByte(), 0xA5.toByte(), 0x24.toByte(), 0x33.toByte(), 0x9A.toByte(), 0x31.toByte(), 0xDB.toByte(), 0xB5.toByte(), 0x9A.toByte()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.kunzisoft.keepass.crypto.engine
|
||||
|
||||
import com.kunzisoft.keepass.crypto.CipherFactory
|
||||
import com.kunzisoft.keepass.database.element.PwEncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException
|
||||
import java.security.InvalidKeyException
|
||||
@@ -53,7 +53,7 @@ class TwofishEngine : CipherEngine() {
|
||||
|
||||
companion object {
|
||||
|
||||
val CIPHER_UUID: UUID = Types.bytestoUUID(
|
||||
val CIPHER_UUID: UUID = DatabaseInputOutputUtils.bytestoUUID(
|
||||
byteArrayOf(0xAD.toByte(), 0x68.toByte(), 0xF2.toByte(), 0x9F.toByte(), 0x57.toByte(), 0x6F.toByte(), 0x4B.toByte(), 0xB9.toByte(), 0xA3.toByte(), 0x6A.toByte(), 0xD4.toByte(), 0x7A.toByte(), 0xF9.toByte(), 0x65.toByte(), 0x34.toByte(), 0x6C.toByte()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.content.res.Resources
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.crypto.CryptoUtil
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKeyFactory
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import java.io.IOException
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
@@ -88,7 +88,7 @@ class AesKdf internal constructor() : KdfEngine() {
|
||||
|
||||
private const val DEFAULT_ROUNDS = 6000
|
||||
|
||||
val CIPHER_UUID: UUID = Types.bytestoUUID(
|
||||
val CIPHER_UUID: UUID = DatabaseInputOutputUtils.bytestoUUID(
|
||||
byteArrayOf(0xC9.toByte(),
|
||||
0xD9.toByte(),
|
||||
0xF3.toByte(),
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.kunzisoft.keepass.crypto.keyDerivation
|
||||
|
||||
import android.content.res.Resources
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import java.io.IOException
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
@@ -126,7 +126,7 @@ class Argon2Kdf internal constructor() : KdfEngine() {
|
||||
|
||||
companion object {
|
||||
|
||||
val CIPHER_UUID: UUID = Types.bytestoUUID(
|
||||
val CIPHER_UUID: UUID = DatabaseInputOutputUtils.bytestoUUID(
|
||||
byteArrayOf(0xEF.toByte(),
|
||||
0x63.toByte(),
|
||||
0x6D.toByte(),
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.crypto.keyDerivation;
|
||||
import com.kunzisoft.keepass.utils.VariantDictionary;
|
||||
import com.kunzisoft.keepass.stream.LEDataInputStream;
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream;
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -44,7 +44,7 @@ public class KdfParameters extends VariantDictionary {
|
||||
}
|
||||
|
||||
protected void setParamUUID() {
|
||||
setByteArray(ParamUUID, Types.UUIDtoBytes(kdfUUID));
|
||||
setByteArray(ParamUUID, DatabaseInputOutputUtils.UUIDtoBytes(kdfUUID));
|
||||
}
|
||||
|
||||
public static KdfParameters deserialize(byte[] data) throws IOException {
|
||||
@@ -56,7 +56,7 @@ public class KdfParameters extends VariantDictionary {
|
||||
return null;
|
||||
}
|
||||
|
||||
UUID uuid = Types.bytestoUUID(d.getByteArray(ParamUUID));
|
||||
UUID uuid = DatabaseInputOutputUtils.bytestoUUID(d.getByteArray(ParamUUID));
|
||||
|
||||
KdfParameters kdfP = new KdfParameters(uuid);
|
||||
kdfP.copyTo(d);
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.content.res.Resources
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import androidx.core.os.ConfigurationCompat
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -188,11 +188,11 @@ class PwDate : Parcelable {
|
||||
*/
|
||||
fun readTime(buf: ByteArray?, offset: Int, calendar: Calendar?): Date {
|
||||
var time = calendar
|
||||
val dw1 = Types.readUByte(buf!!, offset)
|
||||
val dw2 = Types.readUByte(buf, offset + 1)
|
||||
val dw3 = Types.readUByte(buf, offset + 2)
|
||||
val dw4 = Types.readUByte(buf, offset + 3)
|
||||
val dw5 = Types.readUByte(buf, offset + 4)
|
||||
val dw1 = DatabaseInputOutputUtils.readUByte(buf!!, offset)
|
||||
val dw2 = DatabaseInputOutputUtils.readUByte(buf, offset + 1)
|
||||
val dw3 = DatabaseInputOutputUtils.readUByte(buf, offset + 2)
|
||||
val dw4 = DatabaseInputOutputUtils.readUByte(buf, offset + 3)
|
||||
val dw5 = DatabaseInputOutputUtils.readUByte(buf, offset + 4)
|
||||
|
||||
// Unpack 5 byte structure to date and time
|
||||
val year = dw1 shl 6 or (dw2 shr 2)
|
||||
@@ -236,8 +236,8 @@ class PwDate : Parcelable {
|
||||
val minute = cal.get(Calendar.MINUTE)
|
||||
val second = cal.get(Calendar.SECOND)
|
||||
|
||||
buf[0] = Types.writeUByte(year shr 6 and 0x0000003F)
|
||||
buf[1] = Types.writeUByte(year and 0x0000003F shl 2 or (month shr 2 and 0x00000003))
|
||||
buf[0] = DatabaseInputOutputUtils.writeUByte(year shr 6 and 0x0000003F)
|
||||
buf[1] = DatabaseInputOutputUtils.writeUByte(year and 0x0000003F shl 2 or (month shr 2 and 0x00000003))
|
||||
buf[2] = (month and 0x00000003 shl 6
|
||||
or (day and 0x0000001F shl 1) or (hour shr 4 and 0x00000001)).toByte()
|
||||
buf[3] = (hour and 0x0000000F shl 4 or (minute shr 2 and 0x0000000F)).toByte()
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.kunzisoft.keepass.database.exception.LoadDatabaseVersionException
|
||||
import com.kunzisoft.keepass.stream.CopyInputStream
|
||||
import com.kunzisoft.keepass.stream.HmacBlockStream
|
||||
import com.kunzisoft.keepass.stream.LEDataInputStream
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
@@ -239,7 +239,7 @@ class PwDbHeaderV4(private val databaseV4: PwDatabaseV4) : PwDbHeader() {
|
||||
throw IOException("Invalid cipher ID.")
|
||||
}
|
||||
|
||||
databaseV4.dataCipher = Types.bytestoUUID(pbId)
|
||||
databaseV4.dataCipher = DatabaseInputOutputUtils.bytestoUUID(pbId)
|
||||
}
|
||||
|
||||
private fun setTransformRound(roundsByte: ByteArray?) {
|
||||
@@ -319,7 +319,7 @@ class PwDbHeaderV4(private val databaseV4: PwDatabaseV4) : PwDbHeader() {
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun computeHeaderHmac(header: ByteArray, key: ByteArray): ByteArray {
|
||||
val blockKey = HmacBlockStream.GetHmacKey64(key, Types.ULONG_MAX_VALUE)
|
||||
val blockKey = HmacBlockStream.GetHmacKey64(key, DatabaseInputOutputUtils.ULONG_MAX_VALUE)
|
||||
|
||||
val hmac: Mac
|
||||
try {
|
||||
|
||||
@@ -55,7 +55,7 @@ import com.kunzisoft.keepass.database.file.PwDbHeaderV3
|
||||
import com.kunzisoft.keepass.stream.LEDataInputStream
|
||||
import com.kunzisoft.keepass.stream.NullOutputStream
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
import javax.crypto.*
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
@@ -287,7 +287,7 @@ class ImporterV3 : Importer<PwDatabaseV3>() {
|
||||
0x0000 -> {
|
||||
}
|
||||
0x0001 -> grp.setGroupId(LEDataInputStream.readInt(buf, offset))
|
||||
0x0002 -> grp.title = Types.readCString(buf, offset)
|
||||
0x0002 -> grp.title = DatabaseInputOutputUtils.readCString(buf, offset)
|
||||
0x0003 -> grp.creationTime = PwDate(buf, offset)
|
||||
0x0004 -> grp.lastModificationTime = PwDate(buf, offset)
|
||||
0x0005 -> grp.lastAccessTime = PwDate(buf, offset)
|
||||
@@ -309,7 +309,7 @@ class ImporterV3 : Importer<PwDatabaseV3>() {
|
||||
when (fieldType) {
|
||||
0x0000 -> {
|
||||
}
|
||||
0x0001 -> ent.nodeId = PwNodeIdUUID(Types.bytestoUUID(buf, offsetMutable))
|
||||
0x0001 -> ent.nodeId = PwNodeIdUUID(DatabaseInputOutputUtils.bytestoUUID(buf, offsetMutable))
|
||||
0x0002 -> {
|
||||
val pwGroupV3 = mDatabaseToOpen.createGroup()
|
||||
pwGroupV3.nodeId = PwNodeIdInt(LEDataInputStream.readInt(buf, offsetMutable))
|
||||
@@ -325,17 +325,17 @@ class ImporterV3 : Importer<PwDatabaseV3>() {
|
||||
|
||||
ent.icon = db.iconFactory.getIcon(iconId)
|
||||
}
|
||||
0x0004 -> ent.title = Types.readCString(buf, offsetMutable)
|
||||
0x0005 -> ent.url = Types.readCString(buf, offsetMutable)
|
||||
0x0006 -> ent.username = Types.readCString(buf, offsetMutable)
|
||||
0x0007 -> ent.password = Types.readPassword(buf, offsetMutable)
|
||||
0x0008 -> ent.notes = Types.readCString(buf, offsetMutable)
|
||||
0x0004 -> ent.title = DatabaseInputOutputUtils.readCString(buf, offsetMutable)
|
||||
0x0005 -> ent.url = DatabaseInputOutputUtils.readCString(buf, offsetMutable)
|
||||
0x0006 -> ent.username = DatabaseInputOutputUtils.readCString(buf, offsetMutable)
|
||||
0x0007 -> ent.password = DatabaseInputOutputUtils.readPassword(buf, offsetMutable)
|
||||
0x0008 -> ent.notes = DatabaseInputOutputUtils.readCString(buf, offsetMutable)
|
||||
0x0009 -> ent.creationTime = PwDate(buf, offsetMutable)
|
||||
0x000A -> ent.lastModificationTime = PwDate(buf, offsetMutable)
|
||||
0x000B -> ent.lastAccessTime = PwDate(buf, offsetMutable)
|
||||
0x000C -> ent.expiryTime = PwDate(buf, offsetMutable)
|
||||
0x000D -> ent.binaryDesc = Types.readCString(buf, offsetMutable)
|
||||
0x000E -> ent.binaryData = Types.readBytes(buf, offsetMutable, fieldSize)
|
||||
0x000D -> ent.binaryDesc = DatabaseInputOutputUtils.readCString(buf, offsetMutable)
|
||||
0x000E -> ent.binaryData = DatabaseInputOutputUtils.readBytes(buf, offsetMutable, fieldSize)
|
||||
}// Ignore field
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.kunzisoft.keepass.stream.HmacBlockInputStream
|
||||
import com.kunzisoft.keepass.stream.LEDataInputStream
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
import com.kunzisoft.keepass.utils.MemoryUtil
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import org.spongycastle.crypto.StreamCipher
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserException
|
||||
@@ -876,7 +876,7 @@ class ImporterV4(private val streamDir: File,
|
||||
// TODO: Switch to framework Base64 once API level 8 is the minimum
|
||||
val buf = Base64Coder.decode(encoded)
|
||||
|
||||
return Types.bytestoUUID(buf)
|
||||
return DatabaseInputOutputUtils.bytestoUUID(buf)
|
||||
}
|
||||
|
||||
@Throws(IOException::class, XmlPullParserException::class)
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.kunzisoft.keepass.database.exception.DatabaseOutputException
|
||||
import com.kunzisoft.keepass.stream.HmacBlockStream
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream
|
||||
import com.kunzisoft.keepass.stream.MacOutputStream
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
@@ -66,7 +66,7 @@ constructor(private val db: PwDatabaseV4, private val header: PwDbHeaderV4, os:
|
||||
val hmac: Mac
|
||||
try {
|
||||
hmac = Mac.getInstance("HmacSHA256")
|
||||
val signingKey = SecretKeySpec(HmacBlockStream.GetHmacKey64(db.hmacKey, Types.ULONG_MAX_VALUE), "HmacSHA256")
|
||||
val signingKey = SecretKeySpec(HmacBlockStream.GetHmacKey64(db.hmacKey, DatabaseInputOutputUtils.ULONG_MAX_VALUE), "HmacSHA256")
|
||||
hmac.init(signingKey)
|
||||
} catch (e: NoSuchAlgorithmException) {
|
||||
throw DatabaseOutputException(e)
|
||||
@@ -86,7 +86,7 @@ constructor(private val db: PwDatabaseV4, private val header: PwDbHeaderV4, os:
|
||||
los.writeUInt(PwDbHeaderV4.DBSIG_2.toLong())
|
||||
los.writeUInt(header.version)
|
||||
|
||||
writeHeaderField(PwDbHeaderV4.PwDbHeaderV4Fields.CipherID, Types.UUIDtoBytes(db.dataCipher))
|
||||
writeHeaderField(PwDbHeaderV4.PwDbHeaderV4Fields.CipherID, DatabaseInputOutputUtils.UUIDtoBytes(db.dataCipher))
|
||||
writeHeaderField(PwDbHeaderV4.PwDbHeaderV4Fields.CompressionFlags, LEDataOutputStream.writeIntBuf(PwDbHeaderV4.getFlagFromCompression(db.compressionAlgorithm)))
|
||||
writeHeaderField(PwDbHeaderV4.PwDbHeaderV4Fields.MasterSeed, header.masterSeed)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.kunzisoft.keepass.stream.HmacBlockOutputStream
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream
|
||||
import com.kunzisoft.keepass.database.file.KDBX4DateUtil
|
||||
import com.kunzisoft.keepass.utils.MemoryUtil
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
import org.joda.time.DateTime
|
||||
import org.spongycastle.crypto.StreamCipher
|
||||
import org.xmlpull.v1.XmlSerializer
|
||||
@@ -505,7 +505,7 @@ class PwDbV4Output(private val mDatabaseV4: PwDatabaseV4, outputStream: OutputSt
|
||||
|
||||
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
|
||||
private fun writeObject(name: String, uuid: UUID) {
|
||||
val data = Types.UUIDtoBytes(uuid)
|
||||
val data = DatabaseInputOutputUtils.UUIDtoBytes(uuid)
|
||||
writeObject(name, String(Base64Coder.encode(data)))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.kunzisoft.keepass.database.file.save
|
||||
|
||||
import com.kunzisoft.keepass.database.element.PwEntryV3
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
@@ -47,7 +47,7 @@ class PwEntryOutputV3
|
||||
// UUID
|
||||
mOutputStream.write(UUID_FIELD_TYPE)
|
||||
mOutputStream.write(UUID_FIELD_SIZE)
|
||||
mOutputStream.write(Types.UUIDtoBytes(mEntry.id))
|
||||
mOutputStream.write(DatabaseInputOutputUtils.UUIDtoBytes(mEntry.id))
|
||||
|
||||
// Group ID
|
||||
mOutputStream.write(GROUPID_FIELD_TYPE)
|
||||
@@ -62,23 +62,23 @@ class PwEntryOutputV3
|
||||
// Title
|
||||
//byte[] title = mEntry.title.getBytes("UTF-8");
|
||||
mOutputStream.write(TITLE_FIELD_TYPE)
|
||||
length += Types.writeCString(mEntry.title, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writeCString(mEntry.title, mOutputStream).toLong()
|
||||
|
||||
// URL
|
||||
mOutputStream.write(URL_FIELD_TYPE)
|
||||
length += Types.writeCString(mEntry.url, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writeCString(mEntry.url, mOutputStream).toLong()
|
||||
|
||||
// Username
|
||||
mOutputStream.write(USERNAME_FIELD_TYPE)
|
||||
length += Types.writeCString(mEntry.username, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writeCString(mEntry.username, mOutputStream).toLong()
|
||||
|
||||
// Password
|
||||
mOutputStream.write(PASSWORD_FIELD_TYPE)
|
||||
length += Types.writePassword(mEntry.password, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writePassword(mEntry.password, mOutputStream).toLong()
|
||||
|
||||
// Additional
|
||||
mOutputStream.write(ADDITIONAL_FIELD_TYPE)
|
||||
length += Types.writeCString(mEntry.notes, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writeCString(mEntry.notes, mOutputStream).toLong()
|
||||
|
||||
// Create date
|
||||
writeDate(CREATE_FIELD_TYPE, mEntry.creationTime.byteArrayDate)
|
||||
@@ -114,11 +114,11 @@ class PwEntryOutputV3
|
||||
@Throws(IOException::class)
|
||||
private fun writeBinary(data: ByteArray?) {
|
||||
mOutputStream.write(BINARY_DESC_FIELD_TYPE)
|
||||
length += Types.writeCString(mEntry.binaryDesc, mOutputStream).toLong()
|
||||
length += DatabaseInputOutputUtils.writeCString(mEntry.binaryDesc, mOutputStream).toLong()
|
||||
|
||||
val dataLen: Int = data?.size ?: 0
|
||||
mOutputStream.write(BINARY_DATA_FIELD_TYPE)
|
||||
length += Types.writeBytes(data, dataLen, mOutputStream)
|
||||
length += DatabaseInputOutputUtils.writeBytes(data, dataLen, mOutputStream)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.kunzisoft.keepass.database.file.save
|
||||
|
||||
import com.kunzisoft.keepass.database.element.PwGroupV3
|
||||
import com.kunzisoft.keepass.stream.LEDataOutputStream
|
||||
import com.kunzisoft.keepass.utils.Types
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
@@ -44,7 +44,7 @@ class PwGroupOutputV3
|
||||
|
||||
// Name
|
||||
mOS.write(NAME_FIELD_TYPE)
|
||||
Types.writeCString(mPG.title, mOS)
|
||||
DatabaseInputOutputUtils.writeCString(mPG.title, mOS)
|
||||
|
||||
// Create date
|
||||
mOS.write(CREATE_FIELD_TYPE)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.search;
|
||||
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UuidUtil {
|
||||
public static String toHexString(UUID uuid) {
|
||||
if (uuid == null) { return null; }
|
||||
|
||||
byte[] buf = Types.UUIDtoBytes(uuid);
|
||||
byte[] buf = DatabaseInputOutputUtils.UUIDtoBytes(uuid);
|
||||
if (buf == null) { return null; }
|
||||
|
||||
int len = buf.length;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.stream;
|
||||
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -151,7 +151,7 @@ public class HashedBlockInputStream extends InputStream {
|
||||
if ( ! ReadHashedBlock() ) return -1;
|
||||
}
|
||||
|
||||
int output = Types.readUByte(buffer, bufferPos);
|
||||
int output = DatabaseInputOutputUtils.readUByte(buffer, bufferPos);
|
||||
bufferPos++;
|
||||
|
||||
return output;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.stream;
|
||||
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
import com.kunzisoft.keepass.utils.DatabaseInputOutputUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -56,7 +56,7 @@ public class HmacBlockInputStream extends InputStream {
|
||||
if (!readSafeBlock()) return -1;
|
||||
}
|
||||
|
||||
int output = Types.readUByte(buffer, bufferPos);
|
||||
int output = DatabaseInputOutputUtils.readUByte(buffer, bufferPos);
|
||||
bufferPos++;
|
||||
|
||||
return output;
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Bill Zwicky <wrzwicky@pobox.com>
|
||||
*/
|
||||
public class Types {
|
||||
public class DatabaseInputOutputUtils {
|
||||
|
||||
public static long ULONG_MAX_VALUE = -1;
|
||||
|
||||
Reference in New Issue
Block a user