summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1Sequence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/Asn1Sequence.cs')
-rw-r--r--crypto/src/asn1/Asn1Sequence.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1Sequence.cs b/crypto/src/asn1/Asn1Sequence.cs
index 8229bfb1d..83e881728 100644
--- a/crypto/src/asn1/Asn1Sequence.cs
+++ b/crypto/src/asn1/Asn1Sequence.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO;
 
 using Org.BouncyCastle.Utilities;
@@ -76,6 +77,28 @@ namespace Org.BouncyCastle.Asn1
             return (Asn1Sequence)Meta.Instance.GetContextInstance(taggedObject, declaredExplicit);
         }
 
+        internal static Asn1Encodable[] ConcatenateElements(Asn1Sequence[] sequences)
+        {
+            int count = sequences.Length;
+            int totalElements = 0;
+            for (int i = 0; i < count; ++i)
+            {
+                totalElements += sequences[i].Count;
+            }
+
+            Asn1Encodable[] concatElements = new Asn1Encodable[totalElements];
+            int pos = 0;
+            for (int i = 0; i < count; ++i)
+            {
+                Asn1Encodable[] elements = sequences[i].m_elements;
+                Array.Copy(elements, 0, concatElements, pos, elements.Length);
+                pos += elements.Length;
+            }
+
+            Debug.Assert(pos == totalElements);
+            return concatElements;
+        }
+
         internal readonly Asn1Encodable[] m_elements;
 
         protected internal Asn1Sequence()