mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-06 00:32:32 -08:00
Get to the point where I can decode the database down to plaintext XML.
This commit is contained in:
1 parent
a76b4e1976
commit
1bfc2bd29a
17 files changed
+560
-211
No files matched your search
@@ -19,8 +19,13 @@
|
||||
*/
|
||||
package com.keepassdroid.database;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.keepassdroid.database.exception.InvalidKeyFileException;
|
||||
|
||||
|
||||
public class PwDatabaseV4 extends PwDatabase {
|
||||
|
||||
@@ -28,4 +33,36 @@ public class PwDatabaseV4 extends PwDatabase {
|
||||
public PwCompressionAlgorithm compressionAlgorithm;
|
||||
public long numKeyEncRounds;
|
||||
|
||||
@Override
|
||||
public byte[] getMasterKey(String key, String keyFileName)
|
||||
throws InvalidKeyFileException, IOException {
|
||||
assert( key != null && keyFileName != null );
|
||||
|
||||
byte[] fKey;
|
||||
|
||||
if ( key.length() > 0 && keyFileName.length() > 0 ) {
|
||||
return getCompositeKey(key, keyFileName);
|
||||
} else if ( key.length() > 0 ) {
|
||||
fKey = getPasswordKey(key);
|
||||
} else if ( keyFileName.length() > 0 ) {
|
||||
fKey = getFileKey(keyFileName);
|
||||
} else {
|
||||
throw new IllegalArgumentException( "Key cannot be empty." );
|
||||
}
|
||||
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("No SHA-256 implementation");
|
||||
}
|
||||
|
||||
return md.digest(fKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getPasswordKey(String key) throws IOException {
|
||||
return getPasswordKey(key, "UTF-8");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user