|
|
@ -11,18 +11,12 @@ import 'package:crypto/crypto.dart' as crypto; |
|
|
|
import 'package:kdbx/kdbx.dart'; |
|
|
|
import 'package:kdbx/kdbx.dart'; |
|
|
|
import 'package:kdbx/src/crypto/key_encrypter_kdf.dart'; |
|
|
|
import 'package:kdbx/src/crypto/key_encrypter_kdf.dart'; |
|
|
|
import 'package:kdbx/src/crypto/protected_salt_generator.dart'; |
|
|
|
import 'package:kdbx/src/crypto/protected_salt_generator.dart'; |
|
|
|
import 'package:kdbx/src/crypto/protected_value.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/internal/consts.dart'; |
|
|
|
import 'package:kdbx/src/internal/consts.dart'; |
|
|
|
import 'package:kdbx/src/internal/crypto_utils.dart'; |
|
|
|
import 'package:kdbx/src/internal/crypto_utils.dart'; |
|
|
|
import 'package:kdbx/src/internal/extension_utils.dart'; |
|
|
|
import 'package:kdbx/src/internal/extension_utils.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_binary.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/kdbx_deleted_object.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_deleted_object.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_entry.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_entry.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_file.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/kdbx_group.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/kdbx_header.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_header.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_meta.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/kdbx_object.dart'; |
|
|
|
|
|
|
|
import 'package:kdbx/src/kdbx_xml.dart'; |
|
|
|
import 'package:kdbx/src/kdbx_xml.dart'; |
|
|
|
import 'package:kdbx/src/utils/byte_utils.dart'; |
|
|
|
import 'package:kdbx/src/utils/byte_utils.dart'; |
|
|
|
import 'package:logging/logging.dart'; |
|
|
|
import 'package:logging/logging.dart'; |
|
|
@ -39,7 +33,7 @@ abstract class Credentials { |
|
|
|
Credentials.composite(password, null); //PasswordCredentials(password); |
|
|
|
Credentials.composite(password, null); //PasswordCredentials(password); |
|
|
|
factory Credentials.composite(ProtectedValue password, Uint8List? keyFile) => |
|
|
|
factory Credentials.composite(ProtectedValue password, Uint8List? keyFile) => |
|
|
|
KeyFileComposite( |
|
|
|
KeyFileComposite( |
|
|
|
password: password == null ? null : PasswordCredentials(password), |
|
|
|
password: PasswordCredentials(password), |
|
|
|
keyFile: keyFile == null ? null : KeyFileCredentials(keyFile), |
|
|
|
keyFile: keyFile == null ? null : KeyFileCredentials(keyFile), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
@ -73,9 +67,7 @@ class KdbxReadWriteContext { |
|
|
|
KdbxReadWriteContext({ |
|
|
|
KdbxReadWriteContext({ |
|
|
|
required List<KdbxBinary> binaries, |
|
|
|
required List<KdbxBinary> binaries, |
|
|
|
required this.header, |
|
|
|
required this.header, |
|
|
|
}) : assert(binaries != null), |
|
|
|
}) : _binaries = binaries, |
|
|
|
assert(header != null), |
|
|
|
|
|
|
|
_binaries = binaries, |
|
|
|
|
|
|
|
_deletedObjects = []; |
|
|
|
_deletedObjects = []; |
|
|
|
|
|
|
|
|
|
|
|
static final kdbxContext = Expando<KdbxReadWriteContext>(); |
|
|
|
static final kdbxContext = Expando<KdbxReadWriteContext>(); |
|
|
@ -129,7 +121,6 @@ class KdbxReadWriteContext { |
|
|
|
/// finds the ID of the given binary. |
|
|
|
/// finds the ID of the given binary. |
|
|
|
/// if it can't be found, [KdbxCorruptedFileException] is thrown. |
|
|
|
/// if it can't be found, [KdbxCorruptedFileException] is thrown. |
|
|
|
int findBinaryId(KdbxBinary binary) { |
|
|
|
int findBinaryId(KdbxBinary binary) { |
|
|
|
assert(binary != null); |
|
|
|
|
|
|
|
assert(!binary.isInline!); |
|
|
|
assert(!binary.isInline!); |
|
|
|
final id = _binaries.indexOf(binary); |
|
|
|
final id = _binaries.indexOf(binary); |
|
|
|
if (id < 0) { |
|
|
|
if (id < 0) { |
|
|
@ -818,7 +809,7 @@ class KdbxFormat { |
|
|
|
final deletedObjects = root |
|
|
|
final deletedObjects = root |
|
|
|
.findElements(KdbxXml.NODE_DELETED_OBJECTS) |
|
|
|
.findElements(KdbxXml.NODE_DELETED_OBJECTS) |
|
|
|
.singleOrNull |
|
|
|
.singleOrNull |
|
|
|
?.let((el) => el! |
|
|
|
?.let((el) => el |
|
|
|
.findElements(KdbxDeletedObject.NODE_NAME) |
|
|
|
.findElements(KdbxDeletedObject.NODE_NAME) |
|
|
|
.map((node) => KdbxDeletedObject.read(node, ctx))) ?? |
|
|
|
.map((node) => KdbxDeletedObject.read(node, ctx))) ?? |
|
|
|
[]; |
|
|
|
[]; |
|
|
|