Merge pull request #233 from ashh87/expiry

change key expiry
This commit is contained in:
Dominik Schürmann 2014-01-30 00:03:42 -08:00
commit 39d24d6d9d
2 changed files with 29 additions and 26 deletions

View File

@ -322,20 +322,20 @@ public class PgpKeyOperation {
hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS);
hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS);
// TODO: Now use keysExpiryDates here!!! (and some lines below) if (keysExpiryDates.get(0) != null) {
GregorianCalendar creationDate = new GregorianCalendar();
// TODO: this doesn't work quite right yet (APG 1) creationDate.setTime(masterPublicKey.getCreationTime());
// if (keyEditor.getExpiryDate() != null) { GregorianCalendar expiryDate = keysExpiryDates.get(0);
// GregorianCalendar creationDate = new GregorianCalendar(); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
// creationDate.setTime(getCreationDate(masterKey)); //here we purposefully ignore partial days in each date - long type has no fractional part!
// GregorianCalendar expiryDate = keyEditor.getExpiryDate(); long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
// long numDays = Utils.getNumDaysBetween(creationDate, expiryDate); if (numDays <= 0)
// if (numDays <= 0) { throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation));
// throw new GeneralException( hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
// context.getString(R.string.error_expiryMustComeAfterCreation)); } else {
// } hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
// hashedPacketsGen.setKeyExpirationTime(true, numDays * 86400); //this happens anyway
// } }
updateProgress(R.string.progress_building_master_key, 30, 100); updateProgress(R.string.progress_building_master_key, 30, 100);
@ -396,18 +396,20 @@ public class PgpKeyOperation {
} }
hashedPacketsGen.setKeyFlags(false, keyFlags); hashedPacketsGen.setKeyFlags(false, keyFlags);
// TODO: this doesn't work quite right yet (APG 1) if (keysExpiryDates.get(i) != null) {
// if (keyEditor.getExpiryDate() != null) { GregorianCalendar creationDate = new GregorianCalendar();
// GregorianCalendar creationDate = new GregorianCalendar(); creationDate.setTime(subPublicKey.getCreationTime());
// creationDate.setTime(getCreationDate(masterKey)); GregorianCalendar expiryDate = keysExpiryDates.get(i);
// GregorianCalendar expiryDate = keyEditor.getExpiryDate(); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
// long numDays = Utils.getNumDaysBetween(creationDate, expiryDate); //here we purposefully ignore partial days in each date - long type has no fractional part!
// if (numDays <= 0) { long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
// throw new GeneralException( if (numDays <= 0)
// context.getString(R.string.error_expiryMustComeAfterCreation)); throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation));
// } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400);
// hashedPacketsGen.setKeyExpirationTime(true, numDays * 86400); } else {
// } hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding,
//this happens anyway
}
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
} }

View File

@ -280,6 +280,7 @@
<string name="error_jelly_bean_needed">You need Android 4.1 alias Jelly Bean to use Androids NFC Beam feature!</string> <string name="error_jelly_bean_needed">You need Android 4.1 alias Jelly Bean to use Androids NFC Beam feature!</string>
<string name="error_nfc_needed">NFC is not available on your device!</string> <string name="error_nfc_needed">NFC is not available on your device!</string>
<string name="error_nothing_import">Nothing to import!</string> <string name="error_nothing_import">Nothing to import!</string>
<string name="error_expiry_must_come_after_creation">expiry date must come after creation date</string>
<!-- progress dialogs, usually ending in '…' --> <!-- progress dialogs, usually ending in '…' -->
<string name="progress_done">done.</string> <string name="progress_done">done.</string>