diff --git a/crypto/src/asn1/LazyDLSequence.cs b/crypto/src/asn1/LazyDLSequence.cs
index fe8e71794..63152e446 100644
--- a/crypto/src/asn1/LazyDLSequence.cs
+++ b/crypto/src/asn1/LazyDLSequence.cs
@@ -65,6 +65,7 @@ namespace Org.BouncyCastle.Asn1
internal override int EncodedLength(bool withID)
{
+ // TODO This depends on knowing it's BER
byte[] encoded = GetContents();
if (encoded != null)
{
@@ -76,11 +77,18 @@ namespace Org.BouncyCastle.Asn1
internal override void Encode(Asn1OutputStream asn1Out, bool withID)
{
- byte[] encoded = GetContents();
- if (encoded != null)
+ if (asn1Out.IsBer)
{
- asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | Asn1Tags.Sequence, encoded);
- return;
+ byte[] encoded = GetContents();
+ if (encoded != null)
+ {
+ asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | Asn1Tags.Sequence, encoded);
+ return;
+ }
+ }
+ else
+ {
+ Force();
}
base.Encode(asn1Out, withID);
diff --git a/crypto/src/asn1/LazyDLSet.cs b/crypto/src/asn1/LazyDLSet.cs
index f644f69e5..0d4d84310 100644
--- a/crypto/src/asn1/LazyDLSet.cs
+++ b/crypto/src/asn1/LazyDLSet.cs
@@ -65,6 +65,7 @@ namespace Org.BouncyCastle.Asn1
internal override int EncodedLength(bool withID)
{
+ // TODO This depends on knowing it's BER
byte[] encoded = GetContents();
if (encoded != null)
{
@@ -76,11 +77,18 @@ namespace Org.BouncyCastle.Asn1
internal override void Encode(Asn1OutputStream asn1Out, bool withID)
{
- byte[] encoded = GetContents();
- if (encoded != null)
+ if (asn1Out.IsBer)
{
- asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | Asn1Tags.Set, encoded);
- return;
+ byte[] encoded = GetContents();
+ if (encoded != null)
+ {
+ asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | Asn1Tags.Set, encoded);
+ return;
+ }
+ }
+ else
+ {
+ Force();
}
base.Encode(asn1Out, withID);
|