summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@gmail.com>2022-06-22 01:40:55 +0700
committerPeter Dettman <peter.dettman@gmail.com>2022-06-22 01:40:55 +0700
commit892dbe845c98ff3fad3d682aaed3cd40b3161d4f (patch)
tree785ea8dc92cde60b6c06d5f56f6c3f0cda69bb2c /crypto/src/asn1
parentCleanup old build systems (diff)
downloadBouncyCastle.NET-ed25519-892dbe845c98ff3fad3d682aaed3cd40b3161d4f.tar.xz
ObsoleteAttribute cleanup
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/ASN1TaggedObjectParser.cs4
-rw-r--r--crypto/src/asn1/Asn1TaggedObject.cs14
-rw-r--r--crypto/src/asn1/BERTaggedObjectParser.cs9
-rw-r--r--crypto/src/asn1/DERExternal.cs3
-rw-r--r--crypto/src/asn1/DERExternalParser.cs11
-rw-r--r--crypto/src/asn1/cms/AuthEnvelopedDataParser.cs23
-rw-r--r--crypto/src/asn1/cms/AuthenticatedDataParser.cs38
-rw-r--r--crypto/src/asn1/cms/EncryptedContentInfoParser.cs2
-rw-r--r--crypto/src/asn1/cms/EnvelopedDataParser.cs18
-rw-r--r--crypto/src/asn1/cms/SignedDataParser.cs28
-rw-r--r--crypto/src/asn1/esf/SignerLocation.cs12
-rw-r--r--crypto/src/asn1/x509/UserNotice.cs13
12 files changed, 66 insertions, 109 deletions
diff --git a/crypto/src/asn1/ASN1TaggedObjectParser.cs b/crypto/src/asn1/ASN1TaggedObjectParser.cs
index 68b83f290..0b53b6abf 100644
--- a/crypto/src/asn1/ASN1TaggedObjectParser.cs
+++ b/crypto/src/asn1/ASN1TaggedObjectParser.cs
@@ -15,10 +15,6 @@ namespace Org.BouncyCastle.Asn1
         bool HasTag(int tagClass, int tagNo);
 
         /// <exception cref="IOException"/>
-        [Obsolete("Use 'Parse...' methods instead, after checking this parser's TagClass and TagNo")]
-        IAsn1Convertible GetObjectParser(int tag, bool isExplicit);
-
-        /// <exception cref="IOException"/>
         IAsn1Convertible ParseBaseUniversal(bool declaredExplicit, int baseTagNo);
 
         /// <summary>Needed for open types, until we have better type-guided parsing support.</summary>
diff --git a/crypto/src/asn1/Asn1TaggedObject.cs b/crypto/src/asn1/Asn1TaggedObject.cs
index f2eca9ad8..f2bf0cfe1 100644
--- a/crypto/src/asn1/Asn1TaggedObject.cs
+++ b/crypto/src/asn1/Asn1TaggedObject.cs
@@ -299,20 +299,6 @@ namespace Org.BouncyCastle.Asn1
             }
         }
 
-        /**
-		* Return the object held in this tagged object as a parser assuming it has
-		* the type of the passed in tag. If the object doesn't have a parser
-		* associated with it, the base object is returned.
-		*/
-        [Obsolete("Use 'Parse...' methods instead, after checking this parser's TagClass and TagNo")]
-        public IAsn1Convertible GetObjectParser(int tag, bool isExplicit)
-		{
-            if (Asn1Tags.ContextSpecific != TagClass)
-                throw new InvalidOperationException("this method only valid for CONTEXT_SPECIFIC tags");
-
-            return ParseBaseUniversal(isExplicit, tag);
-		}
-
         public IAsn1Convertible ParseBaseUniversal(bool declaredExplicit, int baseTagNo)
         {
             Asn1Object asn1Object = GetBaseUniversal(declaredExplicit, baseTagNo);
diff --git a/crypto/src/asn1/BERTaggedObjectParser.cs b/crypto/src/asn1/BERTaggedObjectParser.cs
index 522e0d22b..ecb4a4a13 100644
--- a/crypto/src/asn1/BERTaggedObjectParser.cs
+++ b/crypto/src/asn1/BERTaggedObjectParser.cs
@@ -42,15 +42,6 @@ namespace Org.BouncyCastle.Asn1
             return m_tagClass == tagClass && m_tagNo == tagNo;
         }
 
