summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-10-14 13:03:27 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-10-14 13:03:27 +0700
commitcbf1038241e3a2b895813ccee83d559525b01630 (patch)
tree385fedc4e1614ae0c87324a2caa04a084b0bc09c
parentASN.1 Obsolete cleanup (diff)
downloadBouncyCastle.NET-ed25519-cbf1038241e3a2b895813ccee83d559525b01630.tar.xz
Obsolete BerOutputStream
-rw-r--r--crypto/src/asn1/Asn1OutputStream.cs5
-rw-r--r--crypto/src/asn1/BERBitString.cs5
-rw-r--r--crypto/src/asn1/BERGenerator.cs4
-rw-r--r--crypto/src/asn1/BerNull.cs2
-rw-r--r--crypto/src/asn1/BerOctetString.cs2
-rw-r--r--crypto/src/asn1/BerOutputStream.cs7
-rw-r--r--crypto/src/asn1/BerSequence.cs2
-rw-r--r--crypto/src/asn1/BerSet.cs2
-rw-r--r--crypto/src/asn1/BerTaggedObject.cs4
-rw-r--r--crypto/src/asn1/DerOutputStream.cs19
-rw-r--r--crypto/src/pkcs/Pkcs12Store.cs2
11 files changed, 34 insertions, 20 deletions
diff --git a/crypto/src/asn1/Asn1OutputStream.cs b/crypto/src/asn1/Asn1OutputStream.cs
index 9ed3fbe4a..ffbe5c05d 100644
--- a/crypto/src/asn1/Asn1OutputStream.cs
+++ b/crypto/src/asn1/Asn1OutputStream.cs
@@ -10,5 +10,10 @@ namespace Org.BouncyCastle.Asn1
             : base(os)
         {
         }
+
+        internal override bool IsBer
+        {
+            get { return true; }
+        }
     }
 }
