summary refs log tree commit diff
path: root/crypto/src/asn1/BerTaggedObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/BerTaggedObject.cs')
-rw-r--r--crypto/src/asn1/BerTaggedObject.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crypto/src/asn1/BerTaggedObject.cs b/crypto/src/asn1/BerTaggedObject.cs
index 097f77610..631d34420 100644
--- a/crypto/src/asn1/BerTaggedObject.cs
+++ b/crypto/src/asn1/BerTaggedObject.cs
@@ -47,12 +47,16 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-		internal override void Encode(Asn1OutputStream asn1Out)
+		internal override void Encode(Asn1OutputStream asn1Out, bool withID)
 		{
 			if (asn1Out.IsBer)
 			{
-				asn1Out.WriteIdentifier(true, Asn1Tags.Constructed | Asn1Tags.Tagged, tagNo);
-				asn1Out.WriteByte(0x80);
+                if (withID)
+                {
+                    asn1Out.WriteIdentifier(true, Asn1Tags.Constructed | Asn1Tags.Tagged, tagNo);
+                }
+
+                asn1Out.WriteByte(0x80);
 
 				if (!IsEmpty())
 				{
@@ -86,12 +90,12 @@ namespace Org.BouncyCastle.Asn1
 
 						foreach (Asn1Encodable o in eObj)
 						{
-							asn1Out.WritePrimitive(o.ToAsn1Object());
+							asn1Out.WritePrimitive(o.ToAsn1Object(), true);
 						}
 					}
 					else
 					{
-						asn1Out.WritePrimitive(obj.ToAsn1Object());
+						asn1Out.WritePrimitive(obj.ToAsn1Object(), true);
 					}
 				}
 
@@ -100,7 +104,7 @@ namespace Org.BouncyCastle.Asn1
 			}
 			else
 			{
-				base.Encode(asn1Out);
+				base.Encode(asn1Out, withID);
 			}
 		}
 	}