summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2015-04-10 09:23:11 -0400
committerJeffrey Stedfast <jeff@xamarin.com>2015-04-10 09:23:11 -0400
commit902205f5ff9d9fcc1e76230a58dbcf728fe982cd (patch)
tree03fd2b371c8f3ee8f871acdb322805684967edf6
parentUpdated Visual Studio 2010 project files (diff)
parentUpdate version to 1.8.0-RC.1 prior to release (diff)
downloadBouncyCastle.NET-ed25519-902205f5ff9d9fcc1e76230a58dbcf728fe982cd.tar.xz
Merge branch 'master' into vs2010
-rw-r--r--crypto/NBuild.build2
-rw-r--r--crypto/src/openpgp/PgpPublicKey.cs47
2 files changed, 27 insertions, 22 deletions
diff --git a/crypto/NBuild.build b/crypto/NBuild.build
index eada08eee..64ea07545 100644
--- a/crypto/NBuild.build
+++ b/crypto/NBuild.build
@@ -16,7 +16,7 @@
   <property name="dist-path" value="./dist"/>
 
   <!-- Version -->
-  <property name="version" value="1.8.0-beta.5"/>
+  <property name="version" value="1.8.0-RC.1"/>
   <property name="name" value="BouncyCastle.Crypto"/>
 
   <property name="OPTIONAL_STRONG_NAME" value="" />
diff --git a/crypto/src/openpgp/PgpPublicKey.cs b/crypto/src/openpgp/PgpPublicKey.cs
index c6b2e9e0e..249b94ea6 100644
--- a/crypto/src/openpgp/PgpPublicKey.cs
+++ b/crypto/src/openpgp/PgpPublicKey.cs
@@ -266,16 +266,23 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
         }
 
         /// <summary>The number of valid days from creation time - zero means no expiry.</summary>
+        /// <remarks>WARNING: This method will return 1 for keys with version > 3 that expire in less than 1 day</remarks>
+        [Obsolete("Use 'GetValidSeconds' instead")]
         public int ValidDays
         {
             get
             {
-                if (publicPk.Version > 3)
+                if (publicPk.Version <= 3)
                 {
-                    return (int)(GetValidSeconds() / (24 * 60 * 60));
+                    return publicPk.ValidDays;
                 }
 
-                return publicPk.ValidDays;
+                long expSecs = GetValidSeconds();
+                if (expSecs <= 0)
+                    return 0;
+
+                int days = (int)(expSecs / (24 * 60 * 60));
+                return System.Math.Max(1, days);
             }
         }
 
@@ -294,34 +301,32 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
         /// <summary>The number of valid seconds from creation time - zero means no expiry.</summary>
         public long GetValidSeconds()
         {
-            if (publicPk.Version > 3)
+            if (publicPk.Version <= 3)
             {
-                if (IsMasterKey)
-                {
-                    for (int i = 0; i != MasterKeyCertificationTypes.Length; i++)
-                    {
-                        long seconds = GetExpirationTimeFromSig(true, MasterKeyCertificationTypes[i]);
+                return (long)publicPk.ValidDays * (24 * 60 * 60);
+            }
 
-                        if (seconds >= 0)
-                        {
-                            return seconds;
-                        }
-                    }
-                }
-                else
+            if (IsMasterKey)
+            {
+                for (int i = 0; i != MasterKeyCertificationTypes.Length; i++)
                 {
-                    long seconds = GetExpirationTimeFromSig(false, PgpSignature.SubkeyBinding);
-
+                    long seconds = GetExpirationTimeFromSig(true, MasterKeyCertificationTypes[i]);
                     if (seconds >= 0)
                     {
                         return seconds;
                     }
                 }
-
-                return 0;
+            }
+            else
+            {
+                long seconds = GetExpirationTimeFromSig(false, PgpSignature.SubkeyBinding);
+                if (seconds >= 0)
+                {
+                    return seconds;
+                }
             }
 
-            return (long) publicPk.ValidDays * 24 * 60 * 60;
+            return 0;
         }
 
         private long GetExpirationTimeFromSig(