|
|
@ -20,11 +20,22 @@ import 'kdbx_object.dart'; |
|
|
|
|
|
|
|
|
|
|
|
final _logger = Logger('kdbx.format'); |
|
|
|
final _logger = Logger('kdbx.format'); |
|
|
|
|
|
|
|
|
|
|
|
class Credentials { |
|
|
|
abstract class Credentials { |
|
|
|
Credentials(this._password); |
|
|
|
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; |
|
|
|
final ProtectedValue _password; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
Uint8List getHash() { |
|
|
|
Uint8List getHash() { |
|
|
|
final output = convert.AccumulatorSink<crypto.Digest>(); |
|
|
|
final output = convert.AccumulatorSink<crypto.Digest>(); |
|
|
|
final input = crypto.sha256.startChunkedConversion(output); |
|
|
|
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 { |
|
|
|
class KdbxFile { |
|
|
|
KdbxFile(this.credentials, this.header, this.body) { |
|
|
|
KdbxFile(this.credentials, this.header, this.body) { |
|
|
|
for (final obj in _allObjects) { |
|
|
|
for (final obj in _allObjects) { |
|
|
|