summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/CertOrEncCert.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cmp/CertOrEncCert.cs')
-rw-r--r--crypto/src/asn1/cmp/CertOrEncCert.cs9
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/src/asn1/cmp/CertOrEncCert.cs b/crypto/src/asn1/cmp/CertOrEncCert.cs
index d248de1aa..94df00006 100644
--- a/crypto/src/asn1/cmp/CertOrEncCert.cs
+++ b/crypto/src/asn1/cmp/CertOrEncCert.cs
@@ -26,17 +26,18 @@ namespace Org.BouncyCastle.Asn1.Cmp
 
 		private CertOrEncCert(Asn1TaggedObject taggedObject)
 		{
-			if (taggedObject.TagNo == 0)
+			if (taggedObject.HasContextTag(0))
 			{
 				m_certificate = CmpCertificate.GetInstance(taggedObject.GetExplicitBaseObject());
 			}
-			else if (taggedObject.TagNo == 1)
+			else if (taggedObject.HasContextTag(1))
 			{
                 m_encryptedCert = EncryptedKey.GetInstance(taggedObject.GetExplicitBaseObject());
 			}
 			else
 			{
-				throw new ArgumentException("unknown tag: " + taggedObject.TagNo, nameof(taggedObject));
+				throw new ArgumentException("unknown tag: " + Asn1Utilities.GetTagText(taggedObject),
+					nameof(taggedObject));
             }
         }
 
@@ -60,6 +61,8 @@ namespace Org.BouncyCastle.Asn1.Cmp
 
 		public virtual EncryptedKey EncryptedCert => m_encryptedCert;
 
+		public virtual bool HasEncryptedCertificate => m_encryptedCert != null;
+
         /**
 		 * <pre>
 		 * CertOrEncCert ::= CHOICE {