Browse Source

fix bug loading hex keyfile without newline. https://github.com/authpass/authpass/issues/3

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
2180d39f68
  1. 3
      lib/src/kdbx_format.dart
  2. 9
      test/kdbx_test.dart
  3. 1
      test/keyfile/hexkey_no_newline
  4. BIN
      test/keyfile/newdatabase2.kdbx

3
lib/src/kdbx_format.dart

@ -87,7 +87,8 @@ class KeyFileCredentials implements CredentialsPart {
KeyFileCredentials._(this._keyFileValue);
static final RegExp _hexValuePattern = RegExp(r'/^[a-f\d]{64}$/i');
static final RegExp _hexValuePattern =
RegExp(r'^[a-f\d]{64}', caseSensitive: false);
final ProtectedValue _keyFileValue;

9
test/kdbx_test.dart

@ -41,6 +41,15 @@ void main() {
final file = kdbxForamt.read(data, cred);
expect(file.body.rootGroup.entries, hasLength(2));
});
test('Read with PW and hex keyfile', () async {
final keyFileBytes =
await File('test/keyfile/hexkey_no_newline').readAsBytes();
final cred = Credentials.composite(
ProtectedValue.fromString('testing99'), keyFileBytes);
final data = await File('test/keyfile/newdatabase2.kdbx').readAsBytes();
final file = kdbxForamt.read(data, cred);
expect(file.body.rootGroup.entries, hasLength(3));
});
});
group('Creating', () {

1
test/keyfile/hexkey_no_newline

@ -0,0 +1 @@
033ce6a895f345fdd177c1afcbc6bdbc8047207ba0e58e5231c1ee53f4b40d70

BIN
test/keyfile/newdatabase2.kdbx

Binary file not shown.
Loading…
Cancel
Save