summary refs log tree commit diff
path: root/crypto/src/asn1/ConstructedLazyDLEncoding.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/ConstructedLazyDLEncoding.cs')
-rw-r--r--crypto/src/asn1/ConstructedLazyDLEncoding.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crypto/src/asn1/ConstructedLazyDLEncoding.cs b/crypto/src/asn1/ConstructedLazyDLEncoding.cs
new file mode 100644
index 000000000..3847b465b
--- /dev/null
+++ b/crypto/src/asn1/ConstructedLazyDLEncoding.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace Org.BouncyCastle.Asn1
+{
+    internal class ConstructedLazyDLEncoding
+        : IAsn1Encoding
+    {
+        private readonly int m_tagClass;
+        private readonly int m_tagNo;
+        private readonly byte[] m_contentsOctets;
+
+        internal ConstructedLazyDLEncoding(int tagClass, int tagNo, byte[] contentsOctets)
+        {
+            m_tagClass = tagClass;
+            m_tagNo = tagNo;
+            m_contentsOctets = contentsOctets;
+        }
+
+        void IAsn1Encoding.Encode(Asn1OutputStream asn1Out)
+        {
+            asn1Out.WriteIdentifier(Asn1Tags.Constructed | m_tagClass, m_tagNo);
+            asn1Out.WriteDL(m_contentsOctets.Length);
+            asn1Out.Write(m_contentsOctets, 0, m_contentsOctets.Length);
+        }
+
+        int IAsn1Encoding.GetLength()
+        {
+            return Asn1OutputStream.GetLengthOfIdentifier(m_tagNo)
+                +  Asn1OutputStream.GetLengthOfDL(m_contentsOctets.Length)
+                +  m_contentsOctets.Length;
+        }
+    }
+}