summary refs log tree commit diff
path: root/crypto/src/asn1/BerSet.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-11 14:06:03 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-11 14:06:03 +0700
commit46230a012af2824a5e742db8e6dc5b23c720d696 (patch)
tree9cd842e680b7a9e3eac925f05bde504bb8670859 /crypto/src/asn1/BerSet.cs
parentHandle high tag numbers (diff)
downloadBouncyCastle.NET-ed25519-46230a012af2824a5e742db8e6dc5b23c720d696.tar.xz
ASN.1: Update encoding in line with bc-java
Diffstat (limited to 'crypto/src/asn1/BerSet.cs')
-rw-r--r--crypto/src/asn1/BerSet.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/crypto/src/asn1/BerSet.cs b/crypto/src/asn1/BerSet.cs
index 2cfda2f09..c0d00537c 100644
--- a/crypto/src/asn1/BerSet.cs
+++ b/crypto/src/asn1/BerSet.cs
@@ -48,14 +48,25 @@ namespace Org.BouncyCastle.Asn1
         {
         }
 
-        internal override int EncodedLength(bool withID)
+        internal override int EncodedLength(int encoding, bool withID)
         {
-            throw Platform.CreateNotImplementedException("BerSet.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;