diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-11 14:06:03 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-11 14:06:03 +0700 |
commit | 46230a012af2824a5e742db8e6dc5b23c720d696 (patch) | |
tree | 9cd842e680b7a9e3eac925f05bde504bb8670859 /crypto/src/asn1/LazyDLSequence.cs | |
parent | Handle high tag numbers (diff) | |
download | BouncyCastle.NET-ed25519-46230a012af2824a5e742db8e6dc5b23c720d696.tar.xz |
ASN.1: Update encoding in line with bc-java
Diffstat (limited to 'crypto/src/asn1/LazyDLSequence.cs')
-rw-r--r-- | crypto/src/asn1/LazyDLSequence.cs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/crypto/src/asn1/LazyDLSequence.cs b/crypto/src/asn1/LazyDLSequence.cs index fe924365e..bf9fc0800 100644 --- a/crypto/src/asn1/LazyDLSequence.cs +++ b/crypto/src/asn1/LazyDLSequence.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) |