Pick the right root node to parse.

This commit is contained in:
Brian Pellin
2010-05-24 00:02:14 -05:00
parent d78f900fcd
commit bd7f48e0e7
2 changed files with 3 additions and 6 deletions

View File

@@ -93,7 +93,7 @@ public class PwDatabaseV4 extends PwDatabase {
throw new InconsistentDBException("Missing root node"); throw new InconsistentDBException("Missing root node");
} }
Node root = list.item(1); Node root = list.item(0);
rootGroup = new PwGroupV4(root); rootGroup = new PwGroupV4(root);
} }

View File

@@ -67,14 +67,11 @@ public class ImporterV4 extends Importer {
InvalidKeyFileException, InvalidPasswordException, InvalidKeyFileException, InvalidPasswordException,
InvalidDBSignatureException, InvalidDBVersionException { InvalidDBSignatureException, InvalidDBVersionException {
// TODO: Measure whether this buffer is better or worse for performance
BufferedInputStream bis = new BufferedInputStream(inStream);
PwDatabaseV4 db = new PwDatabaseV4(); PwDatabaseV4 db = new PwDatabaseV4();
PwDbHeaderV4 header = new PwDbHeaderV4(db); PwDbHeaderV4 header = new PwDbHeaderV4(db);
header.loadFromFile(bis); header.loadFromFile(inStream);
db.setMasterKey(password, keyfile); db.setMasterKey(password, keyfile);
db.makeFinalKey(header.masterSeed, header.transformSeed, (int)db.numKeyEncRounds); db.makeFinalKey(header.masterSeed, header.transformSeed, (int)db.numKeyEncRounds);
@@ -93,7 +90,7 @@ public class ImporterV4 extends Importer {
throw new IOException("Invalid algorithm."); throw new IOException("Invalid algorithm.");
} }
InputStream decrypted = new BetterCipherInputStream(bis, cipher, 50 * 1024); InputStream decrypted = new BetterCipherInputStream(inStream, cipher, 50 * 1024);
LEDataInputStream dataDecrypted = new LEDataInputStream(decrypted); LEDataInputStream dataDecrypted = new LEDataInputStream(decrypted);
byte[] storedStartBytes = dataDecrypted.readBytes(32); byte[] storedStartBytes = dataDecrypted.readBytes(32);
if ( storedStartBytes == null || storedStartBytes.length != 32 ) { if ( storedStartBytes == null || storedStartBytes.length != 32 ) {