summary refs log tree commit diff
path: root/crypto/src/asn1/LazyDLSet.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/LazyDLSet.cs')
-rw-r--r--crypto/src/asn1/LazyDLSet.cs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crypto/src/asn1/LazyDLSet.cs b/crypto/src/asn1/LazyDLSet.cs
index bdee0bc22..a426bb4cb 100644
--- a/crypto/src/asn1/LazyDLSet.cs
+++ b/crypto/src/asn1/LazyDLSet.cs
@@ -63,21 +63,25 @@ namespace Org.BouncyCastle.Asn1
             return base.ToString();
         }
 
-        internal override int EncodedLength(bool withID)
+        internal override int EncodedLength(int encoding, bool withID)
         {
-            // TODO This depends on knowing it's BER
-            byte[] encoded = GetContents();
-            if (encoded != null)
+            if (Asn1OutputStream.EncodingBer == encoding)
             {
-                return Asn1OutputStream.GetLengthOfEncodingDL(withID, encoded.Length);
+                byte[] encoded = GetContents();
+                if (null != encoded)
+                    return Asn1OutputStream.GetLengthOfEncodingDL(withID, encoded.Length);
+            }
+            else
+            {
+                Force();
             }
 
-            return base.EncodedLength(withID);
+            return base.EncodedLength(encoding, withID);
         }
 
         internal override void Encode(Asn1OutputStream asn1Out, bool withID)
         {
-            if (asn1Out.IsBer)
+            if (Asn1OutputStream.EncodingBer == asn1Out.Encoding)
             {
                 byte[] encoded = GetContents();
                 if (encoded != null)