summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1OutputStream.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/Asn1OutputStream.cs')
-rw-r--r--crypto/src/asn1/Asn1OutputStream.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1OutputStream.cs b/crypto/src/asn1/Asn1OutputStream.cs
index ffbe5c05d..240c7891b 100644
--- a/crypto/src/asn1/Asn1OutputStream.cs
+++ b/crypto/src/asn1/Asn1OutputStream.cs
@@ -6,6 +6,24 @@ namespace Org.BouncyCastle.Asn1
     public class Asn1OutputStream
         : DerOutputStream
     {
+        public static Asn1OutputStream Create(Stream output)
+        {
+            return new Asn1OutputStream(output);
+        }
+
+        public static Asn1OutputStream Create(Stream output, string encoding)
+        {
+            if (Asn1Encodable.Der.Equals(encoding))
+            {
+                return new DerOutputStreamNew(output);
+            }
+            else
+            {
+                return new Asn1OutputStream(output);
+            }
+        }
+
+        [Obsolete("Use static Create method(s)")]
         public Asn1OutputStream(Stream os)
             : base(os)
         {
@@ -15,5 +33,29 @@ namespace Org.BouncyCastle.Asn1
         {
             get { return true; }
         }
+
+        public override void WriteObject(Asn1Encodable obj)
+        {
+            if (obj == null)
+            {
+                WriteNull();
+            }
+            else
+            {
+                obj.ToAsn1Object().Encode(this);
+            }
+        }
+
+        public override void WriteObject(Asn1Object obj)
+        {
+            if (obj == null)
+            {
+                WriteNull();
+            }
+            else
+            {
+                obj.Encode(this);
+            }
+        }
     }
 }