From f06dc7c2f2e578c77bdb53ff981c578c3fe017eb Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 1 Aug 2019 20:30:22 +0700 Subject: Rewrite Asn1Sequence/Set to store elements as Asn1Encodable[] --- crypto/src/asn1/DerSequence.cs | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'crypto/src/asn1/DerSequence.cs') diff --git a/crypto/src/asn1/DerSequence.cs b/crypto/src/asn1/DerSequence.cs index a76cf2882..823fa869b 100644 --- a/crypto/src/asn1/DerSequence.cs +++ b/crypto/src/asn1/DerSequence.cs @@ -11,51 +11,38 @@ namespace Org.BouncyCastle.Asn1 { public static readonly DerSequence Empty = new DerSequence(); - public static DerSequence FromVector( - Asn1EncodableVector v) + public static DerSequence FromVector(Asn1EncodableVector elementVector) { - return v.Count < 1 ? Empty : new DerSequence(v); + return elementVector.Count < 1 ? Empty : new DerSequence(elementVector); } /** * create an empty sequence */ public DerSequence() - : base(0) + : base() { } /** * create a sequence containing one object */ - public DerSequence( - Asn1Encodable obj) - : base(1) + public DerSequence(Asn1Encodable element) + : base(element) { - AddObject(obj); } - public DerSequence( - params Asn1Encodable[] v) - : base(v.Length) + public DerSequence(params Asn1Encodable[] elements) + : base(elements) { - foreach (Asn1Encodable ae in v) - { - AddObject(ae); - } } /** * create a sequence containing a vector of objects. */ - public DerSequence( - Asn1EncodableVector v) - : base(v.Count) + public DerSequence(Asn1EncodableVector elementVector) + : base(elementVector) { - foreach (Asn1Encodable ae in v) - { - AddObject(ae); - } } /* @@ -66,8 +53,7 @@ namespace Org.BouncyCastle.Asn1 * ASN.1 descriptions given. Rather than just outputing Sequence, * we also have to specify Constructed, and the objects length. */ - internal override void Encode( - DerOutputStream derOut) + internal override void Encode(DerOutputStream derOut) { // TODO Intermediate buffer could be avoided if we could calculate expected length MemoryStream bOut = new MemoryStream(); -- cgit 1.4.1