diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-02 22:30:53 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-02 22:30:53 +0700 |
commit | 9bd5d6e8c0d913251078ad52dee9e0cee2042087 (patch) | |
tree | 9868a08ab48fb864b83575a115025f0cf48fe064 /crypto/src/asn1 | |
parent | EC wNAF-related updates from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-9bd5d6e8c0d913251078ad52dee9e0cee2042087.tar.xz |
Handle x400Address as sequence in GeneralName
- add 'default' tag handler (instead of falling out of if-block)
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/x509/GeneralName.cs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/crypto/src/asn1/x509/GeneralName.cs b/crypto/src/asn1/x509/GeneralName.cs index b8794ea8f..fe00323ee 100644 --- a/crypto/src/asn1/x509/GeneralName.cs +++ b/crypto/src/asn1/x509/GeneralName.cs @@ -170,24 +170,25 @@ namespace Org.BouncyCastle.Asn1.X509 switch (tag) { - case OtherName: - return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false)); - case Rfc822Name: - return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false)); - case DnsName: - return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false)); - case X400Address: - throw new ArgumentException("unknown tag: " + tag); + case EdiPartyName: + case OtherName: + case X400Address: + return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false)); + + case DnsName: + case Rfc822Name: + case UniformResourceIdentifier: + return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false)); + case DirectoryName: return new GeneralName(tag, X509Name.GetInstance(tagObj, true)); - case EdiPartyName: - return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false)); - case UniformResourceIdentifier: - return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false)); case IPAddress: return new GeneralName(tag, Asn1OctetString.GetInstance(tagObj, false)); case RegisteredID: return new GeneralName(tag, DerObjectIdentifier.GetInstance(tagObj, false)); + + default: + throw new ArgumentException("unknown tag: " + tag); } } @@ -412,8 +413,10 @@ namespace Org.BouncyCastle.Asn1.X509 public override Asn1Object ToAsn1Object() { - // Explicitly tagged if DirectoryName - return new DerTaggedObject(tag == DirectoryName, tag, obj); + // directoryName is explicitly tagged as it is a CHOICE + bool isExplicit = (tag == DirectoryName); + + return new DerTaggedObject(isExplicit, tag, obj); } } } |