diff options
Diffstat (limited to 'crypto/src/asn1/BerSequence.cs')
-rw-r--r-- | crypto/src/asn1/BerSequence.cs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/crypto/src/asn1/BerSequence.cs b/crypto/src/asn1/BerSequence.cs index c8c5bbbbd..a92b70f98 100644 --- a/crypto/src/asn1/BerSequence.cs +++ b/crypto/src/asn1/BerSequence.cs @@ -1,7 +1,5 @@ using System; -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Asn1 { public class BerSequence @@ -48,14 +46,25 @@ namespace Org.BouncyCastle.Asn1 { } - internal override int EncodedLength(bool withID) + internal override int EncodedLength(int encoding, bool withID) { - throw Platform.CreateNotImplementedException("BerSequence.EncodedLength"); + if (Asn1OutputStream.EncodingBer != encoding) + return base.EncodedLength(encoding, withID); + + int totalLength = withID ? 4 : 3; + + for (int i = 0, count = elements.Length; i < count; ++i) + { + Asn1Object asn1Object = elements[i].ToAsn1Object(); + totalLength += asn1Object.EncodedLength(encoding, true); + } + + return totalLength; } internal override void Encode(Asn1OutputStream asn1Out, bool withID) { - if (!asn1Out.IsBer) + if (Asn1OutputStream.EncodingBer != asn1Out.Encoding) { base.Encode(asn1Out, withID); return; |