-        [Obsolete("Use 'Parse...' methods instead, after checking this parser's TagClass and TagNo")]
-        public IAsn1Convertible GetObjectParser(int baseTagNo, bool declaredExplicit)
-		{
-            if (Asn1Tags.ContextSpecific != TagClass)
-                throw new Asn1Exception("this method only valid for CONTEXT_SPECIFIC tags");
-
-            return ParseBaseUniversal(declaredExplicit, baseTagNo);
-		}
-
         public virtual IAsn1Convertible ParseBaseUniversal(bool declaredExplicit, int baseTagNo)
         {
             if (declaredExplicit)
diff --git a/crypto/src/asn1/DERExternal.cs b/crypto/src/asn1/DERExternal.cs
index cc3d2435f..1806b5296 100644
--- a/crypto/src/asn1/DERExternal.cs
+++ b/crypto/src/asn1/DERExternal.cs
@@ -61,13 +61,12 @@ namespace Org.BouncyCastle.Asn1
 		private readonly int encoding;
 		private readonly Asn1Object externalContent;
 
-        [Obsolete("Use constructor taking an Asn1Sequence instead.")]
         public DerExternal(Asn1EncodableVector vector)
             : this(new DerSequence(vector))
         {
         }
 
-        public DerExternal(DerSequence sequence)
+        public DerExternal(Asn1Sequence sequence)
 		{
 			int offset = 0;
 
diff --git a/crypto/src/asn1/DERExternalParser.cs b/crypto/src/asn1/DERExternalParser.cs
index 5e52e63c6..cb5e0d8b6 100644
--- a/crypto/src/asn1/DERExternalParser.cs
+++ b/crypto/src/asn1/DERExternalParser.cs
@@ -5,22 +5,21 @@ namespace Org.BouncyCastle.Asn1
 	public class DerExternalParser
 		: Asn1Encodable
 	{
-		private readonly Asn1StreamParser _parser;
+		private readonly Asn1StreamParser m_parser;
 
-        [Obsolete("Will be removed")]
-		public DerExternalParser(Asn1StreamParser parser)
+		internal DerExternalParser(Asn1StreamParser parser)
 		{
-			this._parser = parser;
+			m_parser = parser;
 		}
 
 		public IAsn1Convertible ReadObject()
 		{
-			return _parser.ReadObject();
+			return m_parser.ReadObject();
 		}
 
 		public override Asn1Object ToAsn1Object()
 		{
-            return Parse(_parser);
+            return Parse(m_parser);
 		}
 
         internal static DerExternal Parse(Asn1StreamParser sp)
diff --git a/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs b/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs
index 1e1e72c02..e61754e65 100644
--- a/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs
+++ b/crypto/src/asn1/cms/AuthEnvelopedDataParser.cs
@@ -49,11 +49,14 @@ namespace Org.BouncyCastle.Asn1.Cms
 				nextObject = seq.ReadObject();
 			}
 
-			if (nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)nextObject).TagNo == 0)
+			if (nextObject is Asn1TaggedObjectParser o)
 			{
-				Asn1SequenceParser originatorInfo = (Asn1SequenceParser) ((Asn1TaggedObjectParser)nextObject).GetObjectParser(Asn1Tags.Sequence, false);
-				nextObject = null;
-				return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
+				if (o.HasContextTag(0))
+				{
+					Asn1SequenceParser originatorInfo = (Asn1SequenceParser)o.ParseBaseUniversal(false, Asn1Tags.Sequence);
+					nextObject = null;
+					return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
+				}
 			}
 
 			return null;
@@ -102,15 +105,13 @@ namespace Org.BouncyCastle.Asn1.Cms
 				nextObject = seq.ReadObject();
 			}
 
-			if (nextObject is Asn1TaggedObjectParser)
+			if (nextObject is Asn1TaggedObjectParser o)
 			{
-				IAsn1Convertible o = nextObject;
 				nextObject = null;
-				return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
+				return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 1, false, Asn1Tags.SetOf);
 			}
 
-			// "The authAttrs MUST be present if the content type carried in
-			// EncryptedContentInfo is not id-data."
+			// "The authAttrs MUST be present if the content type carried in EncryptedContentInfo is not id-data."
 			if (!isData)
 				throw new Asn1ParsingException("authAttrs must be present with non-data content");
 
@@ -139,9 +140,9 @@ namespace Org.BouncyCastle.Asn1.Cms
 
 			if (nextObject != null)
 			{
-				IAsn1Convertible o = nextObject;
+				Asn1TaggedObjectParser o = (Asn1TaggedObjectParser)nextObject;
 				nextObject = null;
-				return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
+				return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 2, false, Asn1Tags.SetOf);
 			}
 
 			return null;
