summary refs log tree commit diff
path: root/crypto/src/util/io/BinaryReaders.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-11-17 10:09:10 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-11-17 10:09:10 +0700
commitae66e668da98ed3ceac7fa28bb2e9f92a220e595 (patch)
treed207ea604246fe78526ffb88fc0f959eab6bd0c9 /crypto/src/util/io/BinaryReaders.cs
parentImprovements to OaepEncoding (diff)
downloadBouncyCastle.NET-ed25519-ae66e668da98ed3ceac7fa28bb2e9f92a220e595.tar.xz
Refactor LMS parsing
Diffstat (limited to 'crypto/src/util/io/BinaryReaders.cs')
-rw-r--r--crypto/src/util/io/BinaryReaders.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crypto/src/util/io/BinaryReaders.cs b/crypto/src/util/io/BinaryReaders.cs
index c5f99a712..ed4b57d0a 100644
--- a/crypto/src/util/io/BinaryReaders.cs
+++ b/crypto/src/util/io/BinaryReaders.cs
@@ -1,10 +1,19 @@
 using System;
 using System.IO;
+using System.Text;
 
 namespace Org.BouncyCastle.Utilities.IO
 {
     public static class BinaryReaders
     {
+        internal static T Parse<T>(Func<BinaryReader, T> parse, Stream stream, bool leaveOpen)
+        {
+            using (var binaryReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen))
+            {
+                return parse(binaryReader);
+            }
+        }
+
         public static byte[] ReadBytesFully(BinaryReader binaryReader, int count)
         {
             byte[] bytes = binaryReader.ReadBytes(count);