summary refs log tree commit diff
path: root/crypto/src/asn1/BERBitString.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crypto/src/asn1/BERBitString.cs25
1 files changed, 12 insertions, 13 deletions
diff --git a/crypto/src/asn1/BERBitString.cs b/crypto/src/asn1/BERBitString.cs
index 2f5bd9cb7..e69e7a35f 100644
--- a/crypto/src/asn1/BERBitString.cs
+++ b/crypto/src/asn1/BERBitString.cs
@@ -6,7 +6,10 @@ namespace Org.BouncyCastle.Asn1
     public class BerBitString
         : DerBitString
     {
-        private const int DefaultSegmentLimit = 1000;
+        public static BerBitString FromSequence(Asn1Sequence seq)
+        {
+            return new BerBitString(seq.MapElements(GetInstance));
+        }
 
         internal static byte[] FlattenBitStrings(DerBitString[] bitStrings)
         {
@@ -53,14 +56,12 @@ namespace Org.BouncyCastle.Asn1
             }
         }
 
-        private readonly int segmentLimit;
         private readonly DerBitString[] elements;
 
         public BerBitString(byte data, int padBits)
             : base(data, padBits)
         {
             this.elements = null;
-            this.segmentLimit = DefaultSegmentLimit;
         }
 
         public BerBitString(byte[] data)
@@ -69,22 +70,21 @@ namespace Org.BouncyCastle.Asn1
         }
 
         public BerBitString(byte[] data, int padBits)
-            : this(data, padBits, DefaultSegmentLimit)
+            : base(data, padBits)
 		{
+            this.elements = null;
         }
 
+        [Obsolete("Use version without segmentLimit (which is ignored anyway)")]
         public BerBitString(byte[] data, int padBits, int segmentLimit)
-            : base(data, padBits)
+            : this(data, padBits)
         {
-            this.elements = null;
-            this.segmentLimit = segmentLimit;
         }
 
         public BerBitString(int namedBits)
             : base(namedBits)
         {
             this.elements = null;
-            this.segmentLimit = DefaultSegmentLimit;
         }
 
         public BerBitString(Asn1Encodable obj)
@@ -93,22 +93,21 @@ namespace Org.BouncyCastle.Asn1
         }
 
         public BerBitString(DerBitString[] elements)
-            : this(elements, DefaultSegmentLimit)
+            : base(FlattenBitStrings(elements), false)
         {
+            this.elements = elements;
         }
 
+        [Obsolete("Use version without segmentLimit (which is ignored anyway)")]
         public BerBitString(DerBitString[] elements, int segmentLimit)
-            : base(FlattenBitStrings(elements), false)
+            : this(elements)
         {
-            this.elements = elements;
-            this.segmentLimit = segmentLimit;
         }
 
         internal BerBitString(byte[] contents, bool check)
             : base(contents, check)
         {
             this.elements = null;
-            this.segmentLimit = DefaultSegmentLimit;
         }
 
         internal override IAsn1Encoding GetEncoding(int encoding)