diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-09 23:37:08 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-09 23:37:08 +0700 |
commit | 3c034ea8ac68da52b5ff128300b6780549d05bd1 (patch) | |
tree | a3f4572beee014d784560c0ba1282a4000e1a98a /crypto/src/asn1/BerSet.cs | |
parent | Fix DER encoding of lazy objects (diff) | |
download | BouncyCastle.NET-ed25519-3c034ea8ac68da52b5ff128300b6780549d05bd1.tar.xz |
Add DLSequence, DLSet for internal use
- improve sorting of sets
Diffstat (limited to 'crypto/src/asn1/BerSet.cs')
-rw-r--r-- | crypto/src/asn1/BerSet.cs | 25 |
1 files changed, 12 insertions, 13 deletions
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); } } } |