Successfully able to output the uneycrypted version of the database, and calculate SHA-256 checksum.

Needed to leave Meta-Stream entries in the PwManager, and ensure that nulls are included in string output.
This commit is contained in:
Brian Pellin
2009-04-26 13:26:08 -05:00
parent 1aabc01456
commit 0287413643
4 changed files with 11 additions and 10 deletions

View File

@@ -60,7 +60,7 @@ public class PwEntryOutput {
//byte[] title = mPE.title.getBytes("UTF-8");
mOS.write(TITLE_FIELD_TYPE);
Types.writeCString(mPE.title, mOS);
// URL
mOS.write(URL_FIELD_TYPE);
Types.writeCString(mPE.url, mOS);
@@ -75,11 +75,11 @@ public class PwEntryOutput {
mOS.write(Types.writeInt(password.length+1));
mOS.write(password);
mOS.write(0);
// Additional
mOS.write(ADDITIONAL_FIELD_TYPE);
Types.writeCString(mPE.additional, mOS);
// Create date
mOS.write(CREATE_FIELD_TYPE);
mOS.write(DATE_FIELD_SIZE);

View File

@@ -40,6 +40,7 @@ public class PwGroupOutput {
//NOTE: Need be to careful about using ints. The actual type written to file is a unsigned int
public void output() throws IOException {
// Group ID
mOS.write(GROUPID_FIELD_TYPE);
mOS.write(GROUPID_FIELD_SIZE);

View File

@@ -243,6 +243,7 @@ public class ImporterV3 {
}
// Keep the Meta-Info entry separate
/*
for( int i=0; i<newManager.entries.size(); i++) {
PwEntry ent = (PwEntry)newManager.entries.elementAt(i);
if( ent.title.equals( "Meta-Info" )
@@ -252,6 +253,7 @@ public class ImporterV3 {
newManager.entries.removeElementAt(i);
}
}
*/
return newManager;
}

View File

@@ -34,6 +34,7 @@ import junit.framework.TestCase;
import org.phoneid.keepassj2me.PwEntry;
import org.phoneid.keepassj2me.PwGroup;
import org.phoneid.keepassj2me.PwManager;
import org.phoneid.keepassj2me.Types;
import com.android.keepass.keepasslib.PwEntryOutput;
import com.android.keepass.keepasslib.PwGroupOutput;
@@ -61,19 +62,16 @@ public class PwGroupOutputTest extends TestCase {
// Entries
for (int i = 0; i < mPM.entries.size(); i++ ) {
boolean debug;
PwEntry pe = mPM.entries.get(i);
PwEntryOutput peo = new PwEntryOutput(pe, bos);
debug = (i == 1);
peo.output();
}
Calendar cal = Calendar.getInstance();
cal.setTime(mPM.groups.get(1).tCreation);
byte[] buf = bos.toByteArray();
for (int i = 0; i < buf.length; i++) {
assertEquals("Buf31: " + mPM.postHeader[31] + " Buf32: " + mPM.postHeader[32] + "Buf33: " + mPM.postHeader[33] + " Year: " + cal.get(Calendar.YEAR) + " Month: " + cal.get(Calendar.MONTH) + " Difference at byte " + i, mPM.postHeader[i], buf[i]);
}
//assertArrayEquals(mPM.postHeader, bos.toByteArray());
assertArrayEquals(mPM.postHeader, bos.toByteArray());
}