diff --git a/crypto/src/asn1/cms/AuthenticatedDataParser.cs b/crypto/src/asn1/cms/AuthenticatedDataParser.cs
index 4b80d1b02..54dee99e8 100644
--- a/crypto/src/asn1/cms/AuthenticatedDataParser.cs
+++ b/crypto/src/asn1/cms/AuthenticatedDataParser.cs
@@ -53,12 +53,15 @@ namespace Org.BouncyCastle.Asn1.Cms
 	            nextObject = seq.ReadObject();
 	        }
 
-	        if (nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)nextObject).TagNo == 0)
-	        {
-	            Asn1SequenceParser originatorInfo = (Asn1SequenceParser) ((Asn1TaggedObjectParser)nextObject).GetObjectParser(Asn1Tags.Sequence, false);
-	            nextObject = null;
-	            return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
-	        }
+			if (nextObject is Asn1TaggedObjectParser o)
+			{
+				if (o.HasContextTag(0))
+				{
+					Asn1SequenceParser originatorInfo = (Asn1SequenceParser)o.ParseBaseUniversal(false, Asn1Tags.Sequence);
+					nextObject = null;
+					return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
+				}
+			}
 
 	        return null;
 	    }
@@ -139,12 +142,11 @@ namespace Org.BouncyCastle.Asn1.Cms
 	            nextObject = seq.ReadObject();
 	        }
 
-	        if (nextObject is Asn1TaggedObjectParser)
-	        {
-	            IAsn1Convertible o = nextObject;
-	            nextObject = null;
-	            return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
-	        }
+			if (nextObject is Asn1TaggedObjectParser o)
+			{
+				nextObject = null;
+				return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 2, false, Asn1Tags.SetOf);
+			}
 
 	        return null;
 	    }
@@ -169,12 +171,12 @@ namespace Org.BouncyCastle.Asn1.Cms
 	            nextObject = seq.ReadObject();
 	        }
 
-	        if (nextObject != null)
-	        {
-	            IAsn1Convertible o = nextObject;
-	            nextObject = null;
-	            return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
-	        }
+			if (nextObject != null)
+			{
+				Asn1TaggedObject o = (Asn1TaggedObject)nextObject;
+				nextObject = null;
+				return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 3, false, Asn1Tags.SetOf);
+			}
 
 	        return null;
 	    }
diff --git a/crypto/src/asn1/cms/EncryptedContentInfoParser.cs b/crypto/src/asn1/cms/EncryptedContentInfoParser.cs
index af748b1b3..09434d7ef 100644
--- a/crypto/src/asn1/cms/EncryptedContentInfoParser.cs
+++ b/crypto/src/asn1/cms/EncryptedContentInfoParser.cs
@@ -40,7 +40,7 @@ namespace Org.BouncyCastle.Asn1.Cms
 		public IAsn1Convertible GetEncryptedContent(
 			int tag)
 		{
-			return _encryptedContent.GetObjectParser(tag, false);
+			return Asn1Utilities.ParseContextBaseUniversal(_encryptedContent, 0, false, tag);
 		}
 	}
 }
diff --git a/crypto/src/asn1/cms/EnvelopedDataParser.cs b/crypto/src/asn1/cms/EnvelopedDataParser.cs
index 599353791..a86608bb4 100644
--- a/crypto/src/asn1/cms/EnvelopedDataParser.cs
+++ b/crypto/src/asn1/cms/EnvelopedDataParser.cs
@@ -42,12 +42,14 @@ namespace Org.BouncyCastle.Asn1.Cms
 				_nextObject = _seq.ReadObject();
 			}
 
-			if (_nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)_nextObject).TagNo == 0)
+			if (_nextObject is Asn1TaggedObjectParser o)
 			{
-				Asn1SequenceParser originatorInfo = (Asn1SequenceParser)
-					((Asn1TaggedObjectParser)_nextObject).GetObjectParser(Asn1Tags.Sequence, false);
-				_nextObject = null;
-				return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
+				if (o.HasContextTag(0))
+				{
+					Asn1SequenceParser originatorInfo = (Asn1SequenceParser)o.ParseBaseUniversal(false, Asn1Tags.Sequence);
+					_nextObject = null;
+					return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
+				}
 			}
 
 			return null;
