diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-07-01 19:23:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-07-01 19:23:46 +0700 |
commit | 4e97fa1cbee0072938c5ea33ca51f4e3964f2998 (patch) | |
tree | 0aad9c9bc277429ee733c8383672cb7c6aed329a /crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs | |
parent | Refactoring in Asn1.Smime (diff) | |
download | BouncyCastle.NET-ed25519-4e97fa1cbee0072938c5ea33ca51f4e3964f2998.tar.xz |
Refactoring in Asn1.Tsp
Diffstat (limited to 'crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs')
-rw-r--r-- | crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs b/crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs index 3c5d963e6..3ddeed4dd 100644 --- a/crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs +++ b/crypto/src/asn1/tsp/ArchiveTimeStampSequence.cs @@ -29,23 +29,17 @@ namespace Org.BouncyCastle.Asn1.Tsp return new ArchiveTimeStampSequence(Asn1Sequence.GetInstance(obj)); } - public static ArchiveTimeStampSequence GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) - { - return new ArchiveTimeStampSequence(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); - } + public static ArchiveTimeStampSequence GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) => + new ArchiveTimeStampSequence(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + + public static ArchiveTimeStampSequence GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) => + new ArchiveTimeStampSequence(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); private readonly Asn1Sequence m_archiveTimeStampChains; - private ArchiveTimeStampSequence(Asn1Sequence sequence) + private ArchiveTimeStampSequence(Asn1Sequence seq) { - Asn1EncodableVector vector = new Asn1EncodableVector(sequence.Count); - - foreach (var element in sequence) - { - vector.Add(ArchiveTimeStampChain.GetInstance(element)); - } - - m_archiveTimeStampChains = new DerSequence(vector); + m_archiveTimeStampChains = DerSequence.FromElements(seq.MapElements(ArchiveTimeStampChain.GetInstance)); } public ArchiveTimeStampSequence(ArchiveTimeStampChain archiveTimeStampChain) @@ -55,7 +49,7 @@ namespace Org.BouncyCastle.Asn1.Tsp public ArchiveTimeStampSequence(ArchiveTimeStampChain[] archiveTimeStampChains) { - m_archiveTimeStampChains = new DerSequence(archiveTimeStampChains); + m_archiveTimeStampChains = DerSequence.FromElements(archiveTimeStampChains); } /** @@ -76,6 +70,9 @@ namespace Org.BouncyCastle.Asn1.Tsp */ public virtual ArchiveTimeStampSequence Append(ArchiveTimeStampChain chain) { + if (chain == null) + throw new ArgumentNullException(nameof(chain)); + Asn1EncodableVector v = new Asn1EncodableVector(m_archiveTimeStampChains.Count + 1); foreach (var element in m_archiveTimeStampChains) |