summary refs log tree commit diff
path: root/crypto/src/asn1/crmf/CertId.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/crmf/CertId.cs')
-rw-r--r--crypto/src/asn1/crmf/CertId.cs18
1 files changed, 15 insertions, 3 deletions
diff --git a/crypto/src/asn1/crmf/CertId.cs b/crypto/src/asn1/crmf/CertId.cs
index c63c21ca8..c9f66b065 100644
--- a/crypto/src/asn1/crmf/CertId.cs
+++ b/crypto/src/asn1/crmf/CertId.cs
@@ -1,4 +1,6 @@
-using Org.BouncyCastle.Asn1.X509;
+using System;
+
+using Org.BouncyCastle.Asn1.X509;
 
 namespace Org.BouncyCastle.Asn1.Crmf
 {
@@ -9,8 +11,8 @@ namespace Org.BouncyCastle.Asn1.Crmf
         {
             if (obj == null)
                 return null;
-            if (obj is CertId certID)
-                return certID;
+            if (obj is CertId certId)
+                return certId;
             return new CertId(Asn1Sequence.GetInstance(obj));
         }
 
@@ -24,10 +26,20 @@ namespace Org.BouncyCastle.Asn1.Crmf
 
         private CertId(Asn1Sequence seq)
         {
+            int count = seq.Count;
+            if (count != 2)
+                throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
+
             m_issuer = GeneralName.GetInstance(seq[0]);
             m_serialNumber = DerInteger.GetInstance(seq[1]);
         }
 
+        public CertId(GeneralName issuer, DerInteger serialNumber)
+        {
+            m_issuer = issuer ?? throw new ArgumentNullException(nameof(issuer));
+            m_serialNumber = serialNumber ?? throw new ArgumentNullException(nameof(serialNumber));
+        }
+
         public virtual GeneralName Issuer => m_issuer;
 
         public virtual DerInteger SerialNumber => m_serialNumber;