From 19d87bee16fef5f1e1df518dba467ded14cf6915 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 15 Oct 2021 15:37:14 +0700 Subject: Refactoring --- crypto/src/asn1/ASN1StreamParser.cs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'crypto/src/asn1/ASN1StreamParser.cs') diff --git a/crypto/src/asn1/ASN1StreamParser.cs b/crypto/src/asn1/ASN1StreamParser.cs index cca333412..a92a3adae 100644 --- a/crypto/src/asn1/ASN1StreamParser.cs +++ b/crypto/src/asn1/ASN1StreamParser.cs @@ -146,32 +146,30 @@ namespace Org.BouncyCastle.Asn1 IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, _limit, tmpBuffers); - if ((tag & Asn1Tags.Application) != 0) - { - return new BerApplicationSpecificParser(tagNo, sp); - } + int tagClass = tag & Asn1Tags.Private; + if (0 != tagClass) + { + if ((tag & Asn1Tags.Application) != 0) + return new BerApplicationSpecificParser(tagNo, sp); - if ((tag & Asn1Tags.Tagged) != 0) - { - return new BerTaggedObjectParser(true, tagNo, sp); - } + return new BerTaggedObjectParser(true, tagNo, sp); + } - return sp.ReadIndef(tagNo); + return sp.ReadIndef(tagNo); } else { DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length, _limit); - if ((tag & Asn1Tags.Application) != 0) - { - return new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray()); - } + int tagClass = tag & Asn1Tags.Private; + if (0 != tagClass) + { + if ((tag & Asn1Tags.Application) != 0) + return new DerApplicationSpecific(isConstructed, tagNo, defIn.ToArray()); - if ((tag & Asn1Tags.Tagged) != 0) - { - return new BerTaggedObjectParser(isConstructed, tagNo, + return new BerTaggedObjectParser(isConstructed, tagNo, new Asn1StreamParser(defIn, defIn.Remaining, tmpBuffers)); - } + } if (!isConstructed) { -- cgit 1.4.1