summary refs log tree commit diff
path: root/crypto/src/asn1/LazyASN1InputStream.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-05 14:45:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-05 14:45:49 +0700
commit6b59dbbece3b1509b83b8479259a3c6059e9a60b (patch)
tree3dca66ea9a1e8aa02ac6099cde5844155783bd7b /crypto/src/asn1/LazyASN1InputStream.cs
parentRefactor Asn1Set classes (diff)
downloadBouncyCastle.NET-ed25519-6b59dbbece3b1509b83b8479259a3c6059e9a60b.tar.xz
Support 'leaveOpen' in Asn1 streams
Diffstat (limited to 'crypto/src/asn1/LazyASN1InputStream.cs')
-rw-r--r--crypto/src/asn1/LazyASN1InputStream.cs19
1 files changed, 16 insertions, 3 deletions
diff --git a/crypto/src/asn1/LazyASN1InputStream.cs b/crypto/src/asn1/LazyASN1InputStream.cs
index 8dfbba122..8807416f4 100644
--- a/crypto/src/asn1/LazyASN1InputStream.cs
+++ b/crypto/src/asn1/LazyASN1InputStream.cs
@@ -16,8 +16,18 @@ namespace Org.BouncyCastle.Asn1
         {
         }
 
-        internal LazyAsn1InputStream(Stream input, int limit, byte[][] tmpBuffers)
-            : base(input, limit, tmpBuffers)
+        public LazyAsn1InputStream(Stream input, int limit)
+            : base(input, limit)
+        {
+        }
+
+        public LazyAsn1InputStream(Stream input, int limit, bool leaveOpen)
+            : base(input, limit, leaveOpen)
+        {
+        }
+
+        internal LazyAsn1InputStream(Stream input, int limit, bool leaveOpen, byte[][] tmpBuffers)
+            : base(input, limit, leaveOpen, tmpBuffers)
         {
         }
 
@@ -37,7 +47,10 @@ namespace Org.BouncyCastle.Asn1
             if (remaining < 1)
                 return new Asn1EncodableVector(0);
 
-            return new LazyAsn1InputStream(defIn, remaining, tmpBuffers).ReadVector();
+            using (var sub = new LazyAsn1InputStream(defIn, remaining, leaveOpen: true, tmpBuffers))
+            {
+                return sub.ReadVector();
+            }
         }
     }
 }