diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-21 15:04:43 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-21 15:04:43 +0700 |
commit | eccbf9e1c26dc22c8f3966295057cafb718b5156 (patch) | |
tree | 3257cb92e8e3d0ffe9af55bf8b58acfd26855756 /crypto | |
parent | Port a few Java openpgp updates (diff) | |
download | BouncyCastle.NET-ed25519-eccbf9e1c26dc22c8f3966295057cafb718b5156.tar.xz |
[BMA-117]
Cope with redundant ExtendedKeyUsage entries
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/asn1/x509/ExtendedKeyUsage.cs | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/crypto/src/asn1/x509/ExtendedKeyUsage.cs b/crypto/src/asn1/x509/ExtendedKeyUsage.cs index b5e4b7f8d..57f769879 100644 --- a/crypto/src/asn1/x509/ExtendedKeyUsage.cs +++ b/crypto/src/asn1/x509/ExtendedKeyUsage.cs @@ -17,14 +17,14 @@ namespace Org.BouncyCastle.Asn1.X509 internal readonly IDictionary usageTable = Platform.CreateHashtable(); internal readonly Asn1Sequence seq; - public static ExtendedKeyUsage GetInstance( + public static ExtendedKeyUsage GetInstance( Asn1TaggedObject obj, bool explicitly) { return GetInstance(Asn1Sequence.GetInstance(obj, explicitly)); } - public static ExtendedKeyUsage GetInstance( + public static ExtendedKeyUsage GetInstance( object obj) { if (obj is ExtendedKeyUsage) @@ -32,43 +32,43 @@ namespace Org.BouncyCastle.Asn1.X509 return (ExtendedKeyUsage) obj; } - if (obj is Asn1Sequence) + if (obj is Asn1Sequence) { return new ExtendedKeyUsage((Asn1Sequence) obj); } - if (obj is X509Extension) - { - return GetInstance(X509Extension.ConvertValueToObject((X509Extension) obj)); - } + if (obj is X509Extension) + { + return GetInstance(X509Extension.ConvertValueToObject((X509Extension) obj)); + } - throw new ArgumentException("Invalid ExtendedKeyUsage: " + obj.GetType().Name); + throw new ArgumentException("Invalid ExtendedKeyUsage: " + obj.GetType().Name); } - private ExtendedKeyUsage( + private ExtendedKeyUsage( Asn1Sequence seq) { this.seq = seq; - foreach (object o in seq) - { - if (!(o is DerObjectIdentifier)) - throw new ArgumentException("Only DerObjectIdentifier instances allowed in ExtendedKeyUsage."); + foreach (object o in seq) + { + if (!(o is DerObjectIdentifier)) + throw new ArgumentException("Only DerObjectIdentifier instances allowed in ExtendedKeyUsage."); - this.usageTable.Add(o, o); + this.usageTable[o] = o; } } - public ExtendedKeyUsage( - params KeyPurposeID[] usages) - { - this.seq = new DerSequence(usages); + public ExtendedKeyUsage( + params KeyPurposeID[] usages) + { + this.seq = new DerSequence(usages); - foreach (KeyPurposeID usage in usages) - { - this.usageTable.Add(usage, usage); - } - } + foreach (KeyPurposeID usage in usages) + { + this.usageTable[usage] = usage; + } + } #if !SILVERLIGHT [Obsolete] @@ -84,20 +84,20 @@ namespace Org.BouncyCastle.Asn1.X509 { Asn1EncodableVector v = new Asn1EncodableVector(); - foreach (Asn1Object o in usages) + foreach (Asn1Object o in usages) { - v.Add(o); + v.Add(o); - this.usageTable.Add(o, o); + this.usageTable[o] = o; } - this.seq = new DerSequence(v); + this.seq = new DerSequence(v); } - public bool HasKeyPurposeId( + public bool HasKeyPurposeId( KeyPurposeID keyPurposeId) { - return usageTable[keyPurposeId] != null; + return usageTable.Contains(keyPurposeId); } #if !SILVERLIGHT @@ -109,21 +109,21 @@ namespace Org.BouncyCastle.Asn1.X509 #endif /** - * Returns all extended key usages. - * The returned ArrayList contains DerObjectIdentifier instances. - * @return An ArrayList with all key purposes. - */ - public IList GetAllUsages() - { - return Platform.CreateArrayList(usageTable.Values); - } + * Returns all extended key usages. + * The returned ArrayList contains DerObjectIdentifier instances. + * @return An ArrayList with all key purposes. + */ + public IList GetAllUsages() + { + return Platform.CreateArrayList(usageTable.Values); + } public int Count - { - get { return usageTable.Count; } - } + { + get { return usageTable.Count; } + } - public override Asn1Object ToAsn1Object() + public override Asn1Object ToAsn1Object() { return seq; } |