diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-20 18:44:07 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-20 18:44:07 +0700 |
commit | fe0abc8e4f4eb407a7fff3e5d567a51ce49a4baf (patch) | |
tree | 33f1beb1702c99430a033cd52b568b283319c487 /crypto/src/asn1/Asn1TaggedObject.cs | |
parent | ASN:1 tagged object parser updates from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-fe0abc8e4f4eb407a7fff3e5d567a51ce49a4baf.tar.xz |
ASN.1: Tagged object parser improvements
- add DLTaggedObjectParser - refactoring of Asn1InputStream/Asn1StreamParser
Diffstat (limited to 'crypto/src/asn1/Asn1TaggedObject.cs')
-rw-r--r-- | crypto/src/asn1/Asn1TaggedObject.cs | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/crypto/src/asn1/Asn1TaggedObject.cs b/crypto/src/asn1/Asn1TaggedObject.cs index c7c0db6fc..ce5e9e3f2 100644 --- a/crypto/src/asn1/Asn1TaggedObject.cs +++ b/crypto/src/asn1/Asn1TaggedObject.cs @@ -396,6 +396,11 @@ namespace Org.BouncyCastle.Asn1 return asn1Object; } + public IAsn1Convertible ParseExplicitBaseObject() + { + return GetExplicitBaseObject(); + } + public Asn1TaggedObjectParser ParseExplicitBaseTagged() { return GetExplicitBaseTagged(); @@ -417,38 +422,37 @@ namespace Org.BouncyCastle.Asn1 internal abstract Asn1TaggedObject ReplaceTag(int tagClass, int tagNo); - internal static Asn1Object CreateConstructed(int tagClass, int tagNo, bool isIL, - Asn1EncodableVector contentsElements) + internal static Asn1Object CreateConstructedDL(int tagClass, int tagNo, Asn1EncodableVector contentsElements) { bool maybeExplicit = (contentsElements.Count == 1); - if (isIL) - { - Asn1TaggedObject taggedObject = maybeExplicit - ? new BerTaggedObject(ParsedExplicit, tagClass, tagNo, contentsElements[0]) - : new BerTaggedObject(ParsedImplicit, tagClass, tagNo, BerSequence.FromVector(contentsElements)); + Asn1TaggedObject taggedObject = maybeExplicit + ? new DLTaggedObject(ParsedExplicit, tagClass, tagNo, contentsElements[0]) + : new DLTaggedObject(ParsedImplicit, tagClass, tagNo, DLSequence.FromVector(contentsElements)); - switch (tagClass) - { - case Asn1Tags.Application: - return new BerApplicationSpecific(taggedObject); - default: - return taggedObject; - } - } - else + switch (tagClass) { - Asn1TaggedObject taggedObject = maybeExplicit - ? new DLTaggedObject(ParsedExplicit, tagClass, tagNo, contentsElements[0]) - : new DLTaggedObject(ParsedImplicit, tagClass, tagNo, DLSequence.FromVector(contentsElements)); + case Asn1Tags.Application: + return new DLApplicationSpecific(taggedObject); + default: + return taggedObject; + } + } - switch (tagClass) - { - case Asn1Tags.Application: - return new DLApplicationSpecific(taggedObject); - default: - return taggedObject; - } + internal static Asn1Object CreateConstructedIL(int tagClass, int tagNo, Asn1EncodableVector contentsElements) + { + bool maybeExplicit = (contentsElements.Count == 1); + + Asn1TaggedObject taggedObject = maybeExplicit + ? new BerTaggedObject(ParsedExplicit, tagClass, tagNo, contentsElements[0]) + : new BerTaggedObject(ParsedImplicit, tagClass, tagNo, BerSequence.FromVector(contentsElements)); + + switch (tagClass) + { + case Asn1Tags.Application: + return new BerApplicationSpecific(taggedObject); + default: + return taggedObject; } } |