diff --git a/lib/src/kdbx_format.dart b/lib/src/kdbx_format.dart index f462c5f..05887e7 100644 --- a/lib/src/kdbx_format.dart +++ b/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; diff --git a/test/kdbx_test.dart b/test/kdbx_test.dart index bb7fd12..cf44a2a 100644 --- a/test/kdbx_test.dart +++ b/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', () { diff --git a/test/keyfile/hexkey_no_newline b/test/keyfile/hexkey_no_newline new file mode 100644 index 0000000..b4e9a91 --- /dev/null +++ b/test/keyfile/hexkey_no_newline @@ -0,0 +1 @@ +033ce6a895f345fdd177c1afcbc6bdbc8047207ba0e58e5231c1ee53f4b40d70 \ No newline at end of file diff --git a/test/keyfile/newdatabase2.kdbx b/test/keyfile/newdatabase2.kdbx new file mode 100644 index 0000000..49581fa Binary files /dev/null and b/test/keyfile/newdatabase2.kdbx differ