diff --git a/crypto/src/asn1/BERBitString.cs b/crypto/src/asn1/BERBitString.cs
index d8cd00330..4ee52d9f8 100644
--- a/crypto/src/asn1/BERBitString.cs
+++ b/crypto/src/asn1/BERBitString.cs
@@ -27,10 +27,9 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-        internal override void Encode(
-            DerOutputStream derOut)
+        internal override void Encode(DerOutputStream derOut)
         {
-            if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+            if (derOut.IsBer)
             {
                 derOut.WriteEncoded(Asn1Tags.BitString, (byte)mPadBits, mData);
             }
diff --git a/crypto/src/asn1/BERGenerator.cs b/crypto/src/asn1/BERGenerator.cs
index ad72e7a31..f5465b756 100644
--- a/crypto/src/asn1/BERGenerator.cs
+++ b/crypto/src/asn1/BERGenerator.cs
@@ -31,13 +31,13 @@ namespace Org.BouncyCastle.Asn1
 		public override void AddObject(
 			Asn1Encodable obj)
 		{
-			new BerOutputStream(Out).WriteObject(obj);
+			new Asn1OutputStream(Out).WriteObject(obj);
 		}
 
         public override void AddObject(
             Asn1Object obj)
         {
-            new BerOutputStream(Out).WriteObject(obj);
+            new Asn1OutputStream(Out).WriteObject(obj);
         }
 
         public override Stream GetRawOutputStream()
diff --git a/crypto/src/asn1/BerNull.cs b/crypto/src/asn1/BerNull.cs
index cf669914b..8df088d0c 100644
--- a/crypto/src/asn1/BerNull.cs
+++ b/crypto/src/asn1/BerNull.cs
@@ -17,7 +17,7 @@ namespace Org.BouncyCastle.Asn1
 
 		internal override void Encode(DerOutputStream derOut)
 		{
-			if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+            if (derOut.IsBer)
 			{
 				derOut.WriteByte(Asn1Tags.Null);
 			}
diff --git a/crypto/src/asn1/BerOctetString.cs b/crypto/src/asn1/BerOctetString.cs
index 3085f3569..1478488a6 100644
--- a/crypto/src/asn1/BerOctetString.cs
+++ b/crypto/src/asn1/BerOctetString.cs
@@ -124,7 +124,7 @@ namespace Org.BouncyCastle.Asn1
         internal override void Encode(
             DerOutputStream derOut)
         {
-            if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+            if (derOut.IsBer)
             {
                 derOut.WriteByte(Asn1Tags.Constructed | Asn1Tags.OctetString);
 
diff --git a/crypto/src/asn1/BerOutputStream.cs b/crypto/src/asn1/BerOutputStream.cs
index 4ed28d8f3..98c9dd7f8 100644
--- a/crypto/src/asn1/BerOutputStream.cs
+++ b/crypto/src/asn1/BerOutputStream.cs
@@ -3,7 +3,7 @@ using System.IO;
 
 namespace Org.BouncyCastle.Asn1
 {
-	// TODO Make Obsolete in favour of Asn1OutputStream?
+    [Obsolete("Use 'Asn1OutputStream' instead")]
     public class BerOutputStream
         : DerOutputStream
     {
@@ -11,5 +11,10 @@ namespace Org.BouncyCastle.Asn1
             : base(os)
         {
         }
+
+        internal override bool IsBer
+        {
+            get { return true; }
+        }
     }
 }
diff --git a/crypto/src/asn1/BerSequence.cs b/crypto/src/asn1/BerSequence.cs
index ccff73c37..30c44b651 100644
--- a/crypto/src/asn1/BerSequence.cs
+++ b/crypto/src/asn1/BerSequence.cs
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Asn1
 
         internal override void Encode(DerOutputStream derOut)
 		{
-			if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+			if (derOut.IsBer)
 			{
 				derOut.WriteByte(Asn1Tags.Sequence | Asn1Tags.Constructed);
 				derOut.WriteByte(0x80);
diff --git a/crypto/src/asn1/BerSet.cs b/crypto/src/asn1/BerSet.cs
index 14a542106..4e752559d 100644
--- a/crypto/src/asn1/BerSet.cs
+++ b/crypto/src/asn1/BerSet.cs
@@ -46,7 +46,7 @@ namespace Org.BouncyCastle.Asn1
 
         internal override void Encode(DerOutputStream derOut)
         {
-            if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+            if (derOut.IsBer)
             {
                 derOut.WriteByte(Asn1Tags.Set | Asn1Tags.Constructed);
                 derOut.WriteByte(0x80);
diff --git a/crypto/src/asn1/BerTaggedObject.cs b/crypto/src/asn1/BerTaggedObject.cs
index fd0bdc285..9256fc16d 100644
--- a/crypto/src/asn1/BerTaggedObject.cs
+++ b/crypto/src/asn1/BerTaggedObject.cs
@@ -50,9 +50,9 @@ namespace Org.BouncyCastle.Asn1
 		internal override void Encode(
 			DerOutputStream derOut)
 		{
-			if (derOut is Asn1OutputStream || derOut is BerOutputStream)
+			if (derOut.IsBer)
 			{
-				derOut.WriteTag((byte)(Asn1Tags.Constructed | Asn1Tags.Tagged), tagNo);
+				derOut.WriteTag(Asn1Tags.Constructed | Asn1Tags.Tagged, tagNo);
 				derOut.WriteByte(0x80);
 
 				if (!IsEmpty())
diff --git a/crypto/src/asn1/DerOutputStream.cs b/crypto/src/asn1/DerOutputStream.cs
index 52b3a704d..c9c70a3f3 100644
--- a/crypto/src/asn1/DerOutputStream.cs
+++ b/crypto/src/asn1/DerOutputStream.cs
@@ -5,13 +5,18 @@ using Org.BouncyCastle.Utilities.IO;
 
 namespace Org.BouncyCastle.Asn1
 {
-	public class DerOutputStream
-		: FilterStream
-	{
-		public DerOutputStream(Stream os)
-			: base(os)
-		{
-		}
+    public class DerOutputStream
+        : FilterStream
+    {
+        public DerOutputStream(Stream os)
+            : base(os)
+        {
+        }
+
+        internal virtual bool IsBer
+        {
+            get { return false; }
+        }
 
 		private void WriteLength(
 			int length)
diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs
index cbfeab93a..f09198694 100644
--- a/crypto/src/pkcs/Pkcs12Store.cs
+++ b/crypto/src/pkcs/Pkcs12Store.cs
@@ -1037,7 +1037,7 @@ namespace Org.BouncyCastle.Pkcs
             }
             else
             {
-                derOut = new BerOutputStream(stream);
+                derOut = new Asn1OutputStream(stream);
             }
 
             derOut.WriteObject(pfx);