summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/CertResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cmp/CertResponse.cs')
-rw-r--r--crypto/src/asn1/cmp/CertResponse.cs23
1 files changed, 10 insertions, 13 deletions
diff --git a/crypto/src/asn1/cmp/CertResponse.cs b/crypto/src/asn1/cmp/CertResponse.cs
index e70d6d388..ce3355270 100644
--- a/crypto/src/asn1/cmp/CertResponse.cs
+++ b/crypto/src/asn1/cmp/CertResponse.cs
@@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Asn1.Cmp
 
         public static CertResponse GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
         {
-            return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
+            return new CertResponse(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
         }
 
         private readonly DerInteger m_certReqId;
@@ -34,9 +34,9 @@ namespace Org.BouncyCastle.Asn1.Cmp
 				if (seq.Count == 3)
 				{
 					Asn1Encodable o = seq[2];
-					if (o is Asn1OctetString)
+					if (o is Asn1OctetString octetString)
 					{
-						m_rspInfo = Asn1OctetString.GetInstance(o);
+						m_rspInfo = octetString;
 					}
 					else
 					{
@@ -59,15 +59,9 @@ namespace Org.BouncyCastle.Asn1.Cmp
         public CertResponse(DerInteger certReqId, PkiStatusInfo status, CertifiedKeyPair certifiedKeyPair,
             Asn1OctetString rspInfo)
         {
-            if (certReqId == null)
-				throw new ArgumentNullException(nameof(certReqId));
-
-			if (status == null)
-				throw new ArgumentNullException(nameof(status));
-
-			m_certReqId = certReqId;
-			m_status = status;
-			m_certifiedKeyPair = certifiedKeyPair;
+			m_certReqId = certReqId ?? throw new ArgumentNullException(nameof(certReqId));
+			m_status = status ?? throw new ArgumentNullException(nameof(status));
+            m_certifiedKeyPair = certifiedKeyPair;
 			m_rspInfo = rspInfo;
 		}
 
@@ -77,6 +71,8 @@ namespace Org.BouncyCastle.Asn1.Cmp
 
 		public virtual CertifiedKeyPair CertifiedKeyPair => m_certifiedKeyPair;
 
+		public virtual Asn1OctetString RspInfo => m_rspInfo;
+
 		/**
 		 * <pre>
 		 * CertResponse ::= SEQUENCE {
@@ -95,7 +91,8 @@ namespace Org.BouncyCastle.Asn1.Cmp
 		 */
 		public override Asn1Object ToAsn1Object()
 		{
-			Asn1EncodableVector v = new Asn1EncodableVector(m_certReqId, m_status);
+			Asn1EncodableVector v = new Asn1EncodableVector(4);
+			v.Add(m_certReqId, m_status);
 			v.AddOptional(m_certifiedKeyPair, m_rspInfo);
 			return new DerSequence(v);
 		}