summary refs log tree commit diff
path: root/crypto/src/asn1/esf
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/esf')
-rw-r--r--crypto/src/asn1/esf/CrlIdentifier.cs43
1 files changed, 25 insertions, 18 deletions
diff --git a/crypto/src/asn1/esf/CrlIdentifier.cs b/crypto/src/asn1/esf/CrlIdentifier.cs
index 44c99170c..4a2480b4b 100644
--- a/crypto/src/asn1/esf/CrlIdentifier.cs
+++ b/crypto/src/asn1/esf/CrlIdentifier.cs
@@ -20,36 +20,38 @@ namespace Org.BouncyCastle.Asn1.Esf
 	public class CrlIdentifier
 		: Asn1Encodable
 	{
-		private readonly X509Name	crlIssuer;
+		private readonly X509Name crlIssuer;
 		private readonly Asn1UtcTime crlIssuedTime;
-		private readonly DerInteger	crlNumber;
+		private readonly DerInteger crlNumber;
 
-		public static CrlIdentifier GetInstance(
-			object obj)
+		public static CrlIdentifier GetInstance(object obj)
 		{
-			if (obj == null || obj is CrlIdentifier)
-				return (CrlIdentifier) obj;
+			if (obj == null)
+				return null;
 
-			if (obj is Asn1Sequence)
-				return new CrlIdentifier((Asn1Sequence) obj);
+			if (obj is CrlIdentifier crlIdentifier)
+                return crlIdentifier;
 
-			throw new ArgumentException(
-				"Unknown object in 'CrlIdentifier' factory: "
-                    + Platform.GetTypeName(obj),
-				"obj");
+			if (obj is Asn1Sequence asn1Sequence)
+				return new CrlIdentifier(asn1Sequence);
+
+			throw new ArgumentException("Unknown object in 'CrlIdentifier' factory: " + Platform.GetTypeName(obj),
+				nameof(obj));
 		}
 
-		private CrlIdentifier(
-			Asn1Sequence seq)
+		private CrlIdentifier(Asn1Sequence seq)
 		{
 			if (seq == null)
-				throw new ArgumentNullException("seq");
+				throw new ArgumentNullException(nameof(seq));
 			if (seq.Count < 2 || seq.Count > 3)
-				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
+				throw new ArgumentException("Bad sequence size: " + seq.Count, nameof(seq));
 
 			this.crlIssuer = X509Name.GetInstance(seq[0]);
 			this.crlIssuedTime = Asn1UtcTime.GetInstance(seq[1]);
 
+            // Validate crlIssuedTime is in the appropriate year range
+            crlIssuedTime.ToDateTime(2049);
+
 			if (seq.Count > 2)
 			{
 				this.crlNumber = DerInteger.GetInstance(seq[2]);
@@ -62,7 +64,7 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public CrlIdentifier(X509Name crlIssuer, DateTime crlIssuedTime, BigInteger crlNumber)
-			: this(crlIssuer, new Asn1UtcTime(crlIssuedTime), crlNumber)
+			: this(crlIssuer, new Asn1UtcTime(crlIssuedTime, 2049), crlNumber)
 		{
 		}
 
@@ -75,6 +77,11 @@ namespace Org.BouncyCastle.Asn1.Esf
         {
             if (crlIssuer == null)
                 throw new ArgumentNullException(nameof(crlIssuer));
+            if (crlIssuedTime == null)
+                throw new ArgumentNullException(nameof(crlIssuedTime));
+
+            // Validate crlIssuedTime is in the appropriate year range
+            crlIssuedTime.ToDateTime(2049);
 
             this.crlIssuer = crlIssuer;
             this.crlIssuedTime = crlIssuedTime;
@@ -92,7 +99,7 @@ namespace Org.BouncyCastle.Asn1.Esf
 
 		public DateTime CrlIssuedTime
 		{
-			get { return crlIssuedTime.ToAdjustedDateTime(); }
+			get { return crlIssuedTime.ToDateTime(2049); }
 		}
 
 		public BigInteger CrlNumber