2 // X500DistinguishedNameTest.cs - NUnit Test Cases for
3 // System.Security.Cryptography.X509Certificates.X500DistinguishedName
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using NUnit.Framework;
33 using System.Security.Cryptography;
34 using System.Security.Cryptography.X509Certificates;
36 namespace MonoTests.System.Security.Cryptography.X509Certificates {
39 public class X500DistinguishedNameTest {
41 private const string name = "OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US";
42 private const string rname = "C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority";
44 private static byte[] cert_a = { 0x30,0x82,0x01,0xFF,0x30,0x82,0x01,0x6C,0x02,0x05,0x02,0x72,0x00,0x06,0xE8,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
45 0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x37,0x5A,0x17,0x0D,0x39,0x37,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x36,0x5A,0x30,0x61,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
46 0x55,0x04,0x0A,0x13,0x0B,0x43,0x6F,0x6D,0x6D,0x65,0x72,0x63,0x65,0x4E,0x65,0x74,0x31,0x27,0x30,0x25,0x06,0x03,0x55,0x04,0x0B,0x13,0x1E,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x70,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x5F,0x00,0x30,0x5C,0x02,0x55,0x2D,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x3A,0x48,0xA6,0xCB,0xC2,0xFD,0x20,0x57,0xBC,0x63,0x1C };
51 private static byte[] cert_a_issuer_raw = new byte[] { 0x30, 0x5F, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x20, 0x30, 0x1E, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x17, 0x52, 0x53, 0x41, 0x20, 0x44, 0x61, 0x74, 0x61, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2C, 0x20, 0x49, 0x6E, 0x63, 0x2E, 0x31, 0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x25, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, 0x65,
52 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79 };
55 private static byte[] cert_b = { 0x30,0x82,0x03,0x04,0x30,0x82,0x02,0xC4,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x03,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x30,0x51,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x55,0x2E,0x53,0x2E,0x20,0x47,0x6F,0x76,0x65,0x72,0x6E,0x6D,0x65,0x6E,0x74,0x31,0x0C,0x30,0x0A,0x06,0x03,0x55,0x04,0x0B,0x13,0x03,0x44,0x6F,0x44,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x13,0x11,0x41,0x72,0x6D,0x65,0x64,0x20,0x46,0x6F,
56 0x72,0x63,0x65,0x73,0x20,0x52,0x6F,0x6F,0x74,0x30,0x1E,0x17,0x0D,0x30,0x30,0x31,0x30,0x32,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x30,0x33,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x30,0x51,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x55,0x2E,0x53,0x2E,0x20,0x47,0x6F,0x76,0x65,0x72,0x6E,0x6D,0x65,0x6E,0x74,0x31,0x0C,0x30,0x0A,0x06,0x03,0x55,0x04,0x0B,0x13,0x03,0x44,0x6F,0x44,0x31,0x1A,0x30,0x18,
57 0x06,0x03,0x55,0x04,0x03,0x13,0x11,0x41,0x72,0x6D,0x65,0x64,0x20,0x46,0x6F,0x72,0x63,0x65,0x73,0x20,0x52,0x6F,0x6F,0x74,0x30,0x82,0x01,0xB6,0x30,0x82,0x01,0x2B,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x01,0x30,0x82,0x01,0x1E,0x02,0x81,0x81,0x00,0x90,0x89,0x3E,0x18,0x1B,0xFE,0xA3,0x1D,0x16,0x89,0x00,0xB4,0xD5,0x40,0x82,0x4C,0x2E,0xEC,0x3D,0x66,0x0D,0x0D,0xB9,0x17,0x40,0x6E,0x3A,0x5C,0x03,0x7B,0x1B,0x93,0x28,0x0C,0xEF,0xB9,0x97,0xE3,0xA1,0xEB,0xE2,0xA3,0x7C,0x61,0xDD,0x6F,0xD5,0xAD,0x15,0x69,0x00,
58 0x16,0xB2,0xC3,0x08,0x3D,0xC4,0x59,0xC6,0xF2,0x70,0xA5,0xB0,0xF5,0x1F,0x1D,0xF4,0xB0,0x15,0xDA,0x7E,0x28,0x39,0x24,0x99,0x36,0x5B,0xEC,0x39,0x25,0xFA,0x92,0x49,0x65,0xD2,0x43,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31,0xA4,0x07,0x17,0xED,0x1E,0x5D,0xB2,0x7B,0xBB,0xCE,0x3C,0x97,0x67,0x1E,0x88,0x0A,0xFE,0x7D,0x00,0x22,0x27,0x1D,0x66,0xEE,0xF6,0x1B,0xB6,0x95,0x7F,0x5A,0xFF,0x06,0x34,0x02,0x43,0xC3,0x83,0xC4,0x66,0x2C,0xA1,0x05,0x0E,
61 0x68,0xB3,0xCA,0xDC,0xD3,0xF9,0x0C,0xC0,0x66,0xDF,0x85,0x84,0x4B,0x20,0x5D,0x41,0xAC,0xC0,0xEC,0x37,0x92,0x0E,0x97,0x19,0xBF,0x53,0x35,0x63,0x27,0x18,0x33,0x35,0x42,0x4D,0xF0,0x2D,0x6D,0xA7,0xA4,0x98,0xAA,0x57,0xF3,0xD2,0xB8,0x6E,0x4E,0x8F,0xFF,0xBE,0x6F,0x4E,0x0F,0x0B,0x44,0x24,0xEE,0xDF,0x4C,0x22,0x5B,0x44,0x98,0x94,0xCB,0xB8,0xA3,0x2F,0x30,0x2D,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x9D,0x2D,0x73,0xC3,0xB8,0xE3,0x4D,0x29,0x28,0xC3,0x65,0xBE,0xA9,0x98,0xCB,0xD6,0x8A,0x06,0x68,
62 0x9C,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x03,0x2F,0x00,0x30,0x2C,0x02,0x14,0x5A,0x1B,0x2D,0x08,0x0E,0xE6,0x99,0x38,0x8F,0xB5,0x09,0xC9,0x89,0x79,0x7E,0x01,0x30,0xBD,0xCE,0xF0,0x02,0x14,0x71,0x7B,0x08,0x51,0x97,0xCE,0x4D,0x1F,0x6A,0x84,0x47,0x3A,0xC0,0xBD,0x13,0x89,0x81,0xB9,0x01,0x97 };
65 static public byte[] RFC3280MandatoryAttributeTypesCACert_crt = { 0x30, 0x82, 0x02, 0xC1, 0x30, 0x82, 0x02, 0x2A, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x60, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x40, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0C, 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x41, 0x6E, 0x63, 0x68, 0x6F, 0x72, 0x30, 0x1E, 0x17, 0x0D,
66 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x31, 0x34, 0x35, 0x37, 0x32, 0x30, 0x5A, 0x17, 0x0D, 0x31, 0x31, 0x30, 0x34, 0x31, 0x39, 0x31, 0x34, 0x35, 0x37, 0x32, 0x30, 0x5A, 0x30, 0x81, 0x8E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x31, 0x13, 0x30, 0x11, 0x06, 0x0A, 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19, 0x16, 0x03, 0x67, 0x6F, 0x76, 0x31, 0x20, 0x30, 0x1E, 0x06, 0x0A, 0x09,
67 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19, 0x16, 0x10, 0x74, 0x65, 0x73, 0x74, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x08, 0x4D, 0x61, 0x72, 0x79, 0x6C, 0x61, 0x6E, 0x64, 0x31, 0x0C, 0x30, 0x0A, 0x06, 0x03, 0x55, 0x04, 0x05, 0x13, 0x03, 0x33, 0x34, 0x35, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x2E, 0x13, 0x02, 0x43, 0x41, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81,
68 0x81, 0x00, 0x98, 0xF9, 0xAF, 0xBC, 0xDB, 0x8B, 0x05, 0xA5, 0xE2, 0xDD, 0xC6, 0x10, 0x43, 0x3B, 0x8D, 0x14, 0xEB, 0x6A, 0xD9, 0xA7, 0x8D, 0xAB, 0x56, 0x19, 0xA1, 0xD4, 0xFF, 0xFB, 0xB4, 0x92, 0x7E, 0x39, 0x76, 0xBB, 0x3D, 0x70, 0xB0, 0xB1, 0xC8, 0xED, 0x78, 0xCE, 0x18, 0xEB, 0x96, 0xAC, 0x4F, 0x4D, 0xD2, 0x83, 0x41, 0xAC, 0x04, 0x66, 0x49, 0x88, 0x7A, 0x5A, 0xB6, 0x02, 0x26, 0x3D, 0x5C, 0x77, 0xCB, 0xDC, 0x8F, 0xE1, 0x53, 0xCA, 0x6B, 0xF1, 0xE4, 0x35, 0x84, 0x7A, 0xA3, 0xC2, 0x0E, 0x6C, 0x54, 0x10, 0xEE, 0x1E, 0xFB, 0xF4, 0x7E, 0xBA, 0xD1, 0xEC, 0x16, 0x60, 0x91, 0xCE, 0xB3, 0x8E, 0x50, 0x4A,
69 0x8A, 0x92, 0x21, 0xCD, 0x1A, 0x84, 0x77, 0x8B, 0x2A, 0xD8, 0xAF, 0x9C, 0xEC, 0xCC, 0x94, 0x60, 0x44, 0x3C, 0x1F, 0xD5, 0x08, 0x98, 0x22, 0x7B, 0xB4, 0x70, 0xB3, 0x2C, 0x1E, 0xBF, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x7C, 0x30, 0x7A, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xFB, 0x6C, 0xD4, 0x2D, 0x81, 0x9E, 0xCA, 0x27, 0x7A, 0x9E, 0x0D, 0xB0, 0x3C, 0xEA, 0x9A, 0xBC, 0x87, 0xFF, 0x49, 0xEA, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xA0, 0x2D, 0x8D, 0xA0, 0x5C, 0xA8, 0x82, 0x08, 0x62, 0x2A, 0x36, 0xA2, 0x4D, 0x52, 0xC8, 0xE5, 0x2C,
70 0x50, 0x7D, 0x2B, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x17, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x10, 0x30, 0x0E, 0x30, 0x0C, 0x06, 0x0A, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x02, 0x01, 0x30, 0x01, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x97, 0xA1, 0x70, 0x88, 0x1F, 0x94, 0xEE, 0x09, 0xFF, 0x38, 0x75, 0x53, 0xB0, 0x79, 0x23, 0x1F, 0x39, 0xD6, 0xF9, 0x33,
71 0x32, 0x93, 0xB9, 0xD3, 0xB0, 0xE7, 0x99, 0x94, 0xED, 0x58, 0x03, 0xCC, 0xC9, 0x3B, 0xBF, 0x34, 0x08, 0x13, 0x1D, 0xE3, 0x09, 0xE3, 0xF4, 0xEE, 0x1F, 0x1B, 0xC8, 0x33, 0x34, 0x8B, 0xFA, 0x24, 0x8C, 0xDD, 0x14, 0x82, 0x6E, 0x03, 0xCC, 0xEC, 0x31, 0xC7, 0x99, 0x40, 0x8E, 0xCF, 0xEE, 0x18, 0x68, 0x46, 0x44, 0x60, 0x55, 0x08, 0x92, 0x0F, 0x43, 0x84, 0x1E, 0x9A, 0xC5, 0xF7, 0x2F, 0x6E, 0x18, 0xA6, 0xA4, 0x90, 0x2A, 0x82, 0x63, 0x2B, 0xE6, 0x0B, 0xFA, 0xCC, 0xFC, 0xA5, 0xDA, 0x1A, 0xA9, 0x7E, 0xBD, 0x74, 0x30, 0x32, 0x21, 0xC6, 0x4D, 0x1B, 0x68, 0xBD, 0x2F, 0xF5, 0x84, 0xBE, 0x66, 0x9C, 0xC3, 0x40,
72 0x27, 0x25, 0x9F, 0x91, 0x77, 0x4E, 0xA3, 0xAB };
74 static public byte[] RFC3280OptionalAttributeTypesCACert_crt = { 0x30, 0x82, 0x02, 0xCD, 0x30, 0x82, 0x02, 0x36, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x61, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x40, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0C, 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x41, 0x6E, 0x63, 0x68, 0x6F, 0x72, 0x30, 0x1E, 0x17, 0x0D,
75 0x30, 0x31, 0x30, 0x34, 0x31, 0x39, 0x31, 0x34, 0x35, 0x37, 0x32, 0x30, 0x5A, 0x17, 0x0D, 0x31, 0x31, 0x30, 0x34, 0x31, 0x39, 0x31, 0x34, 0x35, 0x37, 0x32, 0x30, 0x5A, 0x30, 0x81, 0x9A, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0C, 0x47, 0x61, 0x69, 0x74, 0x68, 0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x31, 0x0D, 0x30, 0x0B, 0x06,
76 0x03, 0x55, 0x04, 0x2A, 0x13, 0x04, 0x4A, 0x6F, 0x68, 0x6E, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x2B, 0x13, 0x01, 0x51, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x41, 0x13, 0x0A, 0x46, 0x69, 0x63, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x75, 0x73, 0x31, 0x0B, 0x30, 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, 0x0E, 0x2D, 0xD3, 0x7D, 0xBB, 0xF0, 0x2A, 0x2E, 0x8B, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x7C, 0x30, 0x7A, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xFB, 0x6C, 0xD4, 0x2D, 0x81, 0x9E, 0xCA, 0x27, 0x7A, 0x9E, 0x0D, 0xB0, 0x3C, 0xEA, 0x9A, 0xBC, 0x87, 0xFF, 0x49, 0xEA, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xAF, 0x81, 0x9F, 0xCC, 0x19,
79 0x2C, 0x12, 0xA4, 0x63, 0x42, 0x57, 0x57, 0xD7, 0x57, 0x1A, 0x63, 0x07, 0x5F, 0x73, 0xD1, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x17, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x10, 0x30, 0x0E, 0x30, 0x0C, 0x06, 0x0A, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x02, 0x01, 0x30, 0x01, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x53, 0xE9, 0xC6, 0x5A, 0x3C, 0xFA, 0x11, 0xDA,
80 0x3C, 0x93, 0xB1, 0xA8, 0xB2, 0x91, 0xE7, 0x42, 0x77, 0x87, 0xED, 0xB5, 0x31, 0x82, 0xFF, 0xB9, 0xF3, 0x23, 0x9B, 0x3A, 0xFE, 0xB8, 0x85, 0xE6, 0x7C, 0x52, 0x46, 0x1A, 0x0B, 0x33, 0xE8, 0x7C, 0x85, 0xAF, 0xB3, 0x37, 0x67, 0x5F, 0xD7, 0x13, 0x19, 0x6A, 0x8D, 0x4E, 0xBE, 0x9E, 0x91, 0x40, 0x63, 0x8F, 0xAD, 0xBB, 0x8F, 0x87, 0x3F, 0x2A, 0xC2, 0x79, 0x98, 0xAE, 0x36, 0x76, 0x7D, 0xDB, 0xE3, 0xE3, 0xBB, 0x23, 0xF8, 0x14, 0x18, 0xC4, 0x83, 0xBA, 0xA1, 0x4C, 0x9D, 0xFC, 0x36, 0x18, 0xC0, 0x8F, 0xE7, 0x9A, 0xAD, 0xE8, 0xE5, 0xB2, 0xC1, 0x3B, 0x16, 0x43, 0xCF, 0x7A, 0x82, 0xDC, 0x08, 0x8D, 0x15, 0xF7,
81 0x1F, 0x2C, 0xF8, 0x99, 0xDA, 0x6D, 0x1E, 0xA2, 0xD3, 0xF4, 0x23, 0xBF, 0x27, 0x4E, 0xD0, 0xC6, 0x19, 0x40, 0xDC, 0x13 };
83 static public AsnEncodedData emptyData = new AsnEncodedData (new byte[0]);
85 private X509Certificate2 x509a;
86 //private X509Certificate2 x509b;
89 public void FixtureSetUp ()
91 x509a = new X509Certificate2 (cert_a);
92 //x509b = new X509Certificate2 (cert_b);
95 private void Empty (X500DistinguishedName dn)
97 Assert.AreEqual (String.Empty, dn.Name, "Name");
99 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.None), "Decode(None)");
100 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.Reversed), "Decode(Reversed)");
101 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.UseSemicolons), "Decode(UseSemicolons)");
102 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.DoNotUsePlusSign), "Decode(DoNotUsePlusSign)");
103 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.DoNotUseQuotes), "Decode(DoNotUseQuotes)");
104 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.UseCommas), "Decode(UseCommas)");
105 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.UseNewLines), "Decode(UseNewLines)");
106 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.UseUTF8Encoding), "Decode(UseUTF8Encoding)");
107 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.UseT61Encoding), "Decode(UseT61Encoding)");
108 Assert.AreEqual (String.Empty, dn.Decode (X500DistinguishedNameFlags.ForceUTF8Encoding), "Decode(ForceUTF8Encoding)");
110 Assert.AreEqual (String.Empty, dn.Format (true), "Format(true)");
111 Assert.AreEqual (String.Empty, dn.Format (false), "Format(false)");
114 private void RsaIssuer (X500DistinguishedName dn)
116 Assert.AreEqual (name, dn.Name, "Name");
117 Assert.AreEqual (97, dn.RawData.Length, "RawData");
119 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.None), "Decode(None)");
120 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.Reversed), "Decode(Reversed)");
121 Assert.AreEqual ("C=US; O=\"RSA Data Security, Inc.\"; OU=Secure Server Certification Authority", dn.Decode (X500DistinguishedNameFlags.UseSemicolons), "Decode(UseSemicolons)");
122 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.DoNotUsePlusSign), "Decode(DoNotUsePlusSign)");
123 Assert.AreEqual ("C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority", dn.Decode (X500DistinguishedNameFlags.DoNotUseQuotes), "Decode(DoNotUseQuotes)");
124 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseCommas), "Decode(UseCommas)");
125 string newline = String.Format ("C=US{0}O=\"RSA Data Security, Inc.\"{0}OU=Secure Server Certification Authority", Environment.NewLine);
126 Assert.AreEqual (newline, dn.Decode (X500DistinguishedNameFlags.UseNewLines), "Decode(UseNewLines)");
127 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseUTF8Encoding), "Decode(UseUTF8Encoding)");
128 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseT61Encoding), "Decode(UseT61Encoding)");
129 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.ForceUTF8Encoding), "Decode(ForceUTF8Encoding)");
131 Assert.AreEqual (newline + Environment.NewLine, dn.Format (true), "Format(true)");
132 Assert.AreEqual (rname, dn.Format (false), "Format(false)");
136 [ExpectedException (typeof (ArgumentNullException))]
137 public void Constructor_AsnEncodedData_Null ()
139 new X500DistinguishedName ((AsnEncodedData) null);
143 public void Constructor_AsnEncodedData_Empty ()
145 X500DistinguishedName dn = new X500DistinguishedName (emptyData);
146 Assert.IsNull (dn.Oid, "Oid");
147 Assert.AreEqual (0, dn.RawData.Length, "RawData");
152 public void Constructor_AsnEncodedData ()
154 AsnEncodedData aed = new AsnEncodedData (cert_a_issuer_raw);
155 X500DistinguishedName dn = new X500DistinguishedName (aed);
156 Assert.IsNull (dn.Oid, "Oid");
161 [ExpectedException (typeof (ArgumentNullException))]
162 public void Constructor_ByteArray_Null ()
164 new X500DistinguishedName ((byte[]) null);
168 public void Constructor_ByteArray_Empty ()
170 X500DistinguishedName dn = new X500DistinguishedName (new byte[0]);
171 Assert.IsNotNull (dn.Oid, "Oid");
172 Assert.IsNull (dn.Oid.Value, "Oid.Value");
173 Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
174 Assert.AreEqual (0, dn.RawData.Length, "RawData");
179 public void Constructor_ByteArray ()
181 X500DistinguishedName dn = new X500DistinguishedName (cert_a_issuer_raw);
182 Assert.IsNotNull (dn.Oid, "Oid");
183 Assert.IsNull (dn.Oid.Value, "Oid.Value");
184 Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
189 [ExpectedException (typeof (ArgumentNullException))]
190 public void Constructor_String_Null ()
192 new X500DistinguishedName ((string) null);
196 public void Constructor_String_Empty ()
198 X500DistinguishedName dn = new X500DistinguishedName (String.Empty);
199 Assert.AreEqual (2, dn.RawData.Length, "RawData.Length");
200 Assert.AreEqual ("30-00", BitConverter.ToString (dn.RawData), "RawData");
205 public void Constructor_String ()
207 X500DistinguishedName dn = new X500DistinguishedName ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US");
208 Assert.IsNotNull (dn.Oid, "Oid");
209 Assert.IsNull (dn.Oid.Value, "Oid.Value");
210 Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
215 [ExpectedException (typeof (ArgumentNullException))]
216 public void Constructor_String_Null_Flags ()
218 new X500DistinguishedName ((string) null, X500DistinguishedNameFlags.None);
222 public void Constructor_String_Empty_Flags ()
224 X500DistinguishedName dn = new X500DistinguishedName (String.Empty, X500DistinguishedNameFlags.None);
225 Assert.AreEqual (2, dn.RawData.Length, "RawData.Length");
226 Assert.AreEqual ("30-00", BitConverter.ToString (dn.RawData), "RawData");
231 [ExpectedException (typeof (ArgumentException))]
232 public void Constructor_String_Empty_Flags_Bad ()
234 X500DistinguishedNameFlags flags = (X500DistinguishedNameFlags)Int32.MinValue;
235 new X500DistinguishedName (String.Empty, flags);
239 public void Constructor_String_Flags_None ()
241 X500DistinguishedName dn = new X500DistinguishedName (rname, X500DistinguishedNameFlags.None);
242 // can't call RsaIssuer because Name is reversed from None in those cases
243 // i.e. X500DistinguishedName (string) != X500DistinguishedName (string, X500DistinguishedNameFlags)
244 Assert.AreEqual (rname, dn.Name, "Name");
245 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.None), "Decode(None)");
246 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.Reversed), "Decode(Reversed)");
247 Assert.AreEqual ("C=US; O=\"RSA Data Security, Inc.\"; OU=Secure Server Certification Authority", dn.Decode (X500DistinguishedNameFlags.UseSemicolons), "Decode(UseSemicolons)");
248 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.DoNotUsePlusSign), "Decode(DoNotUsePlusSign)");
249 Assert.AreEqual ("C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority", dn.Decode (X500DistinguishedNameFlags.DoNotUseQuotes), "Decode(DoNotUseQuotes)");
250 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseCommas), "Decode(UseCommas)");
251 string newline = String.Format ("C=US{0}O=\"RSA Data Security, Inc.\"{0}OU=Secure Server Certification Authority", Environment.NewLine);
252 Assert.AreEqual (newline, dn.Decode (X500DistinguishedNameFlags.UseNewLines), "Decode(UseNewLines)");
253 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseUTF8Encoding), "Decode(UseUTF8Encoding)");
254 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseT61Encoding), "Decode(UseT61Encoding)");
255 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.ForceUTF8Encoding), "Decode(ForceUTF8Encoding)");
259 public void Constructor_String_Flags_Reversed ()
261 X500DistinguishedName dn = new X500DistinguishedName (name, X500DistinguishedNameFlags.None);
262 // can't call RsaIssuer because Name is reversed from None in those cases
263 Assert.AreEqual (name, dn.Name, "Name");
264 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.None), "Decode(None)");
265 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.Reversed), "Decode(Reversed)");
266 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.DoNotUsePlusSign), "Decode(DoNotUsePlusSign)");
267 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.UseCommas), "Decode(UseCommas)");
268 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.UseUTF8Encoding), "Decode(UseUTF8Encoding)");
269 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.UseT61Encoding), "Decode(UseT61Encoding)");
270 Assert.AreEqual (name, dn.Decode (X500DistinguishedNameFlags.ForceUTF8Encoding), "Decode(ForceUTF8Encoding)");
274 [ExpectedException (typeof (ArgumentNullException))]
275 public void Constructor_X500DistinguishedName_Null ()
277 new X500DistinguishedName ((X500DistinguishedName) null);
281 public void Constructor_X500DistinguishedName ()
283 X500DistinguishedName dn = new X500DistinguishedName (x509a.IssuerName);
284 Assert.IsNotNull (dn.Oid, "Oid");
285 Assert.IsNull (dn.Oid.Value, "Oid.Value");
286 Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
291 [ExpectedException (typeof (ArgumentException))]
292 public void Decode_BadFlag ()
294 new X500DistinguishedName (rname).Decode ((X500DistinguishedNameFlags) Int32.MinValue);
298 public void Decode_Separators ()
300 string semicolons = "C=US; O=\"RSA Data Security, Inc.\"; OU=Secure Server Certification Authority";
301 string newline = String.Format ("C=US{0}O=\"RSA Data Security, Inc.\"{0}OU=Secure Server Certification Authority", Environment.NewLine);
302 X500DistinguishedName dn = new X500DistinguishedName (rname, X500DistinguishedNameFlags.None);
303 Assert.AreEqual (rname, dn.Name, "Name");
304 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.None), "Decode(None)");
306 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseCommas), "Decode(UseCommas)");
307 Assert.AreEqual (semicolons, dn.Decode (X500DistinguishedNameFlags.UseSemicolons), "Decode(UseCommas|UseSemicolons)");
308 Assert.AreEqual (newline, dn.Decode (X500DistinguishedNameFlags.UseNewLines), "Decode(UseNewLines)");
310 Assert.AreEqual (semicolons, dn.Decode (X500DistinguishedNameFlags.UseCommas | X500DistinguishedNameFlags.UseSemicolons), "Decode(UseCommas|UseSemicolons)");
311 Assert.AreEqual (semicolons, dn.Decode (X500DistinguishedNameFlags.UseNewLines | X500DistinguishedNameFlags.UseSemicolons), "Decode(UseNewLines|UseSemicolons)");
312 Assert.AreEqual (rname, dn.Decode (X500DistinguishedNameFlags.UseCommas | X500DistinguishedNameFlags.UseNewLines), "Decode(UseCommas|UseNewLines)");
316 public void RFC3280MandatoryAttributeTypes ()
318 string expected = "dnQualifier=CA, OID.2.5.4.5=345, S=Maryland, DC=testcertificates, DC=gov, O=Test Certificates, C=US";
319 X509Certificate2 cert = new X509Certificate2 (RFC3280MandatoryAttributeTypesCACert_crt);
320 // note: strangely the (also CryptoAPI based) certificate viewer in Windows seems to resolve 2.5.4.5 as "Serial Number"
321 Assert.AreEqual (expected, cert.SubjectName.Name, "SubjectName");
322 X500DistinguishedName build = new X500DistinguishedName (expected);
323 Assert.AreEqual (expected, build.Name, "Name");
327 public void RFC3280OptionalAttributeTypes ()
329 string expected = "T=M.D., OID.2.5.4.44=III, SN=CA, OID.2.5.4.65=Fictitious, I=Q, G=John, L=Gaithersburg, O=Test Certificates, C=US";
330 X509Certificate2 cert = new X509Certificate2 (RFC3280OptionalAttributeTypesCACert_crt);
331 Assert.AreEqual (expected, cert.SubjectName.Name, "SubjectName");
332 X500DistinguishedName build = new X500DistinguishedName (expected);
333 Assert.AreEqual (expected, build.Name, "Name");
337 public void T61String ()
339 // http://bugzilla.ximian.com/show_bug.cgi?id=77295
340 byte[] sn = { 0x30, 0x81, 0xB5, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x44, 0x4B, 0x31, 0x2D, 0x30, 0x2B, 0x06,
341 0x03, 0x55, 0x04, 0x0A, 0x14, 0x24, 0x48, 0x65, 0x64, 0x65, 0x62, 0x79, 0x27, 0x73, 0x20, 0x4D, 0xF8, 0x62, 0x65, 0x6C, 0x68, 0x61,
342 0x6E, 0x64, 0x65, 0x6C, 0x20, 0x2F, 0x2F, 0x20, 0x43, 0x56, 0x52, 0x3A, 0x31, 0x33, 0x34, 0x37, 0x31, 0x39, 0x36, 0x37, 0x31, 0x2F,
343 0x30, 0x2D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x14, 0x26, 0x48, 0x65, 0x64, 0x65, 0x62, 0x79, 0x27, 0x73, 0x20, 0x4D, 0xF8, 0x62, 0x65,
344 0x6C, 0x68, 0x61, 0x6E, 0x64, 0x65, 0x6C, 0x20, 0x2D, 0x20, 0x53, 0x61, 0x6C, 0x67, 0x73, 0x61, 0x66, 0x64, 0x65, 0x6C, 0x69, 0x6E,
345 0x67, 0x65, 0x6E, 0x31, 0x1E, 0x30, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x0F, 0x76, 0x68,
346 0x6D, 0x40, 0x75, 0x73, 0x65, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x2E, 0x64, 0x6B, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x05,
347 0x13, 0x1D, 0x43, 0x56, 0x52, 0x3A, 0x31, 0x33, 0x34, 0x37, 0x31, 0x39, 0x36, 0x37, 0x2D, 0x55, 0x49, 0x44, 0x3A, 0x31, 0x32, 0x31,
348 0x32, 0x31, 0x32, 0x31, 0x32, 0x31, 0x32, 0x31, 0x32 };
349 X500DistinguishedName dn = new X500DistinguishedName (sn);
350 string subject = "OID.2.5.4.5=CVR:13471967-UID:121212121212, E=vhm@use.test.dk, CN=Hedeby's Møbelhandel - Salgsafdelingen, O=Hedeby's Møbelhandel // CVR:13471967, C=DK";
351 Assert.AreEqual (subject, dn.Name, "Name");