summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1InputStream.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-11 21:13:22 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-11 21:13:22 +0700
commit39f33f785250b544610c429fb9d4e50c521cd493 (patch)
treec7a55871f7c0038dcbc99e582826051cb3a180d0 /crypto/src/asn1/Asn1InputStream.cs
parentTrim stack trace (diff)
downloadBouncyCastle.NET-ed25519-39f33f785250b544610c429fb9d4e50c521cd493.tar.xz
Refactor tagged object parsing
Diffstat (limited to 'crypto/src/asn1/Asn1InputStream.cs')
-rw-r--r--crypto/src/asn1/Asn1InputStream.cs16
1 files changed, 3 insertions, 13 deletions
diff --git a/crypto/src/asn1/Asn1InputStream.cs b/crypto/src/asn1/Asn1InputStream.cs
index 6e097e86d..3f7a65cc9 100644
--- a/crypto/src/asn1/Asn1InputStream.cs
+++ b/crypto/src/asn1/Asn1InputStream.cs
@@ -107,23 +107,13 @@ namespace Org.BouncyCastle.Asn1
         {
             if (!constructed)
             {
-                // Note: !CONSTRUCTED => IMPLICIT
                 byte[] contentsOctets = defIn.ToArray();
-
-                if (Asn1Tags.Application == tagClass)
-                    return new DerApplicationSpecific(false, tagNo, contentsOctets);
-
-                return new DLTaggedObject(false, tagNo, new DerOctetString(contentsOctets));
+                return Asn1TaggedObject.CreatePrimitive(tagClass, tagNo, contentsOctets);
             }
 
+            bool isIL = false;
             Asn1EncodableVector contentsElements = ReadVector(defIn);
-
-            if (Asn1Tags.Application == tagClass)
-                return new DerApplicationSpecific(tagNo, contentsElements);
-
-            return contentsElements.Count == 1
-                ? new DLTaggedObject(true, tagNo, contentsElements[0])
-                : new DLTaggedObject(false, tagNo, DLSequence.FromVector(contentsElements));
+            return Asn1TaggedObject.CreateConstructed(tagClass, tagNo, isIL, contentsElements);
         }
 
         internal virtual Asn1EncodableVector ReadVector()