summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/Asn1Object.cs7
-rw-r--r--crypto/src/asn1/Asn1OutputStream.cs4
-rw-r--r--crypto/src/asn1/LazyDLSequence.cs7
-rw-r--r--crypto/src/asn1/LazyDLSet.cs7
4 files changed, 17 insertions, 8 deletions
diff --git a/crypto/src/asn1/Asn1Object.cs b/crypto/src/asn1/Asn1Object.cs
index 523476f3d..d84350cd2 100644
--- a/crypto/src/asn1/Asn1Object.cs
+++ b/crypto/src/asn1/Asn1Object.cs
@@ -31,7 +31,7 @@ namespace Org.BouncyCastle.Asn1
             using (var asn1Out = Asn1OutputStream.Create(new MemoryStream(result, true), encoding))
             {
                 asn1Encoding.Encode(asn1Out);
-                Debug.Assert(result.Length == Convert.ToInt32(asn1Out.Position));
+                Debug.Assert(result.Length == asn1Out.Position);
             }
             return result;
         }
@@ -73,7 +73,10 @@ namespace Org.BouncyCastle.Asn1
 		{
 			try
 			{
-				return new Asn1InputStream(inStr).ReadObject();
+                using (var asn1In = new Asn1InputStream(inStr, int.MaxValue, leaveOpen: true))
+                {
+                    return asn1In.ReadObject();
+                }
 			}
 			catch (InvalidCastException)
 			{
diff --git a/crypto/src/asn1/Asn1OutputStream.cs b/crypto/src/asn1/Asn1OutputStream.cs
index 588c3733d..4770235d3 100644
--- a/crypto/src/asn1/Asn1OutputStream.cs
+++ b/crypto/src/asn1/Asn1OutputStream.cs
@@ -44,7 +44,7 @@ namespace Org.BouncyCastle.Asn1
 
         private readonly bool m_leaveOpen;
 
-        internal Asn1OutputStream(Stream output, bool leaveOpen)
+        protected internal Asn1OutputStream(Stream output, bool leaveOpen)
             : base(output)
         {
             if (!output.CanWrite)
@@ -101,7 +101,7 @@ namespace Org.BouncyCastle.Asn1
             get { return EncodingBer; }
         }
 
-        internal void FlushInternal()
+        private void FlushInternal()
         {
             // Placeholder to support future internal buffering
         }
diff --git a/crypto/src/asn1/LazyDLSequence.cs b/crypto/src/asn1/LazyDLSequence.cs
index d45706bb3..a9f155359 100644
--- a/crypto/src/asn1/LazyDLSequence.cs
+++ b/crypto/src/asn1/LazyDLSequence.cs
@@ -101,10 +101,13 @@ namespace Org.BouncyCastle.Asn1
             {
                 if (null != encoded)
                 {
-                    Asn1InputStream input = new LazyAsn1InputStream(encoded);
                     try
                     {
-                        Asn1EncodableVector v = input.ReadVector();
+                        Asn1EncodableVector v;
+                        using (var input = new LazyAsn1InputStream(encoded))
+                        {
+                            v = input.ReadVector();
+                        }
 
                         this.elements = v.TakeElements();
                         this.encoded = null;
diff --git a/crypto/src/asn1/LazyDLSet.cs b/crypto/src/asn1/LazyDLSet.cs
index 7386e72ba..87354d394 100644
--- a/crypto/src/asn1/LazyDLSet.cs
+++ b/crypto/src/asn1/LazyDLSet.cs
@@ -99,10 +99,13 @@ namespace Org.BouncyCastle.Asn1
             {
                 if (null != m_encoded)
                 {
-                    Asn1InputStream input = new LazyAsn1InputStream(m_encoded);
                     try
                     {
-                        Asn1EncodableVector v = input.ReadVector();
+                        Asn1EncodableVector v;
+                        using (var input = new LazyAsn1InputStream(m_encoded))
+                        {
+                            v = input.ReadVector();
+                        }
 
                         m_elements = v.TakeElements();
                         m_sortedElements = m_elements.Length <= 1 ? m_elements : null;