diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-09 16:27:36 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-09 16:27:36 +0700 |
commit | 4c3c4694b6331625eee6e9ec1c92b0d17c6db7bf (patch) | |
tree | 06b3db5d6ccfc7cd4259c45d947e0a5d97a450dd /crypto/src/asn1/LazyDLSet.cs | |
parent | Fix deprecated call (diff) | |
download | BouncyCastle.NET-ed25519-4c3c4694b6331625eee6e9ec1c92b0d17c6db7bf.tar.xz |
Fix DER encoding of lazy objects
Diffstat (limited to 'crypto/src/asn1/LazyDLSet.cs')
-rw-r--r-- | crypto/src/asn1/LazyDLSet.cs | 16 |
1 files changed, 12 insertions, 4 deletions
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); |