warn on signature earlier than key creation, err on significantly earlier

This commit is contained in:
Vincent Breitmoser
2015-05-28 11:40:35 +02:00
parent 5c8af1c5a5
commit eb830c6786
3 changed files with 23 additions and 0 deletions

View File

@@ -820,6 +820,15 @@ public class UncachedKeyRing {
continue;
}
Date keyCreationTime = key.getCreationTime(), keyCreationTimeLenient;
{
Calendar keyCreationCal = Calendar.getInstance();
keyCreationCal.setTime(keyCreationTime);
// allow for diverging clocks up to one day when checking creation time
keyCreationCal.add(Calendar.MINUTE, -5);
keyCreationTimeLenient = keyCreationCal.getTime();
}
// A subkey needs exactly one subkey binding certificate, and optionally one revocation
// certificate.
PGPPublicKey modified = key;
@@ -851,6 +860,18 @@ public class UncachedKeyRing {
continue;
}
if (cert.getCreationTime().before(keyCreationTime)) {
// Signature is earlier than key creation time
log.add(LogType.MSG_KC_SUB_BAD_TIME_EARLY, indent);
// due to an earlier accident, we generated keys which had creation timestamps
// a few seconds after their signature timestamp. for compatibility, we only
// error out with some margin of error
if (cert.getCreationTime().before(keyCreationTimeLenient)) {
badCerts += 1;
continue;
}
}
if (cert.isLocal()) {
// Creation date in the future? No way!
log.add(LogType.MSG_KC_SUB_BAD_LOCAL, indent);