summary refs log tree commit diff
path: root/crypto/src/asn1/BEROctetStringParser.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-10-15 16:10:37 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-10-15 16:10:37 +0700
commit2e690b9bb3da422608a86f70fc9090923b398694 (patch)
tree6f2a7da682fce10b58d8615e86ba5d2ef4d882fe /crypto/src/asn1/BEROctetStringParser.cs
parentReplace Obsolete tag (diff)
downloadBouncyCastle.NET-ed25519-2e690b9bb3da422608a86f70fc9090923b398694.tar.xz
Refactor ASN.1 parsers
Diffstat (limited to 'crypto/src/asn1/BEROctetStringParser.cs')
-rw-r--r--crypto/src/asn1/BEROctetStringParser.cs54
1 files changed, 29 insertions, 25 deletions
diff --git a/crypto/src/asn1/BEROctetStringParser.cs b/crypto/src/asn1/BEROctetStringParser.cs
index 3bfd2a98d..c8c344e11 100644
--- a/crypto/src/asn1/BEROctetStringParser.cs
+++ b/crypto/src/asn1/BEROctetStringParser.cs
@@ -5,32 +5,36 @@ using Org.BouncyCastle.Utilities.IO;
 
 namespace Org.BouncyCastle.Asn1
 {
-	public class BerOctetStringParser
-		: Asn1OctetStringParser
-	{
-		private readonly Asn1StreamParser _parser;
+    public class BerOctetStringParser
+        : Asn1OctetStringParser
+    {
+        private readonly Asn1StreamParser _parser;
 
-		internal BerOctetStringParser(
-			Asn1StreamParser parser)
-		{
-			_parser = parser;
-		}
+        internal BerOctetStringParser(Asn1StreamParser parser)
+        {
+            _parser = parser;
+        }
 
-		public Stream GetOctetStream()
-		{
-			return new ConstructedOctetStream(_parser);
-		}
+        public Stream GetOctetStream()
+        {
+            return new ConstructedOctetStream(_parser);
+        }
 
-		public Asn1Object ToAsn1Object()
-		{
-			try
-			{
-				return new BerOctetString(Streams.ReadAll(GetOctetStream()));
-			}
-			catch (IOException e)
-			{
-				throw new Asn1ParsingException("IOException converting stream to byte array: " + e.Message, e);
-			}
-		}
-	}
+        public Asn1Object ToAsn1Object()
+        {
+            try
+            {
+                return Parse(_parser);
+            }
+            catch (IOException e)
+            {
+                throw new Asn1ParsingException("IOException converting stream to byte array: " + e.Message, e);
+            }
+        }
+
+        internal static BerOctetString Parse(Asn1StreamParser sp)
+        {
+            return new BerOctetString(Streams.ReadAll(new ConstructedOctetStream(sp)));
+        }
+    }
 }