From 4119757699083889c8288960c7581a3060bd60c1 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 30 Jan 2014 11:35:55 +0000 Subject: bouncycastle uses the Date class, based off of UTC. Force all GregorianCalendars to use UTC, so get and set of key dates works as expected --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index eed0ed256..d6f130682 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -28,6 +28,7 @@ import java.security.SignatureException; import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; +import java.util.TimeZone; import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.HashAlgorithmTags; @@ -323,7 +324,7 @@ public class PgpKeyOperation { hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); if (keysExpiryDates.get(0) != null) { - GregorianCalendar creationDate = new GregorianCalendar(); + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); creationDate.setTime(masterPublicKey.getCreationTime()); GregorianCalendar expiryDate = keysExpiryDates.get(0); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c @@ -402,7 +403,7 @@ public class PgpKeyOperation { hashedPacketsGen.setKeyFlags(false, keyFlags); if (keysExpiryDates.get(i) != null) { - GregorianCalendar creationDate = new GregorianCalendar(); + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); creationDate.setTime(subPublicKey.getCreationTime()); GregorianCalendar expiryDate = keysExpiryDates.get(i); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c -- cgit v1.2.3