@@ -96,11 +98,11 @@ namespace Org.BouncyCastle.Asn1.Cms
 
 			if (_nextObject != null)
 			{
-				IAsn1Convertible o = _nextObject;
+				Asn1TaggedObjectParser o = (Asn1TaggedObjectParser)_nextObject;
 				_nextObject = null;
-				return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
+				return (Asn1SetParser)Asn1Utilities.ParseContextBaseUniversal(o, 1, false, Asn1Tags.SetOf);
 			}
-        
+
 			return null;
 		}
 	}
diff --git a/crypto/src/asn1/cms/SignedDataParser.cs b/crypto/src/asn1/cms/SignedDataParser.cs
index cd07f4057..64114f292 100644
--- a/crypto/src/asn1/cms/SignedDataParser.cs
+++ b/crypto/src/asn1/cms/SignedDataParser.cs
@@ -64,12 +64,14 @@ namespace Org.BouncyCastle.Asn1.Cms
 			_certsCalled = true;
 			_nextObject = _seq.ReadObject();
 
-			if (_nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)_nextObject).TagNo == 0)
+			if (_nextObject is Asn1TaggedObjectParser o)
 			{
-				Asn1SetParser certs = (Asn1SetParser)((Asn1TaggedObjectParser)_nextObject).GetObjectParser(Asn1Tags.Set, false);
-				_nextObject = null;
-
-				return certs;
+				if (o.HasContextTag(0))
+				{
+					Asn1SetParser certs = (Asn1SetParser)o.ParseBaseUniversal(false, Asn1Tags.SetOf);
+					_nextObject = null;
+					return certs;
+				}
 			}
 
 			return null;
@@ -87,16 +89,18 @@ namespace Org.BouncyCastle.Asn1.Cms
 				_nextObject = _seq.ReadObject();
 			}
 
-			if (_nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)_nextObject).TagNo == 1)
+			if (_nextObject is Asn1TaggedObjectParser o)
 			{
-				Asn1SetParser crls = (Asn1SetParser)((Asn1TaggedObjectParser)_nextObject).GetObjectParser(Asn1Tags.Set, false);
-				_nextObject = null;
-
-				return crls;
+				if (o.HasContextTag(1))
+				{
+					Asn1SetParser crls = (Asn1SetParser)o.ParseBaseUniversal(false, Asn1Tags.SetOf);
+					_nextObject = null;
+					return crls;
+				}
 			}
 
-			return null;
-		}
+            return null;
+        }
 
 		public Asn1SetParser GetSignerInfos()
 		{
diff --git a/crypto/src/asn1/esf/SignerLocation.cs b/crypto/src/asn1/esf/SignerLocation.cs
index 0095c0e5c..4c82d09fd 100644
--- a/crypto/src/asn1/esf/SignerLocation.cs
+++ b/crypto/src/asn1/esf/SignerLocation.cs
@@ -113,18 +113,6 @@ namespace Org.BouncyCastle.Asn1.Esf
             return dirStrings;
         }
 
-        [Obsolete("Use 'Country' property instead")]
-		public DerUtf8String CountryName
-		{
-            get { return countryName == null ? null : new DerUtf8String(countryName.GetString()); }
-		}
-
-        [Obsolete("Use 'Locality' property instead")]
-        public DerUtf8String LocalityName
-        {
-            get { return localityName == null ? null : new DerUtf8String(localityName.GetString()); }
-        }
-
 		public Asn1Sequence PostalAddress
 		{
 			get { return postalAddress; }
diff --git a/crypto/src/asn1/x509/UserNotice.cs b/crypto/src/asn1/x509/UserNotice.cs
index 6311c7693..801ca0ded 100644
--- a/crypto/src/asn1/x509/UserNotice.cs
+++ b/crypto/src/asn1/x509/UserNotice.cs
@@ -49,18 +49,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-        /**
-         * Creates a new <code>UserNotice</code> instance.
-         * <p>Useful from reconstructing a <code>UserNotice</code> instance
-         * from its encodable/encoded form.
-         *
-         * @param as an <code>ASN1Sequence</code> value obtained from either
-         * calling @{link toASN1Object()} for a <code>UserNotice</code>
-         * instance or from parsing it from a DER-encoded stream.</p>
-         */
-        [Obsolete("Use GetInstance() instead")]
-        public UserNotice(
-            Asn1Sequence seq)
+        private UserNotice(Asn1Sequence seq)
         {
             if (seq.Count == 2)
             {