summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1BitStringParser.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-18 16:31:12 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-18 16:31:12 +0700
commit1ec8938ad4d5810c3f50957b85c7fe9a1e6a00b7 (patch)
tree7760d701bc4f114be2b18f02896cbfa0442f958b /crypto/src/asn1/Asn1BitStringParser.cs
parentASN.1: Port of bc-java TYPE instances (diff)
downloadBouncyCastle.NET-ed25519-1ec8938ad4d5810c3f50957b85c7fe9a1e6a00b7.tar.xz
ASN:1 tagged object parser updates from bc-java
Diffstat (limited to 'crypto/src/asn1/Asn1BitStringParser.cs')
-rw-r--r--crypto/src/asn1/Asn1BitStringParser.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1BitStringParser.cs b/crypto/src/asn1/Asn1BitStringParser.cs
new file mode 100644
index 000000000..76af06d73
--- /dev/null
+++ b/crypto/src/asn1/Asn1BitStringParser.cs
@@ -0,0 +1,32 @@
+using System;
+using System.IO;
+
+namespace Org.BouncyCastle.Asn1
+{
+    public interface Asn1BitStringParser
+        : IAsn1Convertible
+    {
+        /// <summary>Return a <see cref="Stream"/> representing the contents of the BIT STRING. The final byte, if any,
+        /// may include pad bits. See <see cref="PadBits"/>.</summary>
+        /// <returns>A <see cref="Stream"/> with its source as the BIT STRING content.</returns>
+        /// <exception cref="IOException"/>
+        Stream GetBitStream();
+
+        /// <summary>Return a <see cref="Stream"/> representing the contents of the BIT STRING, where the content is
+        /// expected to be octet-aligned (this will be automatically checked during parsing).</summary>
+        /// <returns>A <see cref="Stream"/> with its source as the BIT STRING content.</returns>
+        /// <exception cref="IOException"/>
+        Stream GetOctetStream();
+
+        /// <summary>Return the number of pad bits, if any, in the final byte, if any, read from
+        /// <see cref="GetBitStream"/>.</summary>
+        /// <remarks>
+        /// This number is in the range zero to seven. That number of the least significant bits of the final byte, if
+        /// any, are not part of the contents and should be ignored. NOTE: Must be called AFTER the stream has been
+        /// fully processed. (Does not need to be called if <see cref="GetOctetStream"/> was used instead of
+        /// <see cref="GetBitStream"/>.
+        /// </remarks>
+        /// <returns>The number of pad bits. In the range zero to seven.</returns>
+        int PadBits { get; }
+    }
+}