diff --git a/lib/src/internal/byte_utils.dart b/lib/src/internal/byte_utils.dart index dca690c..307b1ff 100644 --- a/lib/src/internal/byte_utils.dart +++ b/lib/src/internal/byte_utils.dart @@ -1,4 +1,3 @@ -import 'dart:ffi'; import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; diff --git a/lib/src/kdbx_format.dart b/lib/src/kdbx_format.dart index ce53234..44ad022 100644 --- a/lib/src/kdbx_format.dart +++ b/lib/src/kdbx_format.dart @@ -20,11 +20,22 @@ import 'kdbx_object.dart'; final _logger = Logger('kdbx.format'); -class Credentials { - Credentials(this._password); +abstract class Credentials { + factory Credentials(ProtectedValue password) => PasswordCredentials(password); + + Credentials._(); + + factory Credentials.fromHash(Uint8List hash) => HashCredentials(hash); + + Uint8List getHash(); +} + +class PasswordCredentials implements Credentials { + PasswordCredentials(this._password); final ProtectedValue _password; + @override Uint8List getHash() { final output = convert.AccumulatorSink(); final input = crypto.sha256.startChunkedConversion(output); @@ -34,6 +45,15 @@ class Credentials { } } +class HashCredentials implements Credentials { + HashCredentials(this.hash); + + final Uint8List hash; + + @override + Uint8List getHash() => hash; +} + class KdbxFile { KdbxFile(this.credentials, this.header, this.body) { for (final obj in _allObjects) { diff --git a/lib/src/kdbx_group.dart b/lib/src/kdbx_group.dart index 4500a0e..341a8e5 100644 --- a/lib/src/kdbx_group.dart +++ b/lib/src/kdbx_group.dart @@ -1,5 +1,4 @@ import 'package:kdbx/kdbx.dart'; -import 'package:kdbx/src/internal/async_utils.dart'; import 'package:kdbx/src/kdbx_consts.dart'; import 'package:kdbx/src/kdbx_entry.dart'; import 'package:kdbx/src/kdbx_xml.dart'; @@ -27,8 +26,6 @@ class KdbxGroup extends KdbxObject { .forEach(_entries.add); } - final StreamSubscriptions _subscriptions = StreamSubscriptions(); - @override XmlElement toXml() { final el = super.toXml(); diff --git a/test/kdbx_test.dart b/test/kdbx_test.dart index 70f5cc6..0d6bda1 100644 --- a/test/kdbx_test.dart +++ b/test/kdbx_test.dart @@ -4,7 +4,6 @@ import 'dart:typed_data'; import 'package:kdbx/kdbx.dart'; import 'package:kdbx/src/crypto/protected_salt_generator.dart'; import 'package:kdbx/src/crypto/protected_value.dart'; -import 'package:kdbx/src/internal/byte_utils.dart'; import 'package:kdbx/src/kdbx_format.dart'; import 'package:logging/logging.dart'; import 'package:logging_appenders/logging_appenders.dart';