diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-05-10 20:07:17 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-05-10 20:07:17 +0700 |
commit | 24e0abbe86d32073abf2f664955d24e10f7dec81 (patch) | |
tree | 3736e375a5f5a35a346aec481633c5ee598cc40e /crypto/src/asn1/DerSequence.cs | |
parent | Obsolete several constructors to make private later (diff) | |
download | BouncyCastle.NET-ed25519-24e0abbe86d32073abf2f664955d24e10f7dec81.tar.xz |
Add Asn1Sequence utility methods
Diffstat (limited to '')
-rw-r--r-- | crypto/src/asn1/DerSequence.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/src/asn1/DerSequence.cs b/crypto/src/asn1/DerSequence.cs index 74dc415ac..4a4aee434 100644 --- a/crypto/src/asn1/DerSequence.cs +++ b/crypto/src/asn1/DerSequence.cs @@ -7,6 +7,35 @@ namespace Org.BouncyCastle.Asn1 { public static readonly DerSequence Empty = new DerSequence(); + public static DerSequence Concatenate(params Asn1Sequence[] sequences) + { + if (sequences == null) + return Empty; + + switch (sequences.Length) + { + case 0: + return Empty; + case 1: + return FromSequence(sequences[0]); + default: + return FromElements(ConcatenateElements(sequences)); + } + } + + internal static DerSequence FromElements(Asn1Encodable[] elements) + { + return elements.Length < 1 ? Empty : new DerSequence(elements, clone: false); + } + + public static DerSequence FromSequence(Asn1Sequence sequence) + { + if (sequence is DerSequence derSequence) + return derSequence; + + return FromElements(sequence.m_elements); + } + public static DerSequence FromVector(Asn1EncodableVector elementVector) { return elementVector.Count < 1 ? Empty : new DerSequence(elementVector); |