summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2018-10-05 13:39:56 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2018-10-05 13:39:56 +0700
commit28d70017845dfe00af366ae56ad388f52bc944d2 (patch)
tree8008969dd84228972b2836a5cbdb7df7bb0c1c3f /crypto/src/util
parentAdd new SignerInformation protected constructor (diff)
downloadBouncyCastle.NET-ed25519-28d70017845dfe00af366ae56ad388f52bc944d2.tar.xz
Fix some TODOs for PORTABLE and Streams
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/io/Streams.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto/src/util/io/Streams.cs b/crypto/src/util/io/Streams.cs
index cc7fa924c..503a1b4f1 100644
--- a/crypto/src/util/io/Streams.cs
+++ b/crypto/src/util/io/Streams.cs
@@ -96,5 +96,30 @@ namespace Org.BouncyCastle.Utilities.IO
         {
             buf.WriteTo(output);
         }
+
+        /// <exception cref="IOException"></exception>
+        public static int WriteBufTo(MemoryStream buf, byte[] output, int offset)
+        {
+#if PORTABLE
+            byte[] bytes = buf.ToArray();
+            bytes.CopyTo(output, offset);
+            return bytes.Length;
+#else
+            int size = (int)buf.Length;
+            buf.WriteTo(new MemoryStream(output, offset, size, true));
+            return size;
+#endif
+        }
+
+        public static void WriteZeroes(Stream outStr, long count)
+        {
+            byte[] zeroes = new byte[BufferSize];
+            while (count > BufferSize)
+            {
+                outStr.Write(zeroes, 0, BufferSize);
+                count -= BufferSize;
+            }
+            outStr.Write(zeroes, 0, (int)count);
+        }
     }
 }