diff options
-rw-r--r-- | crypto/src/asn1/BERBitString.cs | 25 | ||||
-rw-r--r-- | crypto/src/asn1/BerOctetString.cs | 24 |
2 files changed, 20 insertions, 29 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) diff --git a/crypto/src/asn1/BerOctetString.cs b/crypto/src/asn1/BerOctetString.cs index 5350b8416..10d8d6db6 100644 --- a/crypto/src/asn1/BerOctetString.cs +++ b/crypto/src/asn1/BerOctetString.cs @@ -6,17 +6,9 @@ namespace Org.BouncyCastle.Asn1 public class BerOctetString : DerOctetString { - private const int DefaultSegmentLimit = 1000; - public static BerOctetString FromSequence(Asn1Sequence seq) { - int count = seq.Count; - Asn1OctetString[] v = new Asn1OctetString[count]; - for (int i = 0; i < count; ++i) - { - v[i] = GetInstance(seq[i]); - } - return new BerOctetString(v); + return new BerOctetString(seq.MapElements(GetInstance)); } internal static byte[] FlattenOctetStrings(Asn1OctetString[] octetStrings) @@ -51,34 +43,34 @@ namespace Org.BouncyCastle.Asn1 } } - private readonly int segmentLimit; private readonly Asn1OctetString[] elements; public BerOctetString(byte[] contents) - : this(contents, DefaultSegmentLimit) + : this(contents, null) { } public BerOctetString(Asn1OctetString[] elements) - : this(elements, DefaultSegmentLimit) + : this(FlattenOctetStrings(elements), elements) { } + [Obsolete("Use version without segmentLimit (which is ignored anyway)")] public BerOctetString(byte[] contents, int segmentLimit) - : this(contents, null, segmentLimit) + : this(contents) { } + [Obsolete("Use version without segmentLimit (which is ignored anyway)")] public BerOctetString(Asn1OctetString[] elements, int segmentLimit) - : this(FlattenOctetStrings(elements), elements, segmentLimit) + : this(elements) { } - private BerOctetString(byte[] contents, Asn1OctetString[] elements, int segmentLimit) + private BerOctetString(byte[] contents, Asn1OctetString[] elements) : base(contents) { this.elements = elements; - this.segmentLimit = segmentLimit; } internal override IAsn1Encoding GetEncoding(int encoding) |