diff options
Diffstat (limited to 'crypto/src/asn1/BerOctetString.cs')
-rw-r--r-- | crypto/src/asn1/BerOctetString.cs | 78 |
1 files changed, 1 insertions, 77 deletions
diff --git a/crypto/src/asn1/BerOctetString.cs b/crypto/src/asn1/BerOctetString.cs index 2ee508b34..5350b8416 100644 --- a/crypto/src/asn1/BerOctetString.cs +++ b/crypto/src/asn1/BerOctetString.cs @@ -1,13 +1,10 @@ using System; -using System.Collections; using System.Diagnostics; -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Asn1 { public class BerOctetString - : DerOctetString, IEnumerable + : DerOctetString { private const int DefaultSegmentLimit = 1000; @@ -54,19 +51,6 @@ namespace Org.BouncyCastle.Asn1 } } - private static Asn1OctetString[] ToOctetStringArray(IEnumerable e) - { - IList list = Platform.CreateArrayList(e); - - int count = list.Count; - Asn1OctetString[] v = new Asn1OctetString[count]; - for (int i = 0; i < count; ++i) - { - v[i] = GetInstance(list[i]); - } - return v; - } - private readonly int segmentLimit; private readonly Asn1OctetString[] elements; @@ -97,17 +81,6 @@ namespace Org.BouncyCastle.Asn1 this.segmentLimit = segmentLimit; } - /** - * return the DER octets that make up this string. - */ - public IEnumerator GetEnumerator() - { - if (elements == null) - return new ChunkEnumerator(contents, segmentLimit); - - return elements.GetEnumerator(); - } - internal override IAsn1Encoding GetEncoding(int encoding) { if (Asn1OutputStream.EncodingBer != encoding) @@ -131,54 +104,5 @@ namespace Org.BouncyCastle.Asn1 return new ConstructedILEncoding(tagClass, tagNo, Asn1OutputStream.GetContentsEncodings(encoding, elements)); } - - private class ChunkEnumerator - : IEnumerator - { - private readonly byte[] octets; - private readonly int segmentLimit; - - private DerOctetString currentSegment = null; - private int nextSegmentPos = 0; - - internal ChunkEnumerator(byte[] octets, int segmentLimit) - { - this.octets = octets; - this.segmentLimit = segmentLimit; - } - - public object Current - { - get - { - if (null == currentSegment) - throw new InvalidOperationException(); - - return currentSegment; - } - } - - public bool MoveNext() - { - if (nextSegmentPos >= octets.Length) - { - this.currentSegment = null; - return false; - } - - int length = System.Math.Min(octets.Length - nextSegmentPos, segmentLimit); - byte[] segment = new byte[length]; - Array.Copy(octets, nextSegmentPos, segment, 0, length); - this.currentSegment = new DerOctetString(segment); - this.nextSegmentPos += length; - return true; - } - - public void Reset() - { - this.currentSegment = null; - this.nextSegmentPos = 0; - } - } } } |