From 3c034ea8ac68da52b5ff128300b6780549d05bd1 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 9 Nov 2021 23:37:08 +0700 Subject: Add DLSequence, DLSet for internal use - improve sorting of sets --- crypto/src/asn1/BerSet.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'crypto/src/asn1/BerSet.cs') diff --git a/crypto/src/asn1/BerSet.cs b/crypto/src/asn1/BerSet.cs index 5d61db6aa..2cfda2f09 100644 --- a/crypto/src/asn1/BerSet.cs +++ b/crypto/src/asn1/BerSet.cs @@ -14,13 +14,8 @@ namespace Org.BouncyCastle.Asn1 return elementVector.Count < 1 ? Empty : new BerSet(elementVector); } - internal static new BerSet FromVector(Asn1EncodableVector elementVector, bool needsSorting) - { - return elementVector.Count < 1 ? Empty : new BerSet(elementVector, needsSorting); - } - /** - * create an empty sequence + * create an empty set */ public BerSet() : base() @@ -35,6 +30,11 @@ namespace Org.BouncyCastle.Asn1 { } + public BerSet(params Asn1Encodable[] elements) + : base(elements, false) + { + } + /** * create a set containing a vector of objects. */ @@ -43,8 +43,8 @@ namespace Org.BouncyCastle.Asn1 { } - internal BerSet(Asn1EncodableVector elementVector, bool needsSorting) - : base(elementVector, needsSorting) + internal BerSet(bool isSorted, Asn1Encodable[] elements) + : base(isSorted, elements) { } @@ -55,14 +55,13 @@ namespace Org.BouncyCastle.Asn1 internal override void Encode(Asn1OutputStream asn1Out, bool withID) { - if (asn1Out.IsBer) - { - asn1Out.WriteEncodingIL(withID, Asn1Tags.Constructed | Asn1Tags.Set, elements); - } - else + if (!asn1Out.IsBer) { base.Encode(asn1Out, withID); + return; } + + asn1Out.WriteEncodingIL(withID, Asn1Tags.Constructed | Asn1Tags.Set, elements); } } } -- cgit 1.4.1