Closed ivanovpv closed 7 years ago
That's odd. There's a specific test for this use case in DomDatabaseWrapperTest
, does the test work for you?
@Test
public void inspectKeyfileDatabase() throws IOException {
InputStream keyFileInputStream = getClass().getClassLoader().getResourceAsStream("KeyFileDatabase.key");
Credentials credentials = new KdbxCreds("123".getBytes(), keyFileInputStream);
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("KeyFileDatabase.kdbx");
DomDatabaseWrapper database = new DomDatabaseWrapper(new KdbxStreamFormat(), credentials, inputStream);
database.save(new StreamFormat.None(), new Credentials.None(), System.out);
}
What's the specific error that is being thrown?
I agree - that's odd. Unit test mentioned by you works well but only with your test database.
With my database it fails with trace:
java.lang.IllegalStateException: Inconsistent stream start bytes. This usually means the credentials were wromng.
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.checkStartBytes(KdbxSerializer.java:129)
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.createUnencryptedInputStream(KdbxSerializer.java:88)
at org.linguafranca.pwdb.kdbx.stream_3_1.KdbxStreamFormat.load(KdbxStreamFormat.java:37)
at org.linguafranca.pwdb.kdbx.dom.DomDatabaseWrapper.<init>(DomDatabaseWrapper.java:53)
at org.linguafranca.pwdb.kdbx.dom.DomDatabaseWrapper.load(DomDatabaseWrapper.java:58)
Here's my test database and test database key file
Database password is 123456
That database opens with password 123456, and does not require the key file. So when I try to open it with the key file as well as the password it fails, as expected. Am I misunderstanding something?
Hmmm... in my case with native KeePass v. 2.34 (Win x64) I can open database only if I apply both password and key file. But suddenly I realized that I could open it with KeePassJava2 w/o key file (only using password).
So from this point of view looks like correct, but a bit strange... Can't understand whose bug/feature it is? native KeePass?
When I run KeePass 2.34 in a windows emulation it will not open with both password and creds so that is odd. Anyway, glad all sorted for now. Plus the good news is I got to see that there is a typo in "This usually means the credentials were wromng." :-)
Tried to load test database with
DomDatabaseWrapper
.Database was created with KeePass v. 2.34 for Windows and secured with composite key: password+key file.
Code looks like:
Meantime, if I remove from database composite key (i.e. only password based encryption) - I'm able to read database correctly using: