summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 20:17:15 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 20:17:15 +0700
commit5abe3db293d6dfed650a26bb9c3f5c839ccf2aa5 (patch)
treeca85019f4b26dee267ba20c8d9086ff0750076b6
parentFix up openssl test cases (diff)
downloadBouncyCastle.NET-ed25519-5abe3db293d6dfed650a26bb9c3f5c839ccf2aa5.tar.xz
BMA-119
Make GetValueList methods consistent
Remove obsolete X509Name methods
-rw-r--r--crypto/src/asn1/x509/X509Name.cs1097
-rw-r--r--crypto/test/src/asn1/test/X509NameTest.cs1202
2 files changed, 1097 insertions, 1202 deletions
diff --git a/crypto/src/asn1/x509/X509Name.cs b/crypto/src/asn1/x509/X509Name.cs
index a77707354..c183e5798 100644
--- a/crypto/src/asn1/x509/X509Name.cs
+++ b/crypto/src/asn1/x509/X509Name.cs
@@ -52,17 +52,17 @@ namespace Org.BouncyCastle.Asn1.X509
         */
         public static readonly DerObjectIdentifier CN = new DerObjectIdentifier("2.5.4.3");
 
-		/**
-		* street - StringType(SIZE(1..64))
-		*/
-		public static readonly DerObjectIdentifier Street = new DerObjectIdentifier("2.5.4.9");
+        /**
+        * street - StringType(SIZE(1..64))
+        */
+        public static readonly DerObjectIdentifier Street = new DerObjectIdentifier("2.5.4.9");
 
-		/**
-		* device serial number name - StringType(SIZE(1..64))
-		*/
-		public static readonly DerObjectIdentifier SerialNumber = new DerObjectIdentifier("2.5.4.5");
+        /**
+        * device serial number name - StringType(SIZE(1..64))
+        */
+        public static readonly DerObjectIdentifier SerialNumber = new DerObjectIdentifier("2.5.4.5");
 
-		/**
+        /**
         * locality name - StringType(SIZE(1..64))
         */
         public static readonly DerObjectIdentifier L = new DerObjectIdentifier("2.5.4.7");
@@ -81,89 +81,89 @@ namespace Org.BouncyCastle.Asn1.X509
         public static readonly DerObjectIdentifier Generation = new DerObjectIdentifier("2.5.4.44");
         public static readonly DerObjectIdentifier UniqueIdentifier = new DerObjectIdentifier("2.5.4.45");
 
-		/**
-		 * businessCategory - DirectoryString(SIZE(1..128)
-		 */
-		public static readonly DerObjectIdentifier BusinessCategory = new DerObjectIdentifier(
-																	   "2.5.4.15");
-
-		/**
-		 * postalCode - DirectoryString(SIZE(1..40)
-		 */
-		public static readonly DerObjectIdentifier PostalCode = new DerObjectIdentifier(
-																 "2.5.4.17");
-
-		/**
-		 * dnQualifier - DirectoryString(SIZE(1..64)
-		 */
-		public static readonly DerObjectIdentifier DnQualifier = new DerObjectIdentifier(
-														 "2.5.4.46");
-
-		/**
-		 * RFC 3039 Pseudonym - DirectoryString(SIZE(1..64)
-		 */
-		public static readonly DerObjectIdentifier Pseudonym = new DerObjectIdentifier(
-																"2.5.4.65");
-
-		/**
-		 * RFC 3039 DateOfBirth - GeneralizedTime - YYYYMMDD000000Z
-		 */
-		public static readonly DerObjectIdentifier DateOfBirth = new DerObjectIdentifier(
-																  "1.3.6.1.5.5.7.9.1");
-
-		/**
-		 * RFC 3039 PlaceOfBirth - DirectoryString(SIZE(1..128)
-		 */
-		public static readonly DerObjectIdentifier PlaceOfBirth = new DerObjectIdentifier(
-																   "1.3.6.1.5.5.7.9.2");
-
-		/**
-		 * RFC 3039 DateOfBirth - PrintableString (SIZE(1)) -- "M", "F", "m" or "f"
-		 */
-		public static readonly DerObjectIdentifier Gender = new DerObjectIdentifier(
-																   "1.3.6.1.5.5.7.9.3");
-
-		/**
-		 * RFC 3039 CountryOfCitizenship - PrintableString (SIZE (2)) -- ISO 3166
-		 * codes only
-		 */
-		public static readonly DerObjectIdentifier CountryOfCitizenship = new DerObjectIdentifier(
-																		   "1.3.6.1.5.5.7.9.4");
-
-		/**
-		 * RFC 3039 CountryOfCitizenship - PrintableString (SIZE (2)) -- ISO 3166
-		 * codes only
-		 */
-		public static readonly DerObjectIdentifier CountryOfResidence = new DerObjectIdentifier(
-																		 "1.3.6.1.5.5.7.9.5");
-
-		/**
-		 * ISIS-MTT NameAtBirth - DirectoryString(SIZE(1..64)
-		 */
-		public static readonly DerObjectIdentifier NameAtBirth =  new DerObjectIdentifier("1.3.36.8.3.14");
-
-		/**
-		 * RFC 3039 PostalAddress - SEQUENCE SIZE (1..6) OF
-		 * DirectoryString(SIZE(1..30))
-		 */
-		public static readonly DerObjectIdentifier PostalAddress = new DerObjectIdentifier("2.5.4.16");
-
-		/**
-		 * RFC 2256 dmdName
-		 */
-		public static readonly DerObjectIdentifier DmdName = new DerObjectIdentifier("2.5.4.54");
-
-		/**
-		 * id-at-telephoneNumber
-		 */
-		public static readonly DerObjectIdentifier TelephoneNumber = X509ObjectIdentifiers.id_at_telephoneNumber;
-
-		/**
-		 * id-at-name
-		 */
-		public static readonly DerObjectIdentifier Name = X509ObjectIdentifiers.id_at_name;
-
-		/**
+        /**
+         * businessCategory - DirectoryString(SIZE(1..128)
+         */
+        public static readonly DerObjectIdentifier BusinessCategory = new DerObjectIdentifier(
+                                                                       "2.5.4.15");
+
+        /**
+         * postalCode - DirectoryString(SIZE(1..40)
+         */
+        public static readonly DerObjectIdentifier PostalCode = new DerObjectIdentifier(
+                                                                 "2.5.4.17");
+
+        /**
+         * dnQualifier - DirectoryString(SIZE(1..64)
+         */
+        public static readonly DerObjectIdentifier DnQualifier = new DerObjectIdentifier(
+                                                         "2.5.4.46");
+
+        /**
+         * RFC 3039 Pseudonym - DirectoryString(SIZE(1..64)
+         */
+        public static readonly DerObjectIdentifier Pseudonym = new DerObjectIdentifier(
+                                                                "2.5.4.65");
+
+        /**
+         * RFC 3039 DateOfBirth - GeneralizedTime - YYYYMMDD000000Z
+         */
+        public static readonly DerObjectIdentifier DateOfBirth = new DerObjectIdentifier(
+                                                                  "1.3.6.1.5.5.7.9.1");
+
+        /**
+         * RFC 3039 PlaceOfBirth - DirectoryString(SIZE(1..128)
+         */
+        public static readonly DerObjectIdentifier PlaceOfBirth = new DerObjectIdentifier(
+                                                                   "1.3.6.1.5.5.7.9.2");
+
+        /**
+         * RFC 3039 DateOfBirth - PrintableString (SIZE(1)) -- "M", "F", "m" or "f"
+         */
+        public static readonly DerObjectIdentifier Gender = new DerObjectIdentifier(
+                                                                   "1.3.6.1.5.5.7.9.3");
+
+        /**
+         * RFC 3039 CountryOfCitizenship - PrintableString (SIZE (2)) -- ISO 3166
+         * codes only
+         */
+        public static readonly DerObjectIdentifier CountryOfCitizenship = new DerObjectIdentifier(
+                                                                           "1.3.6.1.5.5.7.9.4");
+
+        /**
+         * RFC 3039 CountryOfCitizenship - PrintableString (SIZE (2)) -- ISO 3166
+         * codes only
+         */
+        public static readonly DerObjectIdentifier CountryOfResidence = new DerObjectIdentifier(
+                                                                         "1.3.6.1.5.5.7.9.5");
+
+        /**
+         * ISIS-MTT NameAtBirth - DirectoryString(SIZE(1..64)
+         */
+        public static readonly DerObjectIdentifier NameAtBirth =  new DerObjectIdentifier("1.3.36.8.3.14");
+
+        /**
+         * RFC 3039 PostalAddress - SEQUENCE SIZE (1..6) OF
+         * DirectoryString(SIZE(1..30))
+         */
+        public static readonly DerObjectIdentifier PostalAddress = new DerObjectIdentifier("2.5.4.16");
+
+        /**
+         * RFC 2256 dmdName
+         */
+        public static readonly DerObjectIdentifier DmdName = new DerObjectIdentifier("2.5.4.54");
+
+        /**
+         * id-at-telephoneNumber
+         */
+        public static readonly DerObjectIdentifier TelephoneNumber = X509ObjectIdentifiers.id_at_telephoneNumber;
+
+        /**
+         * id-at-name
+         */
+        public static readonly DerObjectIdentifier Name = X509ObjectIdentifiers.id_at_name;
+
+        /**
         * Email address (RSA PKCS#9 extension) - IA5String.
         * <p>Note: if you're trying to be ultra orthodox, don't use this! It shouldn't be in here.</p>
         */
@@ -195,31 +195,31 @@ namespace Org.BouncyCastle.Asn1.X509
         * from back to front.
         */
 //        public static bool DefaultReverse = false;
-		public static bool DefaultReverse
-		{
-			get { return defaultReverse[0]; }
-			set { defaultReverse[0] = value; }
-		}
+        public static bool DefaultReverse
+        {
+            get { return defaultReverse[0]; }
+            set { defaultReverse[0] = value; }
+        }
 
-		private static readonly bool[] defaultReverse = { false };
+        private static readonly bool[] defaultReverse = { false };
 
 #if SILVERLIGHT
-		/**
-		* default look up table translating OID values into their common symbols following
-		* the convention in RFC 2253 with a few extras
-		*/
-		public static readonly IDictionary DefaultSymbols = Platform.CreateHashtable();
-
-		/**
-		 * look up table translating OID values into their common symbols following the convention in RFC 2253
-		 */
-		public static readonly IDictionary RFC2253Symbols = Platform.CreateHashtable();
-
-		/**
-		 * look up table translating OID values into their common symbols following the convention in RFC 1779
-		 *
-		 */
-		public static readonly IDictionary RFC1779Symbols = Platform.CreateHashtable();
+        /**
+        * default look up table translating OID values into their common symbols following
+        * the convention in RFC 2253 with a few extras
+        */
+        public static readonly IDictionary DefaultSymbols = Platform.CreateHashtable();
+
+        /**
+         * look up table translating OID values into their common symbols following the convention in RFC 2253
+         */
+        public static readonly IDictionary RFC2253Symbols = Platform.CreateHashtable();
+
+        /**
+         * look up table translating OID values into their common symbols following the convention in RFC 1779
+         *
+         */
+        public static readonly IDictionary RFC1779Symbols = Platform.CreateHashtable();
 
         /**
         * look up table translating common symbols into their OIDS.
@@ -227,21 +227,21 @@ namespace Org.BouncyCastle.Asn1.X509
         public static readonly IDictionary DefaultLookup = Platform.CreateHashtable();
 #else
         /**
-		* default look up table translating OID values into their common symbols following
-		* the convention in RFC 2253 with a few extras
-		*/
-		public static readonly Hashtable DefaultSymbols = new Hashtable();
-
-		/**
-		 * look up table translating OID values into their common symbols following the convention in RFC 2253
-		 */
-		public static readonly Hashtable RFC2253Symbols = new Hashtable();
-
-		/**
-		 * look up table translating OID values into their common symbols following the convention in RFC 1779
-		 *
-		 */
-		public static readonly Hashtable RFC1779Symbols = new Hashtable();
+        * default look up table translating OID values into their common symbols following
+        * the convention in RFC 2253 with a few extras
+        */
+        public static readonly Hashtable DefaultSymbols = new Hashtable();
+
+        /**
+         * look up table translating OID values into their common symbols following the convention in RFC 2253
+         */
+        public static readonly Hashtable RFC2253Symbols = new Hashtable();
+
+        /**
+         * look up table translating OID values into their common symbols following the convention in RFC 1779
+         *
+         */
+        public static readonly Hashtable RFC1779Symbols = new Hashtable();
 
         /**
         * look up table translating common symbols into their OIDS.
@@ -262,26 +262,26 @@ namespace Org.BouncyCastle.Asn1.X509
             DefaultSymbols.Add(EmailAddress, "E");
             DefaultSymbols.Add(DC, "DC");
             DefaultSymbols.Add(UID, "UID");
-			DefaultSymbols.Add(Street, "STREET");
+            DefaultSymbols.Add(Street, "STREET");
             DefaultSymbols.Add(Surname, "SURNAME");
             DefaultSymbols.Add(GivenName, "GIVENNAME");
             DefaultSymbols.Add(Initials, "INITIALS");
             DefaultSymbols.Add(Generation, "GENERATION");
             DefaultSymbols.Add(UnstructuredAddress, "unstructuredAddress");
             DefaultSymbols.Add(UnstructuredName, "unstructuredName");
-			DefaultSymbols.Add(UniqueIdentifier, "UniqueIdentifier");
-			DefaultSymbols.Add(DnQualifier, "DN");
-			DefaultSymbols.Add(Pseudonym, "Pseudonym");
-			DefaultSymbols.Add(PostalAddress, "PostalAddress");
-			DefaultSymbols.Add(NameAtBirth, "NameAtBirth");
-			DefaultSymbols.Add(CountryOfCitizenship, "CountryOfCitizenship");
-			DefaultSymbols.Add(CountryOfResidence, "CountryOfResidence");
-			DefaultSymbols.Add(Gender, "Gender");
-			DefaultSymbols.Add(PlaceOfBirth, "PlaceOfBirth");
-			DefaultSymbols.Add(DateOfBirth, "DateOfBirth");
-			DefaultSymbols.Add(PostalCode, "PostalCode");
-			DefaultSymbols.Add(BusinessCategory, "BusinessCategory");
-			DefaultSymbols.Add(TelephoneNumber, "TelephoneNumber");
+            DefaultSymbols.Add(UniqueIdentifier, "UniqueIdentifier");
+            DefaultSymbols.Add(DnQualifier, "DN");
+            DefaultSymbols.Add(Pseudonym, "Pseudonym");
+            DefaultSymbols.Add(PostalAddress, "PostalAddress");
+            DefaultSymbols.Add(NameAtBirth, "NameAtBirth");
+            DefaultSymbols.Add(CountryOfCitizenship, "CountryOfCitizenship");
+            DefaultSymbols.Add(CountryOfResidence, "CountryOfResidence");
+            DefaultSymbols.Add(Gender, "Gender");
+            DefaultSymbols.Add(PlaceOfBirth, "PlaceOfBirth");
+            DefaultSymbols.Add(DateOfBirth, "DateOfBirth");
+            DefaultSymbols.Add(PostalCode, "PostalCode");
+            DefaultSymbols.Add(BusinessCategory, "BusinessCategory");
+            DefaultSymbols.Add(TelephoneNumber, "TelephoneNumber");
 
             RFC2253Symbols.Add(C, "C");
             RFC2253Symbols.Add(O, "O");
@@ -289,28 +289,28 @@ namespace Org.BouncyCastle.Asn1.X509
             RFC2253Symbols.Add(CN, "CN");
             RFC2253Symbols.Add(L, "L");
             RFC2253Symbols.Add(ST, "ST");
-			RFC2253Symbols.Add(Street, "STREET");
-			RFC2253Symbols.Add(DC, "DC");
+            RFC2253Symbols.Add(Street, "STREET");
+            RFC2253Symbols.Add(DC, "DC");
             RFC2253Symbols.Add(UID, "UID");
 
-			RFC1779Symbols.Add(C, "C");
-			RFC1779Symbols.Add(O, "O");
-			RFC1779Symbols.Add(OU, "OU");
-			RFC1779Symbols.Add(CN, "CN");
-			RFC1779Symbols.Add(L, "L");
-			RFC1779Symbols.Add(ST, "ST");
-			RFC1779Symbols.Add(Street, "STREET");
+            RFC1779Symbols.Add(C, "C");
+            RFC1779Symbols.Add(O, "O");
+            RFC1779Symbols.Add(OU, "OU");
+            RFC1779Symbols.Add(CN, "CN");
+            RFC1779Symbols.Add(L, "L");
+            RFC1779Symbols.Add(ST, "ST");
+            RFC1779Symbols.Add(Street, "STREET");
 
-			DefaultLookup.Add("c", C);
+            DefaultLookup.Add("c", C);
             DefaultLookup.Add("o", O);
             DefaultLookup.Add("t", T);
             DefaultLookup.Add("ou", OU);
             DefaultLookup.Add("cn", CN);
             DefaultLookup.Add("l", L);
             DefaultLookup.Add("st", ST);
-			DefaultLookup.Add("serialnumber", SerialNumber);
-			DefaultLookup.Add("street", Street);
-			DefaultLookup.Add("emailaddress", E);
+            DefaultLookup.Add("serialnumber", SerialNumber);
+            DefaultLookup.Add("street", Street);
+            DefaultLookup.Add("emailaddress", E);
             DefaultLookup.Add("dc", DC);
             DefaultLookup.Add("e", E);
             DefaultLookup.Add("uid", UID);
@@ -320,29 +320,29 @@ namespace Org.BouncyCastle.Asn1.X509
             DefaultLookup.Add("generation", Generation);
             DefaultLookup.Add("unstructuredaddress", UnstructuredAddress);
             DefaultLookup.Add("unstructuredname", UnstructuredName);
-			DefaultLookup.Add("uniqueidentifier", UniqueIdentifier);
-			DefaultLookup.Add("dn", DnQualifier);
-			DefaultLookup.Add("pseudonym", Pseudonym);
-			DefaultLookup.Add("postaladdress", PostalAddress);
-			DefaultLookup.Add("nameofbirth", NameAtBirth);
-			DefaultLookup.Add("countryofcitizenship", CountryOfCitizenship);
-			DefaultLookup.Add("countryofresidence", CountryOfResidence);
-			DefaultLookup.Add("gender", Gender);
-			DefaultLookup.Add("placeofbirth", PlaceOfBirth);
-			DefaultLookup.Add("dateofbirth", DateOfBirth);
-			DefaultLookup.Add("postalcode", PostalCode);
-			DefaultLookup.Add("businesscategory", BusinessCategory);
-			DefaultLookup.Add("telephonenumber", TelephoneNumber);
-		}
+            DefaultLookup.Add("uniqueidentifier", UniqueIdentifier);
+            DefaultLookup.Add("dn", DnQualifier);
+            DefaultLookup.Add("pseudonym", Pseudonym);
+            DefaultLookup.Add("postaladdress", PostalAddress);
+            DefaultLookup.Add("nameofbirth", NameAtBirth);
+            DefaultLookup.Add("countryofcitizenship", CountryOfCitizenship);
+            DefaultLookup.Add("countryofresidence", CountryOfResidence);
+            DefaultLookup.Add("gender", Gender);
+            DefaultLookup.Add("placeofbirth", PlaceOfBirth);
+            DefaultLookup.Add("dateofbirth", DateOfBirth);
+            DefaultLookup.Add("postalcode", PostalCode);
+            DefaultLookup.Add("businesscategory", BusinessCategory);
+            DefaultLookup.Add("telephonenumber", TelephoneNumber);
+        }
 
         private readonly IList ordering = Platform.CreateArrayList();
-		private readonly X509NameEntryConverter converter;
+        private readonly X509NameEntryConverter converter;
 
-		private IList		    values = Platform.CreateArrayList();
+        private IList		    values = Platform.CreateArrayList();
         private IList           added = Platform.CreateArrayList();
         private Asn1Sequence	seq;
 
-		/**
+        /**
         * Return a X509Name based on the passed in tagged object.
         *
         * @param obj tag object holding name.
@@ -356,23 +356,23 @@ namespace Org.BouncyCastle.Asn1.X509
             return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
         }
 
-		public static X509Name GetInstance(
+        public static X509Name GetInstance(
             object obj)
         {
             if (obj == null || obj is X509Name)
                 return (X509Name)obj;
 
-			if (obj != null)
-				return new X509Name(Asn1Sequence.GetInstance(obj));
+            if (obj != null)
+                return new X509Name(Asn1Sequence.GetInstance(obj));
 
-			throw new ArgumentException("null object in factory", "obj");
+            throw new ArgumentException("null object in factory", "obj");
         }
 
-		protected X509Name()
-		{
-		}
+        protected X509Name()
+        {
+        }
 
-		/**
+        /**
         * Constructor from Asn1Sequence
         *
         * the principal will be a list of constructed sets, each containing an (OID, string) pair.
@@ -382,50 +382,40 @@ namespace Org.BouncyCastle.Asn1.X509
         {
             this.seq = seq;
 
-			foreach (Asn1Encodable asn1Obj in seq)
-			{
-				Asn1Set asn1Set = Asn1Set.GetInstance(asn1Obj.ToAsn1Object());
+            foreach (Asn1Encodable asn1Obj in seq)
+            {
+                Asn1Set asn1Set = Asn1Set.GetInstance(asn1Obj.ToAsn1Object());
 
-				for (int i = 0; i < asn1Set.Count; i++)
+                for (int i = 0; i < asn1Set.Count; i++)
                 {
-					Asn1Sequence s = Asn1Sequence.GetInstance(asn1Set[i].ToAsn1Object());
+                    Asn1Sequence s = Asn1Sequence.GetInstance(asn1Set[i].ToAsn1Object());
 
-					if (s.Count != 2)
-						throw new ArgumentException("badly sized pair");
+                    if (s.Count != 2)
+                        throw new ArgumentException("badly sized pair");
 
-					ordering.Add(DerObjectIdentifier.GetInstance(s[0].ToAsn1Object()));
+                    ordering.Add(DerObjectIdentifier.GetInstance(s[0].ToAsn1Object()));
 
-					Asn1Object derValue = s[1].ToAsn1Object();
-					if (derValue is IAsn1String && !(derValue is DerUniversalString))
-					{
-						string v = ((IAsn1String)derValue).GetString();
-						if (v.StartsWith("#"))
-						{
-							v = "\\" + v;
-						}
+                    Asn1Object derValue = s[1].ToAsn1Object();
+                    if (derValue is IAsn1String && !(derValue is DerUniversalString))
+                    {
+                        string v = ((IAsn1String)derValue).GetString();
+                        if (v.StartsWith("#"))
+                        {
+                            v = "\\" + v;
+                        }
 
-						values.Add(v);
-					}
+                        values.Add(v);
+                    }
                     else
                     {
-						values.Add("#" + Hex.ToHexString(derValue.GetEncoded()));
+                        values.Add("#" + Hex.ToHexString(derValue.GetEncoded()));
                     }
 
-					added.Add(i != 0);
+                    added.Add(i != 0);
                 }
             }
         }
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public X509Name(
-            ArrayList ordering,
-            Hashtable attributes)
-            : this(ordering, attributes, new X509DefaultEntryConverter())
-        {
-        }
-#endif
-
         /**
         * Constructor from a table of attributes with ordering.
         * <p>
@@ -441,18 +431,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public X509Name(
-            ArrayList				ordering,
-            Hashtable				attributes,
-            X509NameEntryConverter	converter)
-            : this((IList)ordering, (IDictionary)attributes, converter)
-        {
-        }
-#endif
-
-		/**
+        /**
         * Constructor from a table of attributes with ordering.
         * <p>
         * it's is assumed the table contains OID/string pairs, and the contents
@@ -468,33 +447,23 @@ namespace Org.BouncyCastle.Asn1.X509
             IDictionary             attributes,
             X509NameEntryConverter	converter)
         {
-			this.converter = converter;
-
-			foreach (DerObjectIdentifier oid in ordering)
-			{
-				object attribute = attributes[oid];
-				if (attribute == null)
-				{
-					throw new ArgumentException("No attribute for object id - " + oid + " - passed to distinguished name");
-				}
-
-				this.ordering.Add(oid);
-				this.added.Add(false);
-				this.values.Add(attribute); // copy the hash table
-			}
-        }
+            this.converter = converter;
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public X509Name(
-            ArrayList oids,
-            ArrayList values)
-            : this(oids, values, new X509DefaultEntryConverter())
-        {
+            foreach (DerObjectIdentifier oid in ordering)
+            {
+                object attribute = attributes[oid];
+                if (attribute == null)
+                {
+                    throw new ArgumentException("No attribute for object id - " + oid + " - passed to distinguished name");
+                }
+
+                this.ordering.Add(oid);
+                this.added.Add(false);
+                this.values.Add(attribute); // copy the hash table
+            }
         }
-#endif
 
-		/**
+        /**
         * Takes two vectors one of the oids and the other of the values.
         */
         public X509Name(
@@ -504,18 +473,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public X509Name(
-            ArrayList				oids,
-            ArrayList				values,
-            X509NameEntryConverter	converter)
-            : this((IList)oids, (IList)values, converter)
-        {
-        }
-#endif
-
-		/**
+        /**
         * Takes two vectors one of the oids and the other of the values.
         * <p>
         * The passed in converter will be used to convert the strings into their
@@ -528,12 +486,12 @@ namespace Org.BouncyCastle.Asn1.X509
         {
             this.converter = converter;
 
-			if (oids.Count != values.Count)
+            if (oids.Count != values.Count)
             {
                 throw new ArgumentException("'oids' must be same length as 'values'.");
             }
 
-			for (int i = 0; i < oids.Count; i++)
+            for (int i = 0; i < oids.Count; i++)
             {
                 this.ordering.Add(oids[i]);
                 this.values.Add(values[i]);
@@ -547,7 +505,7 @@ namespace Org.BouncyCastle.Asn1.X509
 //			return s.StartsWith("#");
 //		}
 
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes.
         */
@@ -557,7 +515,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes with each
         * string value being converted to its associated ASN.1 type using the passed
@@ -570,7 +528,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes. If reverse
         * is true, create the encoded version of the sequence starting from the
@@ -583,7 +541,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes with each
         * string value being converted to its associated ASN.1 type using the passed
@@ -598,18 +556,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public X509Name(
-            bool reverse,
-            Hashtable lookUp,
-            string dirName)
-            : this(reverse, lookUp, dirName, new X509DefaultEntryConverter())
-        {
-        }
-#endif
-
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes. lookUp
         * should provide a table of lookups, indexed by lowercase only strings and
@@ -630,7 +577,7 @@ namespace Org.BouncyCastle.Asn1.X509
         {
         }
 
-		private DerObjectIdentifier DecodeOid(
+        private DerObjectIdentifier DecodeOid(
             string		name,
             IDictionary lookUp)
         {
@@ -643,16 +590,16 @@ namespace Org.BouncyCastle.Asn1.X509
                 return new DerObjectIdentifier(name);
             }
 
-			DerObjectIdentifier oid = (DerObjectIdentifier)lookUp[Platform.ToLowerInvariant(name)];
+            DerObjectIdentifier oid = (DerObjectIdentifier)lookUp[Platform.ToLowerInvariant(name)];
             if (oid == null)
             {
                 throw new ArgumentException("Unknown object id - " + name + " - passed to distinguished name");
             }
 
-			return oid;
+            return oid;
         }
 
-		/**
+        /**
         * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
         * some such, converting it into an ordered set of name attributes. lookUp
         * should provide a table of lookups, indexed by lowercase only strings and
@@ -674,30 +621,30 @@ namespace Org.BouncyCastle.Asn1.X509
             this.converter = converter;
             X509NameTokenizer nTok = new X509NameTokenizer(dirName);
 
-			while (nTok.HasMoreTokens())
+            while (nTok.HasMoreTokens())
             {
                 string token = nTok.NextToken();
                 int index = token.IndexOf('=');
 
-				if (index == -1)
+                if (index == -1)
                 {
                     throw new ArgumentException("badly formated directory string");
                 }
 
-				string name = token.Substring(0, index);
+                string name = token.Substring(0, index);
                 string value = token.Substring(index + 1);
                 DerObjectIdentifier	oid = DecodeOid(name, lookUp);
 
-				if (value.IndexOf('+') > 0)
+                if (value.IndexOf('+') > 0)
                 {
                     X509NameTokenizer vTok = new X509NameTokenizer(value, '+');
-					string v = vTok.NextToken();
+                    string v = vTok.NextToken();
 
-					this.ordering.Add(oid);
+                    this.ordering.Add(oid);
                     this.values.Add(v);
                     this.added.Add(false);
 
-					while (vTok.HasMoreTokens())
+                    while (vTok.HasMoreTokens())
                     {
                         string sv = vTok.NextToken();
                         int ndx = sv.IndexOf('=');
@@ -717,46 +664,35 @@ namespace Org.BouncyCastle.Asn1.X509
                 }
             }
 
-			if (reverse)
+            if (reverse)
             {
 //				this.ordering.Reverse();
 //				this.values.Reverse();
 //				this.added.Reverse();
-				IList o = Platform.CreateArrayList();
+                IList o = Platform.CreateArrayList();
                 IList v = Platform.CreateArrayList();
                 IList a = Platform.CreateArrayList();
-				int count = 1;
-
-				for (int i = 0; i < this.ordering.Count; i++)
-				{
-					if (!((bool) this.added[i]))
-					{
-						count = 0;
-					}
-
-					int index = count++;
-
-					o.Insert(index, this.ordering[i]);
-					v.Insert(index, this.values[i]);
-					a.Insert(index, this.added[i]);
-				}
-
-				this.ordering = o;
-				this.values = v;
-				this.added = a;
-			}
-        }
+                int count = 1;
 
-#if !SILVERLIGHT
-		/**
-		* return an ArrayList of the oids in the name, in the order they were found.
-		*/
-        [Obsolete("Use 'GetOidList' instead")]
-        public ArrayList GetOids()
-        {
-            return new ArrayList(ordering);
+                for (int i = 0; i < this.ordering.Count; i++)
+                {
+                    if (!((bool) this.added[i]))
+                    {
+                        count = 0;
+                    }
+
+                    int index = count++;
+
+                    o.Insert(index, this.ordering[i]);
+                    v.Insert(index, this.values[i]);
+                    a.Insert(index, this.added[i]);
+                }
+
+                this.ordering = o;
+                this.values = v;
+                this.added = a;
+            }
         }
-#endif
 
         /**
         * return an IList of the oids in the name, in the order they were found.
@@ -766,57 +702,25 @@ namespace Org.BouncyCastle.Asn1.X509
             return Platform.CreateArrayList(ordering);
         }
 
-#if !SILVERLIGHT
-		/**
-		* return an ArrayList of the values found in the name, in the order they
-		* were found.
-		*/
-        [Obsolete("Use 'GetValueList' instead")]
-		public ArrayList GetValues()
-		{
-            return new ArrayList(values);
-		}
-#endif
-
         /**
         * return an IList of the values found in the name, in the order they
         * were found.
         */
         public IList GetValueList()
         {
-            return Platform.CreateArrayList(values);
+            return GetValueList(null);
         }
 
-#if !SILVERLIGHT
-		/**
-		 * return an ArrayList of the values found in the name, in the order they
-		 * were found, with the DN label corresponding to passed in oid.
-		 */
-		public ArrayList GetValues(
-			DerObjectIdentifier oid)
-		{
-			ArrayList v = new ArrayList();
-            DoGetValueList(oid, v);
-			return v;
-		}
-#endif
-
-		/**
-		 * return an IList of the values found in the name, in the order they
-		 * were found, with the DN label corresponding to passed in oid.
-		 */
+        /**
+         * return an IList of the values found in the name, in the order they
+         * were found, with the DN label corresponding to passed in oid.
+         */
         public IList GetValueList(DerObjectIdentifier oid)
         {
             IList v = Platform.CreateArrayList();
-            DoGetValueList(oid, v);
-            return v;
-        }
-
-        private void DoGetValueList(DerObjectIdentifier oid, IList v)
-        {
             for (int i = 0; i != values.Count; i++)
             {
-                if (ordering[i].Equals(oid))
+                if (null == oid || oid.Equals(ordering[i]))
                 {
                     string val = (string)values[i];
 
@@ -828,9 +732,10 @@ namespace Org.BouncyCastle.Asn1.X509
                     v.Add(val);
                 }
             }
+            return v;
         }
 
-		public override Asn1Object ToAsn1Object()
+        public override Asn1Object ToAsn1Object()
         {
             if (seq == null)
             {
@@ -838,12 +743,12 @@ namespace Org.BouncyCastle.Asn1.X509
                 Asn1EncodableVector sVec = new Asn1EncodableVector();
                 DerObjectIdentifier lstOid = null;
 
-				for (int i = 0; i != ordering.Count; i++)
+                for (int i = 0; i != ordering.Count; i++)
                 {
                     DerObjectIdentifier oid = (DerObjectIdentifier)ordering[i];
-					string str = (string)values[i];
+                    string str = (string)values[i];
 
-					if (lstOid == null
+                    if (lstOid == null
                         || ((bool)this.added[i]))
                     {
                     }
@@ -853,211 +758,211 @@ namespace Org.BouncyCastle.Asn1.X509
                         sVec = new Asn1EncodableVector();
                     }
 
-					sVec.Add(
-						new DerSequence(
-							oid,
-							converter.GetConvertedValue(oid, str)));
+                    sVec.Add(
+                        new DerSequence(
+                            oid,
+                            converter.GetConvertedValue(oid, str)));
 
-					lstOid = oid;
+                    lstOid = oid;
                 }
 
-				vec.Add(new DerSet(sVec));
+                vec.Add(new DerSet(sVec));
 
-				seq = new DerSequence(vec);
+                seq = new DerSequence(vec);
             }
 
             return seq;
         }
 
         /// <param name="other">The X509Name object to test equivalency against.</param>
-		/// <param name="inOrder">If true, the order of elements must be the same,
-		/// as well as the values associated with each element.</param>
-		public bool Equivalent(
-			X509Name	other,
-			bool		inOrder)
-		{
-			if (!inOrder)
-				return this.Equivalent(other);
+        /// <param name="inOrder">If true, the order of elements must be the same,
+        /// as well as the values associated with each element.</param>
+        public bool Equivalent(
+            X509Name	other,
+            bool		inOrder)
+        {
+            if (!inOrder)
+                return this.Equivalent(other);
 
-			if (other == null)
-				return false;
+            if (other == null)
+                return false;
 
-			if (other == this)
-				return true;
+            if (other == this)
+                return true;
 
-			int orderingSize = ordering.Count;
+            int orderingSize = ordering.Count;
 
-			if (orderingSize != other.ordering.Count)
-				return false;
+            if (orderingSize != other.ordering.Count)
+                return false;
 
-			for (int i = 0; i < orderingSize; i++)
-			{
-				DerObjectIdentifier oid = (DerObjectIdentifier) ordering[i];
-				DerObjectIdentifier oOid = (DerObjectIdentifier) other.ordering[i];
+            for (int i = 0; i < orderingSize; i++)
+            {
+                DerObjectIdentifier oid = (DerObjectIdentifier) ordering[i];
+                DerObjectIdentifier oOid = (DerObjectIdentifier) other.ordering[i];
 
-				if (!oid.Equals(oOid))
-					return false;
+                if (!oid.Equals(oOid))
+                    return false;
 
-				string val = (string) values[i];
-				string oVal = (string) other.values[i];
+                string val = (string) values[i];
+                string oVal = (string) other.values[i];
 
-				if (!equivalentStrings(val, oVal))
-					return false;
-			}
+                if (!equivalentStrings(val, oVal))
+                    return false;
+            }
 
-			return true;
-		}
+            return true;
+        }
 
         /**
-		 * test for equivalence - note: case is ignored.
-		 */
-		public bool Equivalent(
-			X509Name other)
-		{
-			if (other == null)
-				return false;
-
-			if (other == this)
-				return true;
-
-			int orderingSize = ordering.Count;
-
-			if (orderingSize != other.ordering.Count)
-			{
-				return false;
-			}
-
-			bool[] indexes = new bool[orderingSize];
-			int start, end, delta;
-
-			if (ordering[0].Equals(other.ordering[0]))   // guess forward
-			{
-				start = 0;
-				end = orderingSize;
-				delta = 1;
-			}
-			else  // guess reversed - most common problem
-			{
-				start = orderingSize - 1;
-				end = -1;
-				delta = -1;
-			}
-
-			for (int i = start; i != end; i += delta)
-			{
-				bool found = false;
-				DerObjectIdentifier  oid = (DerObjectIdentifier)ordering[i];
-				string value = (string)values[i];
-
-				for (int j = 0; j < orderingSize; j++)
-				{
-					if (indexes[j])
-					{
-						continue;
-					}
-
-					DerObjectIdentifier oOid = (DerObjectIdentifier)other.ordering[j];
-
-					if (oid.Equals(oOid))
-					{
-						string oValue = (string)other.values[j];
-
-						if (equivalentStrings(value, oValue))
-						{
-							indexes[j] = true;
-							found      = true;
-							break;
-						}
-					}
-				}
-
-				if (!found)
-				{
-					return false;
-				}
-			}
-
-			return true;
-		}
-
-		private static bool equivalentStrings(
-			string	s1,
-			string	s2)
-		{
-			string v1 = canonicalize(s1);
-			string v2 = canonicalize(s2);
-
-			if (!v1.Equals(v2))
-			{
-				v1 = stripInternalSpaces(v1);
-				v2 = stripInternalSpaces(v2);
-
-				if (!v1.Equals(v2))
-				{
-					return false;
-				}
-			}
-
-			return true;
-		}
-
-		private static string canonicalize(
-			string s)
-		{
+         * test for equivalence - note: case is ignored.
+         */
+        public bool Equivalent(
+            X509Name other)
+        {
+            if (other == null)
+                return false;
+
+            if (other == this)
+                return true;
+
+            int orderingSize = ordering.Count;
+
+            if (orderingSize != other.ordering.Count)
+            {
+                return false;
+            }
+
+            bool[] indexes = new bool[orderingSize];
+            int start, end, delta;
+
+            if (ordering[0].Equals(other.ordering[0]))   // guess forward
+            {
+                start = 0;
+                end = orderingSize;
+                delta = 1;
+            }
+            else  // guess reversed - most common problem
+            {
+                start = orderingSize - 1;
+                end = -1;
+                delta = -1;
+            }
+
+            for (int i = start; i != end; i += delta)
+            {
+                bool found = false;
+                DerObjectIdentifier  oid = (DerObjectIdentifier)ordering[i];
+                string value = (string)values[i];
+
+                for (int j = 0; j < orderingSize; j++)
+                {
+                    if (indexes[j])
+                    {
+                        continue;
+                    }
+
+                    DerObjectIdentifier oOid = (DerObjectIdentifier)other.ordering[j];
+
+                    if (oid.Equals(oOid))
+                    {
+                        string oValue = (string)other.values[j];
+
+                        if (equivalentStrings(value, oValue))
+                        {
+                            indexes[j] = true;
+                            found      = true;
+                            break;
+                        }
+                    }
+                }
+
+                if (!found)
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        private static bool equivalentStrings(
+            string	s1,
+            string	s2)
+        {
+            string v1 = canonicalize(s1);
+            string v2 = canonicalize(s2);
+
+            if (!v1.Equals(v2))
+            {
+                v1 = stripInternalSpaces(v1);
+                v2 = stripInternalSpaces(v2);
+
+                if (!v1.Equals(v2))
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        private static string canonicalize(
+            string s)
+        {
             string v = Platform.ToLowerInvariant(s).Trim();
 
             if (v.StartsWith("#"))
-			{
-				Asn1Object obj = decodeObject(v);
-
-				if (obj is IAsn1String)
-				{
-					v = Platform.ToLowerInvariant(((IAsn1String)obj).GetString()).Trim();
-				}
-			}
-
-			return v;
-		}
-
-		private static Asn1Object decodeObject(
-			string v)
-		{
-			try
-			{
-				return Asn1Object.FromByteArray(Hex.Decode(v.Substring(1)));
-			}
-			catch (IOException e)
-			{
-				throw new InvalidOperationException("unknown encoding in name: " + e.Message, e);
-			}
-		}
-
-		private static string stripInternalSpaces(
-			string str)
-		{
-			StringBuilder res = new StringBuilder();
-
-			if (str.Length != 0)
-			{
-				char c1 = str[0];
-
-				res.Append(c1);
-
-				for (int k = 1; k < str.Length; k++)
-				{
-					char c2 = str[k];
-					if (!(c1 == ' ' && c2 == ' '))
-					{
-						res.Append(c2);
-					}
-					c1 = c2;
-				}
-			}
-
-			return res.ToString();
-		}
-
-		private void AppendValue(
+            {
+                Asn1Object obj = decodeObject(v);
+
+                if (obj is IAsn1String)
+                {
+                    v = Platform.ToLowerInvariant(((IAsn1String)obj).GetString()).Trim();
+                }
+            }
+
+            return v;
+        }
+
+        private static Asn1Object decodeObject(
+            string v)
+        {
+            try
+            {
+                return Asn1Object.FromByteArray(Hex.Decode(v.Substring(1)));
+            }
+            catch (IOException e)
+            {
+                throw new InvalidOperationException("unknown encoding in name: " + e.Message, e);
+            }
+        }
+
+        private static string stripInternalSpaces(
+            string str)
+        {
+            StringBuilder res = new StringBuilder();
+
+            if (str.Length != 0)
+            {
+                char c1 = str[0];
+
+                res.Append(c1);
+
+                for (int k = 1; k < str.Length; k++)
+                {
+                    char c2 = str[k];
+                    if (!(c1 == ' ' && c2 == ' '))
+                    {
+                        res.Append(c2);
+                    }
+                    c1 = c2;
+                }
+            }
+
+            return res.ToString();
+        }
+
+        private void AppendValue(
             StringBuilder		buf,
             IDictionary         oidSymbols,
             DerObjectIdentifier	oid,
@@ -1082,18 +987,18 @@ namespace Org.BouncyCastle.Asn1.X509
 
             int end = buf.Length;
 
-			if (val.StartsWith("\\#"))
-			{
-				index += 2;
-			}
+            if (val.StartsWith("\\#"))
+            {
+                index += 2;
+            }
 
-			while (index != end)
+            while (index != end)
             {
                 if ((buf[index] == ',')
                 || (buf[index] == '"')
                 || (buf[index] == '\\')
                 || (buf[index] == '+')
-				|| (buf[index] == '=')
+                || (buf[index] == '=')
                 || (buf[index] == '<')
                 || (buf[index] == '>')
                 || (buf[index] == ';'))
@@ -1106,16 +1011,6 @@ namespace Org.BouncyCastle.Asn1.X509
             }
         }
 
-#if !SILVERLIGHT
-        [Obsolete]
-        public string ToString(
-            bool        reverse,
-            Hashtable   oidSymbols)
-        {
-            return ToString(reverse, (IDictionary)oidSymbols);
-        }
-#endif
-
         /**
         * convert the structure to a string - if reverse is true the
         * oids and values are listed out starting with the last element
@@ -1135,52 +1030,52 @@ namespace Org.BouncyCastle.Asn1.X509
 #if SILVERLIGHT
             List<object> components = new List<object>();
 #else
-			ArrayList components = new ArrayList();
+            ArrayList components = new ArrayList();
 #endif
 
             StringBuilder ava = null;
 
-			for (int i = 0; i < ordering.Count; i++)
-			{
-				if ((bool) added[i])
-				{
-					ava.Append('+');
-					AppendValue(ava, oidSymbols,
-						(DerObjectIdentifier)ordering[i],
-						(string)values[i]);
-				}
-				else
-				{
-					ava = new StringBuilder();
-					AppendValue(ava, oidSymbols,
-						(DerObjectIdentifier)ordering[i],
-						(string)values[i]);
-					components.Add(ava);
-				}
-			}
-
-			if (reverse)
-			{
-				components.Reverse();
-			}
-
-			StringBuilder buf = new StringBuilder();
-
-			if (components.Count > 0)
-			{
-				buf.Append(components[0].ToString());
-
-				for (int i = 1; i < components.Count; ++i)
-				{
-					buf.Append(',');
-					buf.Append(components[i].ToString());
-				}
-			}
-
-			return buf.ToString();
-		}
-
-		public override string ToString()
+            for (int i = 0; i < ordering.Count; i++)
+            {
+                if ((bool) added[i])
+                {
+                    ava.Append('+');
+                    AppendValue(ava, oidSymbols,
+                        (DerObjectIdentifier)ordering[i],
+                        (string)values[i]);
+                }
+                else
+                {
+                    ava = new StringBuilder();
+                    AppendValue(ava, oidSymbols,
+                        (DerObjectIdentifier)ordering[i],
+                        (string)values[i]);
+                    components.Add(ava);
+                }
+            }
+
+            if (reverse)
+            {
+                components.Reverse();
+            }
+
+            StringBuilder buf = new StringBuilder();
+
+            if (components.Count > 0)
+            {
+                buf.Append(components[0].ToString());
+
+                for (int i = 1; i < components.Count; ++i)
+                {
+                    buf.Append(',');
+                    buf.Append(components[i].ToString());
+                }
+            }
+
+            return buf.ToString();
+        }
+
+        public override string ToString()
         {
             return ToString(DefaultReverse, (IDictionary)DefaultSymbols);
         }
diff --git a/crypto/test/src/asn1/test/X509NameTest.cs b/crypto/test/src/asn1/test/X509NameTest.cs
index 7a0832c3e..9a564f72f 100644
--- a/crypto/test/src/asn1/test/X509NameTest.cs
+++ b/crypto/test/src/asn1/test/X509NameTest.cs
@@ -11,664 +11,664 @@ using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Asn1.Tests
 {
-	[TestFixture]
-	public class X509NameTest
-		: SimpleTest
-	{
-		private static readonly string[] subjects =
-		{
-			"C=AU,ST=Victoria,L=South Melbourne,O=Connect 4 Pty Ltd,OU=Webserver Team,CN=www2.connect4.com.au,E=webmaster@connect4.com.au",
-			"C=AU,ST=Victoria,L=South Melbourne,O=Connect 4 Pty Ltd,OU=Certificate Authority,CN=Connect 4 CA,E=webmaster@connect4.com.au",
-			"C=AU,ST=QLD,CN=SSLeay/rsa test cert",
-			"C=US,O=National Aeronautics and Space Administration,SERIALNUMBER=16+CN=Steve Schoch",
-			"E=cooke@issl.atl.hp.com,C=US,OU=Hewlett Packard Company (ISSL),CN=Paul A. Cooke",
-			"O=Sun Microsystems Inc,CN=store.sun.com",
-			"unstructuredAddress=192.168.1.33,unstructuredName=pixfirewall.ciscopix.com,CN=pixfirewall.ciscopix.com"
-		};
-
-		public override string Name
-		{
-			get { return "X509Name"; }
-		}
-
-		private static X509Name FromBytes(
-			byte[] bytes)
-		{
-			return X509Name.GetInstance(Asn1Object.FromByteArray(bytes));
-		}
-
-		private IAsn1Convertible createEntryValue(
-			DerObjectIdentifier	oid,
-			string				value)
-		{
-			IDictionary attrs = new Hashtable();
-			attrs.Add(oid, value);
-
-			IList ord = new ArrayList();
-			ord.Add(oid);
-
-			X509Name name = new X509Name(ord, attrs);
-
-			Asn1Sequence seq = (Asn1Sequence)name.ToAsn1Object();
-			Asn1Set set = (Asn1Set)seq[0];
-			seq = (Asn1Sequence)set[0];
-
-			return seq[1];
-		}
-
-		private IAsn1Convertible createEntryValueFromString(
-			DerObjectIdentifier	oid,
-			string				val)
-		{
-			IDictionary attrs = new Hashtable();
-			attrs.Add(oid, val);
-
-			IList ord = new ArrayList(attrs.Keys);
-
-			X509Name name = new X509Name(new X509Name(ord, attrs).ToString());
-
-			Asn1Sequence seq = (Asn1Sequence) name.ToAsn1Object();
-			Asn1Set asn1Set = (Asn1Set) seq[0];
-			seq = (Asn1Sequence) asn1Set[0];
-
-			return seq[1];
-		}
-
-		private void doTestEncodingPrintableString(
-			DerObjectIdentifier	oid,
-			string				value)
-		{
-			IAsn1Convertible converted = createEntryValue(oid, value);
-			if (!(converted is DerPrintableString))
-			{
-				Fail("encoding for " + oid + " not printable string");
-			}
-		}
-
-		private void doTestEncodingIA5String(
-			DerObjectIdentifier oid,
-			string				value)
-		{
-			IAsn1Convertible converted = createEntryValue(oid, value);
-			if (!(converted is DerIA5String))
-			{
-				Fail("encoding for " + oid + " not IA5String");
-			}
-		}
-
-		private void doTestEncodingGeneralizedTime(
-			DerObjectIdentifier	oid,
-			string				val)
-		{
-			IAsn1Convertible converted = createEntryValue(oid, val);
-			if (!(converted is DerGeneralizedTime))
-			{
-				Fail("encoding for " + oid + " not GeneralizedTime");
-			}
-			converted = createEntryValueFromString(oid, val);
-			if (!(converted is DerGeneralizedTime))
-			{
-				Fail("encoding for " + oid + " not GeneralizedTime");
-			}
-		}
-
-		public override void PerformTest()
-		{
-			doTestEncodingPrintableString(X509Name.C, "AU");
-			doTestEncodingPrintableString(X509Name.SerialNumber, "123456");
-			doTestEncodingPrintableString(X509Name.DnQualifier, "123456");
-			doTestEncodingIA5String(X509Name.EmailAddress, "test@test.com");
-			doTestEncodingIA5String(X509Name.DC, "test");
-			// correct encoding
-			doTestEncodingGeneralizedTime(X509Name.DateOfBirth, "#180F32303032303132323132323232305A");
-			// compatability encoding
-			doTestEncodingGeneralizedTime(X509Name.DateOfBirth, "20020122122220Z");
-
-			//
-			// composite
-			//
-			IDictionary attrs = new Hashtable();
-			attrs.Add(X509Name.C, "AU");
-			attrs.Add(X509Name.O, "The Legion of the Bouncy Castle");
-			attrs.Add(X509Name.L, "Melbourne");
-			attrs.Add(X509Name.ST, "Victoria");
-			attrs.Add(X509Name.E, "feedback-crypto@bouncycastle.org");
-
-			IList order = new ArrayList();
-			order.Add(X509Name.C);
-			order.Add(X509Name.O);
-			order.Add(X509Name.L);
-			order.Add(X509Name.ST);
-			order.Add(X509Name.E);
-
-			X509Name name1 = new X509Name(order, attrs);
-
-			if (!name1.Equivalent(name1))
-			{
-				Fail("Failed same object test");
-			}
-
-			if (!name1.Equivalent(name1, true))
-			{
-				Fail("Failed same object test - in Order");
-			}
-
-			X509Name name2 = new X509Name(order, attrs);
-
-			if (!name1.Equivalent(name2))
-			{
-				Fail("Failed same name test");
-			}
-
-			if (!name1.Equivalent(name2, true))
-			{
-				Fail("Failed same name test - in Order");
-			}
-
-			if (name1.GetHashCode() != name2.GetHashCode())
-			{
-				Fail("Failed same name test - in Order");
-			}
-
-			IList ord1 = new ArrayList();
-
-			ord1.Add(X509Name.C);
-			ord1.Add(X509Name.O);
-			ord1.Add(X509Name.L);
-			ord1.Add(X509Name.ST);
-			ord1.Add(X509Name.E);
-
-			IList ord2 = new ArrayList();
-
-			ord2.Add(X509Name.E);
-			ord2.Add(X509Name.ST);
-			ord2.Add(X509Name.L);
-			ord2.Add(X509Name.O);
-			ord2.Add(X509Name.C);
-
-			name1 = new X509Name(ord1, attrs);
-			name2 = new X509Name(ord2, attrs);
-
-			if (!name1.Equivalent(name2))
-			{
-				Fail("Failed reverse name test");
-			}
-
-			// FIXME Sort out X509Name hashcode problem
+    [TestFixture]
+    public class X509NameTest
+        : SimpleTest
+    {
+        private static readonly string[] subjects =
+        {
+            "C=AU,ST=Victoria,L=South Melbourne,O=Connect 4 Pty Ltd,OU=Webserver Team,CN=www2.connect4.com.au,E=webmaster@connect4.com.au",
+            "C=AU,ST=Victoria,L=South Melbourne,O=Connect 4 Pty Ltd,OU=Certificate Authority,CN=Connect 4 CA,E=webmaster@connect4.com.au",
+            "C=AU,ST=QLD,CN=SSLeay/rsa test cert",
+            "C=US,O=National Aeronautics and Space Administration,SERIALNUMBER=16+CN=Steve Schoch",
+            "E=cooke@issl.atl.hp.com,C=US,OU=Hewlett Packard Company (ISSL),CN=Paul A. Cooke",
+            "O=Sun Microsystems Inc,CN=store.sun.com",
+            "unstructuredAddress=192.168.1.33,unstructuredName=pixfirewall.ciscopix.com,CN=pixfirewall.ciscopix.com"
+        };
+
+        public override string Name
+        {
+            get { return "X509Name"; }
+        }
+
+        private static X509Name FromBytes(
+            byte[] bytes)
+        {
+            return X509Name.GetInstance(Asn1Object.FromByteArray(bytes));
+        }
+
+        private IAsn1Convertible createEntryValue(
+            DerObjectIdentifier	oid,
+            string				value)
+        {
+            IDictionary attrs = new Hashtable();
+            attrs.Add(oid, value);
+
+            IList ord = new ArrayList();
+            ord.Add(oid);
+
+            X509Name name = new X509Name(ord, attrs);
+
+            Asn1Sequence seq = (Asn1Sequence)name.ToAsn1Object();
+            Asn1Set set = (Asn1Set)seq[0];
+            seq = (Asn1Sequence)set[0];
+
+            return seq[1];
+        }
+
+        private IAsn1Convertible createEntryValueFromString(
+            DerObjectIdentifier	oid,
+            string				val)
+        {
+            IDictionary attrs = new Hashtable();
+            attrs.Add(oid, val);
+
+            IList ord = new ArrayList(attrs.Keys);
+
+            X509Name name = new X509Name(new X509Name(ord, attrs).ToString());
+
+            Asn1Sequence seq = (Asn1Sequence) name.ToAsn1Object();
+            Asn1Set asn1Set = (Asn1Set) seq[0];
+            seq = (Asn1Sequence) asn1Set[0];
+
+            return seq[1];
+        }
+
+        private void doTestEncodingPrintableString(
+            DerObjectIdentifier	oid,
+            string				value)
+        {
+            IAsn1Convertible converted = createEntryValue(oid, value);
+            if (!(converted is DerPrintableString))
+            {
+                Fail("encoding for " + oid + " not printable string");
+            }
+        }
+
+        private void doTestEncodingIA5String(
+            DerObjectIdentifier oid,
+            string				value)
+        {
+            IAsn1Convertible converted = createEntryValue(oid, value);
+            if (!(converted is DerIA5String))
+            {
+                Fail("encoding for " + oid + " not IA5String");
+            }
+        }
+
+        private void doTestEncodingGeneralizedTime(
+            DerObjectIdentifier	oid,
+            string				val)
+        {
+            IAsn1Convertible converted = createEntryValue(oid, val);
+            if (!(converted is DerGeneralizedTime))
+            {
+                Fail("encoding for " + oid + " not GeneralizedTime");
+            }
+            converted = createEntryValueFromString(oid, val);
+            if (!(converted is DerGeneralizedTime))
+            {
+                Fail("encoding for " + oid + " not GeneralizedTime");
+            }
+        }
+
+        public override void PerformTest()
+        {
+            doTestEncodingPrintableString(X509Name.C, "AU");
+            doTestEncodingPrintableString(X509Name.SerialNumber, "123456");
+            doTestEncodingPrintableString(X509Name.DnQualifier, "123456");
+            doTestEncodingIA5String(X509Name.EmailAddress, "test@test.com");
+            doTestEncodingIA5String(X509Name.DC, "test");
+            // correct encoding
+            doTestEncodingGeneralizedTime(X509Name.DateOfBirth, "#180F32303032303132323132323232305A");
+            // compatability encoding
+            doTestEncodingGeneralizedTime(X509Name.DateOfBirth, "20020122122220Z");
+
+            //
+            // composite
+            //
+            IDictionary attrs = new Hashtable();
+            attrs.Add(X509Name.C, "AU");
+            attrs.Add(X509Name.O, "The Legion of the Bouncy Castle");
+            attrs.Add(X509Name.L, "Melbourne");
+            attrs.Add(X509Name.ST, "Victoria");
+            attrs.Add(X509Name.E, "feedback-crypto@bouncycastle.org");
+
+            IList order = new ArrayList();
+            order.Add(X509Name.C);
+            order.Add(X509Name.O);
+            order.Add(X509Name.L);
+            order.Add(X509Name.ST);
+            order.Add(X509Name.E);
+
+            X509Name name1 = new X509Name(order, attrs);
+
+            if (!name1.Equivalent(name1))
+            {
+                Fail("Failed same object test");
+            }
+
+            if (!name1.Equivalent(name1, true))
+            {
+                Fail("Failed same object test - in Order");
+            }
+
+            X509Name name2 = new X509Name(order, attrs);
+
+            if (!name1.Equivalent(name2))
+            {
+                Fail("Failed same name test");
+            }
+
+            if (!name1.Equivalent(name2, true))
+            {
+                Fail("Failed same name test - in Order");
+            }
+
+            if (name1.GetHashCode() != name2.GetHashCode())
+            {
+                Fail("Failed same name test - in Order");
+            }
+
+            IList ord1 = new ArrayList();
+
+            ord1.Add(X509Name.C);
+            ord1.Add(X509Name.O);
+            ord1.Add(X509Name.L);
+            ord1.Add(X509Name.ST);
+            ord1.Add(X509Name.E);
+
+            IList ord2 = new ArrayList();
+
+            ord2.Add(X509Name.E);
+            ord2.Add(X509Name.ST);
+            ord2.Add(X509Name.L);
+            ord2.Add(X509Name.O);
+            ord2.Add(X509Name.C);
+
+            name1 = new X509Name(ord1, attrs);
+            name2 = new X509Name(ord2, attrs);
+
+            if (!name1.Equivalent(name2))
+            {
+                Fail("Failed reverse name test");
+            }
+
+            // FIXME Sort out X509Name hashcode problem
 //			if (name1.GetHashCode() != name2.GetHashCode())
 //			{
 //				Fail("Failed reverse name test GetHashCode");
 //			}
 
-			if (name1.Equivalent(name2, true))
-			{
-				Fail("Failed reverse name test - in Order");
-			}
+            if (name1.Equivalent(name2, true))
+            {
+                Fail("Failed reverse name test - in Order");
+            }
 
-			if (!name1.Equivalent(name2, false))
-			{
-				Fail("Failed reverse name test - in Order false");
-			}
+            if (!name1.Equivalent(name2, false))
+            {
+                Fail("Failed reverse name test - in Order false");
+            }
 
-			IList oids = name1.GetOidList();
-			if (!CompareVectors(oids, ord1))
-			{
-				Fail("oid comparison test");
-			}
+            IList oids = name1.GetOidList();
+            if (!CompareVectors(oids, ord1))
+            {
+                Fail("oid comparison test");
+            }
 
-			IList val1 = new ArrayList();
+            IList val1 = new ArrayList();
 
-			val1.Add("AU");
-			val1.Add("The Legion of the Bouncy Castle");
-			val1.Add("Melbourne");
-			val1.Add("Victoria");
-			val1.Add("feedback-crypto@bouncycastle.org");
+            val1.Add("AU");
+            val1.Add("The Legion of the Bouncy Castle");
+            val1.Add("Melbourne");
+            val1.Add("Victoria");
+            val1.Add("feedback-crypto@bouncycastle.org");
 
-			name1 = new X509Name(ord1, val1);
+            name1 = new X509Name(ord1, val1);
 
-			IList values = name1.GetValueList();
-			if (!CompareVectors(values, val1))
-			{
-				Fail("value comparison test");
-			}
+            IList values = name1.GetValueList();
+            if (!CompareVectors(values, val1))
+            {
+                Fail("value comparison test");
+            }
 
-			ord2 = new ArrayList();
+            ord2 = new ArrayList();
 
-			ord2.Add(X509Name.ST);
-			ord2.Add(X509Name.ST);
-			ord2.Add(X509Name.L);
-			ord2.Add(X509Name.O);
-			ord2.Add(X509Name.C);
-
-			name1 = new X509Name(ord1, attrs);
-			name2 = new X509Name(ord2, attrs);
-
-			if (name1.Equivalent(name2))
-			{
-				Fail("Failed different name test");
-			}
-
-			ord2 = new ArrayList();
+            ord2.Add(X509Name.ST);
+            ord2.Add(X509Name.ST);
+            ord2.Add(X509Name.L);
+            ord2.Add(X509Name.O);
+            ord2.Add(X509Name.C);
+
+            name1 = new X509Name(ord1, attrs);
+            name2 = new X509Name(ord2, attrs);
+
+            if (name1.Equivalent(name2))
+            {
+                Fail("Failed different name test");
+            }
+
+            ord2 = new ArrayList();
 
-			ord2.Add(X509Name.ST);
-			ord2.Add(X509Name.L);
-			ord2.Add(X509Name.O);
-			ord2.Add(X509Name.C);
-
-			name1 = new X509Name(ord1, attrs);
-			name2 = new X509Name(ord2, attrs);
+            ord2.Add(X509Name.ST);
+            ord2.Add(X509Name.L);
+            ord2.Add(X509Name.O);
+            ord2.Add(X509Name.C);
+
+            name1 = new X509Name(ord1, attrs);
+            name2 = new X509Name(ord2, attrs);
 
-			if (name1.Equivalent(name2))
-			{
-				Fail("Failed subset name test");
-			}
-
-
-			compositeTest();
+            if (name1.Equivalent(name2))
+            {
+                Fail("Failed subset name test");
+            }
+
+
+            compositeTest();
 
 
-			//
-			// getValues test
-			//
-			ArrayList v1 = name1.GetValues(X509Name.O);
-
-			if (v1.Count != 1 || !v1[0].Equals("The Legion of the Bouncy Castle"))
-			{
-				Fail("O test failed");
-			}
+            //
+            // getValues test
+            //
+            IList v1 = name1.GetValueList(X509Name.O);
+
+            if (v1.Count != 1 || !v1[0].Equals("The Legion of the Bouncy Castle"))
+            {
+                Fail("O test failed");
+            }
 
-			ArrayList v2 = name1.GetValues(X509Name.L);
-
-			if (v2.Count != 1 || !v2[0].Equals("Melbourne"))
-			{
-				Fail("L test failed");
-			}
-
-			//
-			// general subjects test
-			//
-			for (int i = 0; i != subjects.Length; i++)
-			{
-				X509Name name = new X509Name(subjects[i]);
-				byte[] encodedName = name.GetEncoded();
-				name = X509Name.GetInstance(Asn1Object.FromByteArray(encodedName));
-
-				if (!name.ToString().Equals(subjects[i]))
-				{
-					Fail("Failed regeneration test " + i);
-				}
-			}
-
-			//
-			// sort test
-			//
-			X509Name unsorted = new X509Name("SERIALNUMBER=BBB + CN=AA");
-
-			if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("CN=AA+SERIALNUMBER=BBB"))
-			{
-				Fail("Failed sort test 1");
-			}
+            IList v2 = name1.GetValueList(X509Name.L);
+
+            if (v2.Count != 1 || !v2[0].Equals("Melbourne"))
+            {
+                Fail("L test failed");
+            }
+
+            //
+            // general subjects test
+            //
+            for (int i = 0; i != subjects.Length; i++)
+            {
+                X509Name name = new X509Name(subjects[i]);
+                byte[] encodedName = name.GetEncoded();
+                name = X509Name.GetInstance(Asn1Object.FromByteArray(encodedName));
+
+                if (!name.ToString().Equals(subjects[i]))
+                {
+                    Fail("Failed regeneration test " + i);
+                }
+            }
+
+            //
+            // sort test
+            //
+            X509Name unsorted = new X509Name("SERIALNUMBER=BBB + CN=AA");
+
+            if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("CN=AA+SERIALNUMBER=BBB"))
+            {
+                Fail("Failed sort test 1");
+            }
 
-			unsorted = new X509Name("CN=AA + SERIALNUMBER=BBB");
-
-			if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("CN=AA+SERIALNUMBER=BBB"))
-			{
-				Fail("Failed sort test 2");
-			}
+            unsorted = new X509Name("CN=AA + SERIALNUMBER=BBB");
+
+            if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("CN=AA+SERIALNUMBER=BBB"))
+            {
+                Fail("Failed sort test 2");
+            }
 
-			unsorted = new X509Name("SERIALNUMBER=B + CN=AA");
+            unsorted = new X509Name("SERIALNUMBER=B + CN=AA");
 
-			if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("SERIALNUMBER=B+CN=AA"))
-			{
-				Fail("Failed sort test 3");
-			}
+            if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("SERIALNUMBER=B+CN=AA"))
+            {
+                Fail("Failed sort test 3");
+            }
 
-			unsorted = new X509Name("CN=AA + SERIALNUMBER=B");
+            unsorted = new X509Name("CN=AA + SERIALNUMBER=B");
 
-			if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("SERIALNUMBER=B+CN=AA"))
-			{
-				Fail("Failed sort test 4");
-			}
+            if (!FromBytes(unsorted.GetEncoded()).ToString().Equals("SERIALNUMBER=B+CN=AA"))
+            {
+                Fail("Failed sort test 4");
+            }
 
-			//
-			// equality tests
-			//
-			equalityTest(new X509Name("CN=The     Legion"), new X509Name("CN=The Legion"));
-			equalityTest(new X509Name("CN=   The Legion"), new X509Name("CN=The Legion"));
-			equalityTest(new X509Name("CN=The Legion   "), new X509Name("CN=The Legion"));
-			equalityTest(new X509Name("CN=  The     Legion "), new X509Name("CN=The Legion"));
-			equalityTest(new X509Name("CN=  the     legion "), new X509Name("CN=The Legion"));
+            //
+            // equality tests
+            //
+            equalityTest(new X509Name("CN=The     Legion"), new X509Name("CN=The Legion"));
+            equalityTest(new X509Name("CN=   The Legion"), new X509Name("CN=The Legion"));
+            equalityTest(new X509Name("CN=The Legion   "), new X509Name("CN=The Legion"));
+            equalityTest(new X509Name("CN=  The     Legion "), new X509Name("CN=The Legion"));
+            equalityTest(new X509Name("CN=  the     legion "), new X509Name("CN=The Legion"));
 
-			// # test
+            // # test
 
-			X509Name n1 = new X509Name("SERIALNUMBER=8,O=ABC,CN=ABC Class 3 CA,C=LT");
-			X509Name n2 = new X509Name("2.5.4.5=8,O=ABC,CN=ABC Class 3 CA,C=LT");
-			X509Name n3 = new X509Name("2.5.4.5=#130138,O=ABC,CN=ABC Class 3 CA,C=LT");
+            X509Name n1 = new X509Name("SERIALNUMBER=8,O=ABC,CN=ABC Class 3 CA,C=LT");
+            X509Name n2 = new X509Name("2.5.4.5=8,O=ABC,CN=ABC Class 3 CA,C=LT");
+            X509Name n3 = new X509Name("2.5.4.5=#130138,O=ABC,CN=ABC Class 3 CA,C=LT");
 
-			equalityTest(n1, n2);
-			equalityTest(n2, n3);
-			equalityTest(n3, n1);
+            equalityTest(n1, n2);
+            equalityTest(n2, n3);
+            equalityTest(n3, n1);
 
-			n1 = new X509Name(true, "2.5.4.5=#130138,CN=SSC Class 3 CA,O=UAB Skaitmeninio sertifikavimo centras,C=LT");
-			n2 = new X509Name(true, "SERIALNUMBER=#130138,CN=SSC Class 3 CA,O=UAB Skaitmeninio sertifikavimo centras,C=LT");
-			n3 = X509Name.GetInstance(Asn1Object.FromByteArray(Hex.Decode("3063310b3009060355040613024c54312f302d060355040a1326"
-				+ "55414220536b6169746d656e696e696f20736572746966696b6176696d6f2063656e74726173311730150603550403130e53534320436c6173732033204341310a30080603550405130138")));
+            n1 = new X509Name(true, "2.5.4.5=#130138,CN=SSC Class 3 CA,O=UAB Skaitmeninio sertifikavimo centras,C=LT");
+            n2 = new X509Name(true, "SERIALNUMBER=#130138,CN=SSC Class 3 CA,O=UAB Skaitmeninio sertifikavimo centras,C=LT");
+            n3 = X509Name.GetInstance(Asn1Object.FromByteArray(Hex.Decode("3063310b3009060355040613024c54312f302d060355040a1326"
+                + "55414220536b6169746d656e696e696f20736572746966696b6176696d6f2063656e74726173311730150603550403130e53534320436c6173732033204341310a30080603550405130138")));
 
-			equalityTest(n1, n2);
-			equalityTest(n2, n3);
-			equalityTest(n3, n1);
+            equalityTest(n1, n2);
+            equalityTest(n2, n3);
+            equalityTest(n3, n1);
 
-			n1 = new X509Name("SERIALNUMBER=8,O=XX,CN=ABC Class 3 CA,C=LT");
-			n2 = new X509Name("2.5.4.5=8,O=,CN=ABC Class 3 CA,C=LT");
+            n1 = new X509Name("SERIALNUMBER=8,O=XX,CN=ABC Class 3 CA,C=LT");
+            n2 = new X509Name("2.5.4.5=8,O=,CN=ABC Class 3 CA,C=LT");
 
-			if (n1.Equivalent(n2))
-			{
-				Fail("empty inequality check failed");
-			}
-
-			n1 = new X509Name("SERIALNUMBER=8,O=,CN=ABC Class 3 CA,C=LT");
-			n2 = new X509Name("2.5.4.5=8,O=,CN=ABC Class 3 CA,C=LT");
-
-			equalityTest(n1, n2);
-
-			//
-			// inequality to sequences
-			//
-			name1 = new X509Name("CN=The Legion");
-
-			if (name1.Equals(DerSequence.Empty))
-			{
-				Fail("inequality test with sequence");
-			}
-
-			if (name1.Equals(new DerSequence(DerSet.Empty)))
-			{
-				Fail("inequality test with sequence and set");
-			}
-
-			Asn1EncodableVector v = new Asn1EncodableVector(
-				new DerObjectIdentifier("1.1"),
-				new DerObjectIdentifier("1.1"));
-
-			if (name1.Equals(new DerSequence(new DerSet(new DerSet(v)))))
-			{
-				Fail("inequality test with sequence and bad set");
-			}
+            if (n1.Equivalent(n2))
+            {
+                Fail("empty inequality check failed");
+            }
+
+            n1 = new X509Name("SERIALNUMBER=8,O=,CN=ABC Class 3 CA,C=LT");
+            n2 = new X509Name("2.5.4.5=8,O=,CN=ABC Class 3 CA,C=LT");
+
+            equalityTest(n1, n2);
+
+            //
+            // inequality to sequences
+            //
+            name1 = new X509Name("CN=The Legion");
+
+            if (name1.Equals(DerSequence.Empty))
+            {
+                Fail("inequality test with sequence");
+            }
+
+            if (name1.Equals(new DerSequence(DerSet.Empty)))
+            {
+                Fail("inequality test with sequence and set");
+            }
+
+            Asn1EncodableVector v = new Asn1EncodableVector(
+                new DerObjectIdentifier("1.1"),
+                new DerObjectIdentifier("1.1"));
+
+            if (name1.Equals(new DerSequence(new DerSet(new DerSet(v)))))
+            {
+                Fail("inequality test with sequence and bad set");
+            }
 
 //			if (name1.Equals(new DerSequence(new DerSet(new DerSet(v))), true))
 //			{
 //				Fail("inequality test with sequence and bad set");
 //			}
-			try
-			{
-				X509Name.GetInstance(new DerSequence(new DerSet(new DerSet(v))));
-				Fail("GetInstance should reject bad sequence");
-			}
-			catch (ArgumentException)
-			{
-				//expected
-			}
-
-			if (name1.Equals(new DerSequence(new DerSet(DerSequence.Empty))))
-			{
-				Fail("inequality test with sequence and short sequence");
-			}
+            try
+            {
+                X509Name.GetInstance(new DerSequence(new DerSet(new DerSet(v))));
+                Fail("GetInstance should reject bad sequence");
+            }
+            catch (ArgumentException)
+            {
+                //expected
+            }
+
+            if (name1.Equals(new DerSequence(new DerSet(DerSequence.Empty))))
+            {
+                Fail("inequality test with sequence and short sequence");
+            }
 
 //			if (name1.Equals(new DerSequence(new DerSet(DerSequence.Empty)), true))
 //			{
 //				Fail("inequality test with sequence and short sequence");
 //			}
-			try
-			{
-				X509Name.GetInstance(new DerSequence(new DerSet(DerSequence.Empty)));
-				Fail("GetInstance should reject short sequence");
-			}
-			catch (ArgumentException)
-			{
-				//expected
-			}
-
-			v = new Asn1EncodableVector(
-				new DerObjectIdentifier("1.1"),
-				DerSequence.Empty);
-
-			if (name1.Equals(new DerSequence(new DerSet(new DerSequence(v)))))
-			{
-				Fail("inequality test with sequence and bad sequence");
-			}
-
-			if (name1.Equivalent(null))
-			{
-				Fail("inequality test with null");
-			}
-
-			if (name1.Equivalent(null, true))
-			{
-				Fail("inequality test with null");
-			}
-
-			//
-			// this is contrived but it checks sorting of sets with equal elements
-			//
-			unsorted = new X509Name("CN=AA + CN=AA + CN=AA");
-
-			//
-			// tagging test - only works if CHOICE implemented
-			//
-			/*
-			ASN1TaggedObject tag = new DERTaggedObject(false, 1, new X509Name("CN=AA"));
-
-			if (!tag.isExplicit())
-			{
-				Fail("failed to explicitly tag CHOICE object");
-			}
-
-			X509Name name = X509Name.getInstance(tag, false);
-
-			if (!name.equals(new X509Name("CN=AA")))
-			{
-				Fail("failed to recover tagged name");
-			}
-			*/
-
-			DerUtf8String testString = new DerUtf8String("The Legion of the Bouncy Castle");
-			byte[] encodedBytes = testString.GetEncoded();
-			string hexEncodedString = "#" + Hex.ToHexString(encodedBytes);
-
-			DerUtf8String converted = (DerUtf8String)
-				new X509DefaultEntryConverter().GetConvertedValue(
-				X509Name.L , hexEncodedString);
-
-			if (!converted.Equals(testString))
-			{
-				Fail("Failed X509DefaultEntryConverter test");
-			}
-
-			//
-			// try escaped.
-			//
-			converted = (DerUtf8String) new X509DefaultEntryConverter().GetConvertedValue(
-				X509Name.L , "\\" + hexEncodedString);
-
-			if (!converted.Equals(new DerUtf8String(hexEncodedString)))
-			{
-				Fail("Failed X509DefaultEntryConverter test got " + converted + " expected: " + hexEncodedString);
-			}
-
-			//
-			// try a weird value
-			//
-			X509Name n = new X509Name("CN=\\#nothex#string");
-
-			if (!n.ToString().Equals("CN=\\#nothex#string"))
-			{
-				Fail("# string not properly escaped.");
-			}
-
-			ArrayList vls = n.GetValues(X509Name.CN);
-			if (vls.Count != 1 || !vls[0].Equals("#nothex#string"))
-			{
-				Fail("Escaped # not reduced properly");
-			}
-
-			n = new X509Name("CN=\"a+b\"");
-
-			vls = n.GetValues(X509Name.CN);
-			if (vls.Count != 1 || !vls[0].Equals("a+b"))
-			{
-				Fail("Escaped + not reduced properly");
-			}
-
-			n = new X509Name("CN=a\\+b");
-
-			vls = n.GetValues(X509Name.CN);
-			if (vls.Count != 1 || !vls[0].Equals("a+b"))
-			{
-				Fail("Escaped + not reduced properly");
-			}
-
-			if (!n.ToString().Equals("CN=a\\+b"))
-			{
-				Fail("+ in string not properly escaped.");
-			}
-
-			n = new X509Name("CN=a\\=b");
-
-			vls = n.GetValues(X509Name.CN);
-			if (vls.Count != 1 || !vls[0].Equals("a=b"))
-			{
-				Fail("Escaped = not reduced properly");
-			}
-
-			if (!n.ToString().Equals("CN=a\\=b"))
-			{
-				Fail("= in string not properly escaped.");
-			}
-
-	        n = new X509Name("TELEPHONENUMBER=\"+61999999999\"");
-
-	        vls = n.GetValues(X509Name.TelephoneNumber);
-	        if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
-	        {
-	            Fail("telephonenumber escaped + not reduced properly");
-	        }
-
-	        n = new X509Name("TELEPHONENUMBER=\\+61999999999");
-
-	        vls = n.GetValues(X509Name.TelephoneNumber);
-	        if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
-	        {
-	            Fail("telephonenumber escaped + not reduced properly");
-	        }
-
-	        n = new X509Name(@"TELEPHONENUMBER=\+61999999999");
-
-	        vls = n.GetValues(X509Name.TelephoneNumber);
-	        if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
-	        {
-	            Fail("telephonenumber escaped + not reduced properly");
-	        }
-		}
-
-		private void compositeTest()
-		{
-			//
-			// composite test
-			//
-			byte[] enc = Hex.Decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65");
-			X509Name n = X509Name.GetInstance(Asn1Object.FromByteArray(enc));
-
-			if (!n.ToString().Equals("C=AU,O=The Legion of the Bouncy Castle,L=Melbourne+OU=Ascot Vale"))
-			{
-				Fail("Failed composite to string test got: " + n.ToString());
-			}
+            try
+            {
+                X509Name.GetInstance(new DerSequence(new DerSet(DerSequence.Empty)));
+                Fail("GetInstance should reject short sequence");
+            }
+            catch (ArgumentException)
+            {
+                //expected
+            }
+
+            v = new Asn1EncodableVector(
+                new DerObjectIdentifier("1.1"),
+                DerSequence.Empty);
+
+            if (name1.Equals(new DerSequence(new DerSet(new DerSequence(v)))))
+            {
+                Fail("inequality test with sequence and bad sequence");
+            }
+
+            if (name1.Equivalent(null))
+            {
+                Fail("inequality test with null");
+            }
+
+            if (name1.Equivalent(null, true))
+            {
+                Fail("inequality test with null");
+            }
+
+            //
+            // this is contrived but it checks sorting of sets with equal elements
+            //
+            unsorted = new X509Name("CN=AA + CN=AA + CN=AA");
+
+            //
+            // tagging test - only works if CHOICE implemented
+            //
+            /*
+            ASN1TaggedObject tag = new DERTaggedObject(false, 1, new X509Name("CN=AA"));
+
+            if (!tag.isExplicit())
+            {
+                Fail("failed to explicitly tag CHOICE object");
+            }
+
+            X509Name name = X509Name.getInstance(tag, false);
+
+            if (!name.equals(new X509Name("CN=AA")))
+            {
+                Fail("failed to recover tagged name");
+            }
+            */
+
+            DerUtf8String testString = new DerUtf8String("The Legion of the Bouncy Castle");
+            byte[] encodedBytes = testString.GetEncoded();
+            string hexEncodedString = "#" + Hex.ToHexString(encodedBytes);
+
+            DerUtf8String converted = (DerUtf8String)
+                new X509DefaultEntryConverter().GetConvertedValue(
+                X509Name.L , hexEncodedString);
+
+            if (!converted.Equals(testString))
+            {
+                Fail("Failed X509DefaultEntryConverter test");
+            }
+
+            //
+            // try escaped.
+            //
+            converted = (DerUtf8String) new X509DefaultEntryConverter().GetConvertedValue(
+                X509Name.L , "\\" + hexEncodedString);
+
+            if (!converted.Equals(new DerUtf8String(hexEncodedString)))
+            {
+                Fail("Failed X509DefaultEntryConverter test got " + converted + " expected: " + hexEncodedString);
+            }
+
+            //
+            // try a weird value
+            //
+            X509Name n = new X509Name("CN=\\#nothex#string");
+
+            if (!n.ToString().Equals("CN=\\#nothex#string"))
+            {
+                Fail("# string not properly escaped.");
+            }
+
+            IList vls = n.GetValueList(X509Name.CN);
+            if (vls.Count != 1 || !vls[0].Equals("#nothex#string"))
+            {
+                Fail("Escaped # not reduced properly");
+            }
+
+            n = new X509Name("CN=\"a+b\"");
+
+            vls = n.GetValueList(X509Name.CN);
+            if (vls.Count != 1 || !vls[0].Equals("a+b"))
+            {
+                Fail("Escaped + not reduced properly");
+            }
+
+            n = new X509Name("CN=a\\+b");
+
+            vls = n.GetValueList(X509Name.CN);
+            if (vls.Count != 1 || !vls[0].Equals("a+b"))
+            {
+                Fail("Escaped + not reduced properly");
+            }
+
+            if (!n.ToString().Equals("CN=a\\+b"))
+            {
+                Fail("+ in string not properly escaped.");
+            }
+
+            n = new X509Name("CN=a\\=b");
+
+            vls = n.GetValueList(X509Name.CN);
+            if (vls.Count != 1 || !vls[0].Equals("a=b"))
+            {
+                Fail("Escaped = not reduced properly");
+            }
+
+            if (!n.ToString().Equals("CN=a\\=b"))
+            {
+                Fail("= in string not properly escaped.");
+            }
+
+            n = new X509Name("TELEPHONENUMBER=\"+61999999999\"");
+
+            vls = n.GetValueList(X509Name.TelephoneNumber);
+            if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
+            {
+                Fail("telephonenumber escaped + not reduced properly");
+            }
+
+            n = new X509Name("TELEPHONENUMBER=\\+61999999999");
+
+            vls = n.GetValueList(X509Name.TelephoneNumber);
+            if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
+            {
+                Fail("telephonenumber escaped + not reduced properly");
+            }
+
+            n = new X509Name(@"TELEPHONENUMBER=\+61999999999");
+
+            vls = n.GetValueList(X509Name.TelephoneNumber);
+            if (vls.Count != 1 || !vls[0].Equals("+61999999999"))
+            {
+                Fail("telephonenumber escaped + not reduced properly");
+            }
+        }
+
+        private void compositeTest()
+        {
+            //
+            // composite test
+            //
+            byte[] enc = Hex.Decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65");
+            X509Name n = X509Name.GetInstance(Asn1Object.FromByteArray(enc));
+
+            if (!n.ToString().Equals("C=AU,O=The Legion of the Bouncy Castle,L=Melbourne+OU=Ascot Vale"))
+            {
+                Fail("Failed composite to string test got: " + n.ToString());
+            }
 
             IDictionary symbols = X509Name.DefaultSymbols;
-			if (!n.ToString(true, symbols).Equals("L=Melbourne+OU=Ascot Vale,O=The Legion of the Bouncy Castle,C=AU"))
-			{
+            if (!n.ToString(true, symbols).Equals("L=Melbourne+OU=Ascot Vale,O=The Legion of the Bouncy Castle,C=AU"))
+            {
                 Fail("Failed composite to string test got: " + n.ToString(true, symbols));
-			}
+            }
 
-			n = new X509Name(true, "L=Melbourne+OU=Ascot Vale,O=The Legion of the Bouncy Castle,C=AU");
-			if (!n.ToString().Equals("C=AU,O=The Legion of the Bouncy Castle,L=Melbourne+OU=Ascot Vale"))
-			{
-				Fail("Failed composite to string reversal test got: " + n.ToString());
-			}
+            n = new X509Name(true, "L=Melbourne+OU=Ascot Vale,O=The Legion of the Bouncy Castle,C=AU");
+            if (!n.ToString().Equals("C=AU,O=The Legion of the Bouncy Castle,L=Melbourne+OU=Ascot Vale"))
+            {
+                Fail("Failed composite to string reversal test got: " + n.ToString());
+            }
 
-			n = new X509Name("C=AU, O=The Legion of the Bouncy Castle, L=Melbourne + OU=Ascot Vale");
+            n = new X509Name("C=AU, O=The Legion of the Bouncy Castle, L=Melbourne + OU=Ascot Vale");
 
-			MemoryStream bOut = new MemoryStream();
-			Asn1OutputStream aOut = new Asn1OutputStream(bOut);
+            MemoryStream bOut = new MemoryStream();
+            Asn1OutputStream aOut = new Asn1OutputStream(bOut);
 
-			aOut.WriteObject(n);
+            aOut.WriteObject(n);
 
-			byte[] enc2 = bOut.ToArray();
+            byte[] enc2 = bOut.ToArray();
 
-			if (!Arrays.AreEqual(enc, enc2))
-			{
-				Fail("Failed composite string to encoding test");
-			}
+            if (!Arrays.AreEqual(enc, enc2))
+            {
+                Fail("Failed composite string to encoding test");
+            }
 
-			//
-			// dud name test - handle empty DN without barfing.
-			//
-			n = new X509Name("C=CH,O=,OU=dummy,CN=mail@dummy.com");
+            //
+            // dud name test - handle empty DN without barfing.
+            //
+            n = new X509Name("C=CH,O=,OU=dummy,CN=mail@dummy.com");
 
-			n = X509Name.GetInstance(Asn1Object.FromByteArray(n.GetEncoded()));
-		}
+            n = X509Name.GetInstance(Asn1Object.FromByteArray(n.GetEncoded()));
+        }
 
-		private void equalityTest(
-			X509Name	x509Name,
-			X509Name	x509Name1)
-		{
-			if (!x509Name.Equivalent(x509Name1))
-			{
-				Fail("equality test failed for " + x509Name + " : " + x509Name1);
-			}
+        private void equalityTest(
+            X509Name	x509Name,
+            X509Name	x509Name1)
+        {
+            if (!x509Name.Equivalent(x509Name1))
+            {
+                Fail("equality test failed for " + x509Name + " : " + x509Name1);
+            }
 
-			// FIXME Sort out X509Name hashcode problem
+            // FIXME Sort out X509Name hashcode problem
 //			if (x509Name.GetHashCode() != x509Name1.GetHashCode())
 //			{
 //				Fail("GetHashCode test failed for " + x509Name + " : " + x509Name1);
 //			}
 
-			if (!x509Name.Equivalent(x509Name1, true))
-			{
-				Fail("equality test failed for " + x509Name + " : " + x509Name1);
-			}
-		}
-
-		private bool CompareVectors(
-			IList	one,
-			IList	two)
-		{
-			if (one.Count != two.Count)
-				return false;
-
-			for (int i = 0; i < one.Count; ++i)
-			{
-				if (!one[i].Equals(two[i]))
-					return false;
-			}
-
-			return true;
-		}
-
-		public static void Main(
-			string[] args)
-		{
-			ITest test = new X509NameTest();
-			ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-		}
-
-		[Test]
-		public void TestFunction()
-		{
-			string resultText = Perform().ToString();
-
-			Assert.AreEqual(Name + ": Okay", resultText);
-		}
-	}
+            if (!x509Name.Equivalent(x509Name1, true))
+            {
+                Fail("equality test failed for " + x509Name + " : " + x509Name1);
+            }
+        }
+
+        private bool CompareVectors(
+            IList	one,
+            IList	two)
+        {
+            if (one.Count != two.Count)
+                return false;
+
+            for (int i = 0; i < one.Count; ++i)
+            {
+                if (!one[i].Equals(two[i]))
+                    return false;
+            }
+
+            return true;
+        }
+
+        public static void Main(
+            string[] args)
+        {
+            ITest test = new X509NameTest();
+            ITestResult result = test.Perform();
+
+            Console.WriteLine(result);
+        }
+
+        [Test]
+        public void TestFunction()
+        {
+            string resultText = Perform().ToString();
+
+            Assert.AreEqual(Name + ": Okay", resultText);
+        }
+    }
 }