]> git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/kc/kc-51-testSecItemFind.c
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / regressions / kc / kc-51-testSecItemFind.c
1 //
2 // testSecItemFind.c
3 //
4 // Tests the ability of SecItemCopyMatching to replace the following
5 // deprecated keychain search functions:
6 //
7 // - SecKeychainSearchCreateFromAttributes +
8 // SecKeychainSearchCopyNext [for keys, certificates, passwords]
9 //
10 // - SecIdentitySearchCreate (or SecIdentitySearchCreateWithPolicy) +
11 // SecIdentitySearchCopyNext [for identities]
12 //
13 //
14 // This tool incidentally tests other Security API functions, including:
15 // - SecItemAdd
16 // - SecItemImport
17 // - SecItemDelete
18 // - SecKeyGenerateSymmetric
19 //
20 //
21 // To build and run this tool (from Terminal):
22 // cc -framework Security -framework CoreFoundation -o testSecItemFind testSecItemFind.c
23 // ./testSecItemFind
24 //
25 // IMPORTANT: when building this code yourself, make sure that the AUTO_TEST
26 // symbol is undefined (or defined to 0) below. If the AUTO_TEST symbol is
27 // defined and non-zero, it is assumed that this tool is being built as part of
28 // an automated regression test suite by internal Security test harness code.
29 //
30 //
31 // Last modified: Tue Nov 16 2010 (kcm)
32
33
34 #define AUTO_TEST 1
35
36 #include <CoreFoundation/CoreFoundation.h>
37 #include <CoreServices/CoreServices.h>
38 #include <Security/Security.h>
39
40 #include <stdlib.h>
41 #include <string.h>
42 #include <syslog.h>
43 #include <unistd.h>
44 #include <time.h>
45 #include <sys/param.h>
46
47 #if AUTO_TEST
48 #import "testmore.h"
49 #import "testenv.h"
50 #import "testleaks.h"
51 #else
52 #define tests_begin(ARGC, ARGV) /* no-op */
53 #define tests_end(RESULT) /* no-op */
54 #define plan_tests(COUNT) /* no-op */
55 #define ok(RESULT, REASON) /* no-op */
56 #endif
57
58 /* Following is a 3-element certificate chain
59 * (ROOT_CERT, INTERMEDIATE_CERT, LEAF_CERT)
60 */
61 unsigned char ROOT_CERT[985]={
62 0x30,0x82,0x03,0xD5,0x30,0x82,0x02,0xBD,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,
63 0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x30,0x81,0x9D,
64 0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x0C,0x11,0x54,0x65,0x73,0x74,0x2D,
65 0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x52,0x4F,0x4F,0x54,0x31,0x0E,0x30,0x0C,
66 0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,
67 0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,
68 0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,
69 0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,
70 0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
71 0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,
72 0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,
73 0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1E,0x17,
74 0x0D,0x30,0x39,0x31,0x32,0x31,0x38,0x31,0x37,0x32,0x39,0x32,0x33,0x5A,0x17,0x0D,
75 0x31,0x30,0x31,0x32,0x31,0x38,0x31,0x37,0x32,0x39,0x32,0x33,0x5A,0x30,0x81,0x9D,
76 0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x0C,0x11,0x54,0x65,0x73,0x74,0x2D,
77 0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x52,0x4F,0x4F,0x54,0x31,0x0E,0x30,0x0C,
78 0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,
79 0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,
80 0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,
81 0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,
82 0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
83 0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,
84 0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,
85 0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,
86 0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,
87 0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB0,0x4C,
88 0x94,0xF7,0x56,0x26,0x91,0xB8,0xD1,0x5B,0x7C,0xEE,0x74,0xCB,0x1F,0x43,0xFE,0x88,
89 0x24,0xAD,0xB0,0x1E,0x85,0x86,0xE9,0x3F,0xE7,0x74,0x40,0x6C,0x4A,0x8E,0x6B,0x50,
90 0x7A,0x1B,0x43,0x9A,0x9E,0xF4,0x81,0xB3,0xF1,0xDB,0x6E,0xD4,0xFA,0xAE,0x06,0xCB,
91 0x7F,0xE6,0xCA,0x06,0x06,0xC4,0x1E,0x2D,0xF3,0xFA,0x67,0xD6,0x95,0x0E,0xAC,0xCA,
92 0x2B,0x25,0x14,0x4C,0x20,0x04,0xB4,0x26,0xAC,0x15,0x62,0x15,0xA6,0x21,0x14,0x51,
93 0xCC,0x77,0x82,0x11,0xD0,0xF8,0xB0,0x06,0xC1,0x0F,0xFB,0x08,0x60,0x53,0x11,0x1F,
94 0x00,0xA8,0x27,0x0E,0x2C,0x2C,0x63,0x34,0x6A,0xC5,0x4B,0x2D,0xCC,0x07,0xF6,0x39,
95 0xDC,0x00,0xCF,0x6E,0x29,0x15,0x3E,0x3F,0x6C,0x89,0xB9,0x48,0x97,0x19,0xA2,0xB8,
96 0x44,0x8D,0x98,0x85,0xF4,0x0B,0x70,0x06,0xD6,0x9A,0x39,0x4F,0x44,0x92,0x73,0x74,
97 0xDF,0x46,0x10,0x9C,0xB5,0xBB,0x69,0xF4,0xE1,0xB5,0x61,0x2E,0xFF,0x92,0xDB,0x47,
98 0x93,0x48,0x45,0xEB,0x7E,0xFA,0xCC,0xDB,0xCE,0x50,0x0A,0xCA,0xAF,0xAB,0x7D,0x09,
99 0x9A,0x1E,0xC4,0x08,0xA1,0xD4,0xB9,0x2A,0x42,0x49,0x10,0x75,0x63,0x4E,0x51,0x3B,
100 0xF7,0xF4,0xCA,0xCB,0x05,0xC9,0xE0,0xC9,0xD3,0x04,0x14,0x81,0xF6,0x9A,0xEE,0x0C,
101 0x2B,0x56,0x87,0x20,0x50,0x27,0x14,0x71,0x1C,0x30,0x18,0x8C,0xDD,0xF4,0xA9,0x41,
102 0x13,0x6D,0xE4,0x41,0xB1,0xE0,0x7E,0x09,0xD7,0x99,0xCE,0xE4,0x7A,0x91,0x65,0xBB,
103 0x3F,0xE1,0xD4,0x07,0x8D,0xA9,0x23,0x0A,0xA4,0x80,0x47,0x58,0xD5,0x25,0x02,0x03,
104 0x01,0x00,0x01,0xA3,0x20,0x30,0x1E,0x30,0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,
105 0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x0B,0x06,0x03,0x55,0x1D,0x0F,0x04,
106 0x04,0x03,0x02,0x02,0x84,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
107 0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x38,0x44,0x10,0xF4,0x24,0x4A,0xAA,
108 0x9F,0x0D,0x37,0x5E,0x75,0xB7,0xF5,0xC5,0x27,0x19,0x57,0xE5,0x25,0x4A,0x44,0x03,
109 0x5F,0x2E,0xD4,0x70,0x69,0xDD,0x55,0xDB,0x47,0x07,0x06,0x3E,0x5D,0xA4,0xBB,0x64,
110 0xE2,0xA6,0x09,0x8B,0x6D,0x0B,0x50,0x33,0x5A,0x92,0x5A,0x5B,0xDF,0x6A,0x9F,0x81,
111 0x5F,0x17,0x95,0xB0,0xC6,0xC3,0xCD,0x6D,0x17,0xDD,0x83,0xC1,0xA5,0xB7,0xCD,0xFF,
112 0xE8,0x13,0x10,0x35,0x85,0x3E,0xCA,0xE4,0xF5,0x22,0x58,0x1E,0x68,0x14,0x62,0x35,
113 0xE4,0x65,0xB4,0xD3,0x42,0x5A,0x03,0x5C,0x2D,0x76,0xD5,0x9B,0xAA,0xCB,0x3A,0xAC,
114 0x55,0x58,0xAD,0x67,0x30,0xDC,0xC3,0xA7,0xA9,0x37,0xBB,0x61,0xA2,0xEA,0x6E,0x0C,
115 0xB0,0x4B,0x0D,0x64,0x3D,0x59,0x3C,0xA3,0xA1,0x73,0x4F,0x33,0xDB,0x6F,0xBF,0x2D,
116 0xB2,0x9D,0xCE,0x05,0x1C,0xF0,0xAB,0x4A,0xB0,0x70,0x5D,0x32,0x20,0x22,0xD7,0x12,
117 0xC0,0x1C,0x0B,0x0D,0xC0,0x72,0x6B,0x6F,0xA4,0xF8,0xAA,0xD2,0x34,0x36,0x63,0x84,
118 0x80,0xF0,0x70,0x5E,0x09,0xEA,0xFF,0x48,0x49,0x85,0x83,0x8E,0x8E,0x6E,0x4C,0x2E,
119 0x2F,0xBB,0xBF,0xDF,0x3B,0x73,0x65,0xA2,0x0D,0x09,0x84,0x8F,0x08,0x86,0x61,0x27,
120 0x58,0xB6,0x7E,0x2D,0xEC,0x08,0xBA,0x40,0x5D,0x20,0x54,0x37,0xDD,0xCC,0xE5,0xDB,
121 0x38,0x68,0xEE,0x56,0x9F,0x92,0xDD,0x03,0x04,0xD2,0x94,0x51,0xD3,0xA9,0x08,0x2E,
122 0x6E,0x25,0x8E,0xBF,0x8A,0xA9,0x2B,0xAD,0x50,0x00,0xA7,0x39,0x11,0x6A,0x9A,0x28,
123 0x99,0x9A,0xB9,0x3B,0xB9,0xB5,0x9C,0x19,0x3A,
124 };
125
126 unsigned char INTERMEDIATE_CERT[1037]={
127 0x30,0x82,0x04,0x09,0x30,0x82,0x02,0xF1,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x02,
128 0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x30,0x81,0x9D,
129 0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x0C,0x11,0x54,0x65,0x73,0x74,0x2D,
130 0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x52,0x4F,0x4F,0x54,0x31,0x0E,0x30,0x0C,
131 0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,
132 0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,
133 0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,
134 0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,
135 0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
136 0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,
137 0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,
138 0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1E,0x17,
139 0x0D,0x30,0x39,0x31,0x32,0x31,0x38,0x31,0x37,0x33,0x30,0x35,0x34,0x5A,0x17,0x0D,
140 0x31,0x30,0x31,0x32,0x31,0x38,0x31,0x37,0x33,0x30,0x35,0x34,0x5A,0x30,0x81,0xA5,
141 0x31,0x22,0x30,0x20,0x06,0x03,0x55,0x04,0x03,0x0C,0x19,0x54,0x65,0x73,0x74,0x2D,
142 0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x49,0x4E,0x54,0x45,0x52,0x4D,0x45,0x44,
143 0x49,0x41,0x54,0x45,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,
144 0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,
145 0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,
146 0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
147 0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,
148 0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,
149 0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,
150 0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,
151 0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
152 0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,
153 0x0A,0x02,0x82,0x01,0x01,0x00,0xC4,0xBD,0x46,0x0E,0x0F,0x5C,0x1C,0xA2,0x23,0xD2,
154 0x3B,0x8C,0xC4,0x02,0x52,0x8C,0xD8,0xB1,0xC2,0x58,0x2E,0x84,0xAA,0x6C,0xCB,0x4B,
155 0xE4,0xF1,0xE7,0x48,0x98,0x46,0x6B,0xD0,0x50,0xB0,0xA3,0x1F,0x23,0xC6,0x3C,0x81,
156 0x73,0xE7,0xEA,0xAA,0x55,0xF7,0x37,0x58,0x85,0xF6,0x96,0x0D,0xC0,0x81,0x8D,0x3D,
157 0xD9,0xAD,0xFA,0x32,0x46,0x56,0x4A,0x53,0xF5,0x53,0x34,0x5B,0xFC,0xFC,0x51,0x2A,
158 0x45,0xD4,0xCB,0x53,0xF9,0x58,0xBF,0x7D,0x48,0xB3,0x23,0x41,0xD7,0x93,0x1C,0xC2,
159 0x32,0xE8,0x1C,0x82,0xDC,0xDC,0xCB,0xED,0x0B,0xDA,0x8A,0x1C,0xC0,0x0E,0x83,0x24,
160 0xE6,0x2E,0x68,0xA6,0xB6,0x60,0xEE,0xAF,0xB1,0x07,0xF1,0xC0,0xDB,0x29,0x83,0x9E,
161 0x0C,0xF4,0xCF,0x67,0x5B,0x49,0x3A,0x17,0x7E,0xC1,0xEB,0x75,0x3E,0xDD,0x0F,0x9A,
162 0xC7,0x06,0x60,0x2B,0x18,0xBD,0xAA,0x96,0xD1,0xE1,0x9C,0xF0,0x34,0xFF,0x3E,0x8C,
163 0x4A,0x96,0x5D,0x68,0x7C,0xCF,0xA1,0x14,0xED,0xB1,0x8E,0x10,0x8D,0x1F,0x15,0x22,
164 0x4E,0x8E,0x1A,0xC7,0xAD,0xB9,0x16,0xCB,0x3C,0xCB,0x5D,0xB9,0xAC,0xD9,0xFE,0xAE,
165 0xDE,0x06,0x3B,0xB6,0xA1,0xAA,0x7C,0x91,0x76,0xC6,0xA4,0x81,0xBD,0x29,0x86,0x33,
166 0xA6,0xB5,0x4D,0x28,0x94,0x51,0x81,0x3F,0x68,0x95,0xEB,0x41,0x7A,0xE9,0x87,0xD7,
167 0xDC,0xC8,0xA0,0x5F,0xAB,0x29,0xD9,0xC4,0x08,0xC8,0xA0,0x0B,0x77,0xAC,0x6C,0x21,
168 0x10,0xA4,0xED,0x86,0x78,0x99,0x1F,0xA7,0x23,0x33,0x34,0x89,0x80,0x02,0xBC,0xAF,
169 0xC6,0x3E,0x38,0xFB,0x7C,0x47,0x02,0x03,0x01,0x00,0x01,0xA3,0x4C,0x30,0x4A,0x30,
170 0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,
171 0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x02,0x84,
172 0x30,0x27,0x06,0x03,0x55,0x1D,0x11,0x04,0x20,0x30,0x1E,0x81,0x1C,0x73,0x65,0x63,
173 0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,
174 0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
175 0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x3C,0x66,0x3B,
176 0x9D,0x6E,0xA9,0x0E,0xC9,0xC2,0x6C,0xF4,0x79,0xFB,0xD5,0x6E,0x1F,0x01,0x4E,0x0D,
177 0x2C,0x64,0x7B,0x6E,0xD7,0xC7,0xA7,0x64,0x8B,0xF0,0xCD,0x93,0xCD,0x12,0x29,0x71,
178 0x87,0x3E,0xA3,0x1E,0x7F,0x57,0xC7,0xD9,0xBF,0xD2,0xF2,0x03,0x27,0xD5,0x5E,0xEF,
179 0x59,0xBC,0x91,0x37,0xB4,0x4A,0xEE,0xD2,0x2F,0xEA,0x92,0x07,0xBC,0xEC,0xAC,0x6A,
180 0xF1,0x34,0xA4,0x40,0x61,0x8B,0xB9,0x3D,0xAF,0x5B,0x86,0x6E,0xEE,0x4C,0xCB,0x7F,
181 0x1F,0xD0,0x0F,0x9E,0x5A,0xF0,0x39,0xFD,0x89,0xF3,0x03,0x61,0x5A,0xDF,0x6B,0x5F,
182 0xE3,0x33,0x51,0x80,0x1B,0x61,0xFE,0x7A,0xC7,0x27,0xBF,0x12,0xB5,0x69,0x79,0x1E,
183 0xAD,0x75,0xA8,0xFA,0x94,0xCC,0x22,0x4C,0xF9,0xB4,0xD3,0xD0,0xDC,0x57,0xD3,0x66,
184 0x96,0xDD,0x8A,0xC0,0xE4,0x11,0x5A,0xD9,0xB3,0x76,0x17,0x04,0xDA,0x62,0x71,0x58,
185 0xEA,0x99,0xC3,0x06,0xA7,0xE8,0xDB,0xA9,0x05,0xEC,0xA3,0xCA,0xDA,0x2E,0x77,0x66,
186 0xF4,0xC4,0xD2,0xC6,0xF0,0x5F,0xE6,0x88,0xDF,0x7F,0x23,0xDE,0x7B,0x04,0xA4,0x22,
187 0x45,0xEF,0x0A,0x13,0x79,0x8E,0xE1,0x14,0x22,0x79,0x22,0x86,0x1A,0x4C,0xA7,0xBA,
188 0x06,0x55,0xD9,0x5E,0xF3,0x9C,0xE0,0x1F,0xE3,0xA4,0x1C,0x8E,0x01,0x9F,0x7E,0xEF,
189 0xD2,0xA7,0x8D,0xD6,0x4D,0x1A,0x3D,0xA7,0xB2,0xDB,0x44,0x25,0xB5,0xA6,0x8A,0xD5,
190 0x49,0x87,0x04,0x6C,0x41,0x13,0x88,0x7A,0xFB,0x5E,0x16,0xA2,0x8F,0x37,0x81,0x47,
191 0xD8,0x27,0x3D,0xBD,0xB1,0x3E,0xCE,0x2A,0x07,0x75,0x45,0x5F,0x44,
192 };
193
194 unsigned char LEAF_CERT[1037]={
195 0x30,0x82,0x04,0x09,0x30,0x82,0x02,0xF1,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x03,
196 0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x30,0x81,0xA5,
197 0x31,0x22,0x30,0x20,0x06,0x03,0x55,0x04,0x03,0x0C,0x19,0x54,0x65,0x73,0x74,0x2D,
198 0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x49,0x4E,0x54,0x45,0x52,0x4D,0x45,0x44,
199 0x49,0x41,0x54,0x45,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,
200 0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,
201 0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,
202 0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
203 0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,
204 0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,
205 0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,
206 0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,
207 0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1E,0x17,0x0D,0x30,0x39,0x31,0x32,0x31,0x38,0x31,
208 0x37,0x33,0x32,0x31,0x36,0x5A,0x17,0x0D,0x31,0x30,0x31,0x32,0x31,0x38,0x31,0x37,
209 0x33,0x32,0x31,0x36,0x5A,0x30,0x81,0x9D,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,
210 0x03,0x0C,0x11,0x54,0x65,0x73,0x74,0x2D,0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,
211 0x4C,0x45,0x41,0x46,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,0x0C,0x05,0x41,
212 0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0B,0x0C,0x0B,0x43,
213 0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x31,0x0B,0x30,0x09,0x06,0x03,
214 0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
215 0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,
216 0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,
217 0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,
218 0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,
219 0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
220 0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,
221 0x0A,0x02,0x82,0x01,0x01,0x00,0xBF,0x1B,0x87,0x6B,0x10,0xF8,0xF6,0x24,0x07,0x40,
222 0xC3,0xE3,0x81,0x26,0xD6,0xF4,0xFF,0xAA,0x6C,0x26,0xD4,0xBF,0xF7,0x9A,0xF5,0xB8,
223 0x63,0xBD,0x8B,0xFD,0x4B,0xFE,0xFF,0x4B,0xA2,0x15,0x13,0x52,0x84,0x87,0x9E,0x2B,
224 0x32,0x5B,0xF8,0x01,0x28,0x5E,0xF1,0x9C,0xE7,0x52,0xB0,0x89,0xB8,0x4A,0xD0,0x87,
225 0x40,0x0C,0xCD,0xAC,0x11,0x22,0x89,0x44,0x26,0x3B,0x40,0xF3,0x34,0x61,0x14,0x3A,
226 0x94,0xF3,0x1F,0x27,0x62,0xF8,0x8C,0xB4,0xF5,0x1E,0xA6,0x37,0x53,0xB2,0xB3,0x1E,
227 0x35,0xF6,0x00,0x34,0x4B,0x28,0x72,0x5B,0x9D,0xD8,0xEA,0x06,0x91,0x77,0x57,0x38,
228 0x9C,0xA5,0x66,0x5F,0x1A,0x9A,0x0B,0xCC,0x2F,0x2E,0x58,0xA2,0x70,0x66,0xA6,0xEF,
229 0x1B,0x3A,0x0E,0xF0,0x4B,0xA6,0x9D,0x6D,0x63,0xE0,0x1C,0x9C,0x8E,0xFF,0x6F,0x50,
230 0x5F,0x03,0x1A,0x80,0x12,0x4A,0xB6,0x89,0x83,0x5C,0x51,0x9F,0x2F,0xEA,0xE4,0x7F,
231 0x12,0xFB,0xE4,0x92,0xF0,0x8B,0x17,0x35,0x02,0x73,0xA0,0x7D,0xA2,0xB9,0x89,0xE2,
232 0x78,0x52,0xA1,0x08,0x42,0x78,0xD5,0xD3,0x8C,0x3C,0xF2,0x88,0x5E,0x7A,0xCC,0x94,
233 0x80,0x42,0xEA,0xED,0x6E,0x64,0x19,0x5E,0x53,0x05,0xB6,0x60,0xDB,0x81,0x92,0x2C,
234 0x3D,0xD4,0xAF,0xF8,0xED,0xD9,0x28,0xCE,0x0B,0xD9,0xDC,0x20,0x0C,0xA9,0x8D,0xA4,
235 0x54,0xD1,0xDA,0xDE,0x30,0x4A,0x67,0xC6,0xAC,0x4E,0xE3,0xB4,0xD7,0x16,0xF5,0xDC,
236 0xE3,0x52,0xAC,0x01,0x1C,0xB6,0xC1,0x5B,0xB4,0xEA,0x67,0x25,0xFE,0xF6,0x58,0x5C,
237 0xFE,0x88,0x4E,0xCF,0xF1,0x11,0x02,0x03,0x01,0x00,0x01,0xA3,0x4C,0x30,0x4A,0x30,
238 0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x07,0x80,0x30,
239 0x0F,0x06,0x03,0x55,0x1D,0x25,0x04,0x08,0x30,0x06,0x06,0x04,0x55,0x1D,0x25,0x00,
240 0x30,0x27,0x06,0x03,0x55,0x1D,0x11,0x04,0x20,0x30,0x1E,0x81,0x1C,0x73,0x65,0x63,
241 0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,
242 0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
243 0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x1A,0xE5,0xD1,
244 0x13,0x66,0x83,0xC7,0x1A,0xB0,0x50,0xF0,0x1B,0x6E,0x70,0x6E,0x36,0x1A,0x0F,0x12,
245 0x9E,0x0B,0xFD,0x4B,0x79,0xEC,0xAA,0x5E,0x2A,0x37,0x79,0x50,0x97,0x13,0x9E,0xB6,
246 0x43,0xF0,0xD2,0xC6,0xF3,0x43,0x73,0x33,0x6C,0xCB,0x73,0xE5,0xBE,0x4C,0x42,0x6F,
247 0x33,0x76,0x96,0xA2,0x6B,0xA0,0x8D,0xAD,0x46,0xA5,0xD4,0xAC,0x0E,0x55,0x80,0x1A,
248 0x6E,0xAF,0xC2,0x2E,0xB3,0xD4,0x64,0xC3,0x65,0xFA,0x1C,0x42,0x47,0x12,0x9F,0x44,
249 0xD2,0x1F,0xCF,0xA1,0x53,0x49,0x66,0x66,0x14,0x21,0xD4,0x17,0xD1,0x26,0x75,0xAD,
250 0x08,0x93,0x9C,0x3B,0xB7,0x7C,0x03,0x2F,0x76,0x5D,0xB7,0x25,0x83,0x68,0xE3,0x01,
251 0x5C,0xCD,0x87,0x7A,0x71,0x8B,0x8D,0x5D,0x27,0x27,0xF2,0x24,0x56,0x7C,0x7E,0x33,
252 0x8F,0xE6,0x02,0x46,0xAD,0x63,0x28,0x85,0xA2,0x9E,0xEA,0x5A,0xC4,0x92,0xCE,0x76,
253 0xE8,0xD4,0xD4,0x7D,0x48,0x44,0xA4,0x21,0x8C,0xB7,0xC2,0x15,0x80,0x87,0x19,0xB1,
254 0x10,0x6A,0xC7,0x51,0xB7,0x25,0x40,0x26,0x8A,0xCC,0xB6,0x0C,0xE2,0x0D,0xA1,0x40,
255 0x20,0x85,0x0F,0xE5,0xB9,0xB5,0x32,0x10,0xA9,0x5F,0x25,0xCA,0xD2,0x95,0x11,0x54,
256 0x41,0xEA,0xC3,0xBA,0x0C,0x24,0x10,0x28,0xC9,0x09,0xAF,0x7E,0xDF,0x6A,0x2F,0x30,
257 0x49,0x7C,0xB0,0x23,0x46,0xA8,0xDC,0xE3,0x6A,0x17,0x87,0xF7,0xCC,0x3A,0xBD,0x11,
258 0x95,0xC3,0x0A,0x37,0xD1,0x1F,0x20,0xB6,0x1B,0xB2,0xA2,0x45,0xFF,0xC1,0x0D,0x9A,
259 0x56,0xCD,0x5A,0xF6,0x08,0xAA,0xBD,0xAB,0x13,0xC6,0xFD,0xAA,0xEC,
260 };
261
262 /* Test certificate for Code Signing policy
263 */
264 unsigned char Test_codesign[1017]={
265 0x30,0x82,0x03,0xF5,0x30,0x82,0x02,0xDD,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x77,
266 0xCE,0xF5,0x3D,0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,
267 0x30,0x81,0xA5,0x31,0x22,0x30,0x20,0x06,0x03,0x55,0x04,0x03,0x0C,0x19,0x54,0x65,
268 0x73,0x74,0x2D,0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x49,0x4E,0x54,0x45,0x52,
269 0x4D,0x45,0x44,0x49,0x41,0x54,0x45,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,
270 0x0C,0x05,0x41,0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0B,
271 0x0C,0x0B,0x43,0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x31,0x0B,0x30,
272 0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,
273 0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,
274 0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,
275 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,
276 0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,
277 0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1E,0x17,0x0D,0x31,0x30,0x30,0x35,
278 0x32,0x30,0x30,0x31,0x32,0x35,0x33,0x32,0x5A,0x17,0x0D,0x31,0x31,0x30,0x35,0x32,
279 0x30,0x30,0x31,0x32,0x35,0x33,0x32,0x5A,0x30,0x81,0xA8,0x31,0x24,0x30,0x22,0x06,
280 0x03,0x55,0x04,0x03,0x0C,0x1B,0x54,0x65,0x73,0x74,0x2D,0x37,0x38,0x37,0x35,0x38,
281 0x30,0x31,0x20,0x28,0x43,0x6F,0x64,0x65,0x20,0x53,0x69,0x67,0x6E,0x69,0x6E,0x67,
282 0x29,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,
283 0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x0B,0x0C,
284 0x07,0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,
285 0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
286 0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,
287 0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,0x09,0x2A,0x86,0x48,0x86,
288 0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2D,
289 0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,
290 0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
291 0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,
292 0x82,0x01,0x01,0x00,0xC0,0x5E,0x52,0x53,0xB0,0x05,0x8D,0x9E,0xF2,0xBF,0x2E,0xA1,
293 0x95,0xD5,0x10,0x97,0xFC,0x8E,0x77,0x6E,0x63,0x7A,0x7D,0xD2,0x56,0x05,0xE9,0xEE,
294 0x3D,0xEE,0xCA,0xA4,0xBB,0x99,0x42,0xA2,0x55,0x67,0x97,0x15,0xFB,0x94,0x6D,0x22,
295 0x39,0x7F,0xE9,0xC0,0x72,0x41,0x8F,0xF5,0x76,0x55,0x65,0x3B,0x39,0x5F,0x31,0x15,
296 0x72,0x2A,0xB4,0x2F,0xED,0xB7,0x6A,0x3E,0xE9,0x3A,0x1C,0x50,0xD4,0x31,0x6D,0x7A,
297 0x71,0x28,0x98,0x8D,0x8A,0xBF,0x90,0x01,0x8A,0xFF,0x42,0x62,0xEB,0xE5,0xC8,0x5A,
298 0xB2,0x5A,0xB8,0x46,0x27,0xDA,0xD5,0x70,0xAF,0xD4,0xF6,0xF2,0xEC,0xD6,0x43,0x7E,
299 0x25,0x31,0xED,0xA2,0x1E,0xFA,0x77,0xF4,0x59,0xBF,0x3F,0x11,0xAE,0xF1,0x0E,0xC9,
300 0xFD,0x56,0xCA,0xA0,0x3E,0x8B,0xA5,0xE9,0xF6,0x91,0x82,0xE0,0xC6,0x5E,0x35,0x92,
301 0x3F,0x0E,0x77,0x23,0x88,0x6F,0x33,0x91,0xAC,0x98,0xC5,0xF5,0x52,0x12,0xB2,0x3A,
302 0x08,0x66,0xEB,0xC8,0x14,0x8E,0xED,0x0F,0xE5,0x76,0xCE,0x36,0xE8,0xED,0xB6,0x41,
303 0xD6,0xF3,0x1C,0x24,0xBA,0xCC,0xEE,0x28,0xF8,0xC8,0xAE,0x87,0x15,0x1D,0x33,0x47,
304 0xEA,0x5B,0x7D,0xE2,0x80,0xA9,0x6B,0xE3,0x8B,0x36,0xD0,0x25,0x2C,0x32,0xDA,0xFF,
305 0x7C,0x85,0x28,0x48,0xDB,0x35,0x2A,0x1A,0xBE,0x7F,0xCD,0xE1,0xA6,0x79,0x35,0xB3,
306 0x79,0xA3,0xB9,0x15,0xC6,0x31,0xA1,0xB4,0x63,0xD8,0x05,0x1D,0xDD,0x11,0x74,0xCD,
307 0xCF,0xBD,0x27,0x02,0xB7,0xD8,0xA9,0xA1,0x1D,0xFB,0xA1,0xEC,0x44,0x8D,0x21,0x64,
308 0x84,0x2E,0x6B,0x3B,0x02,0x03,0x01,0x00,0x01,0xA3,0x2A,0x30,0x28,0x30,0x0E,0x06,
309 0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x16,0x06,
310 0x03,0x55,0x1D,0x25,0x01,0x01,0xFF,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,
311 0x05,0x05,0x07,0x03,0x03,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
312 0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x80,0xC4,0xB6,0x9D,0xBE,0x72,0x30,
313 0x72,0xFD,0x49,0x43,0x8F,0x3B,0xFE,0xC6,0xF1,0x4D,0xAA,0xB3,0xD1,0xD6,0x0C,0x54,
314 0x9D,0x24,0xDF,0x86,0x9B,0x0A,0x68,0x55,0x4B,0x5A,0x20,0x53,0xC0,0xBF,0x82,0xAF,
315 0xC7,0x19,0x19,0x43,0xA1,0xA4,0x53,0xF4,0xE5,0x33,0xE6,0xF7,0xAD,0x8E,0x6D,0xD8,
316 0x94,0x23,0xEB,0x3E,0x6A,0xCF,0xDA,0x4B,0x09,0x6E,0x26,0x2B,0x62,0x70,0x98,0x0A,
317 0xCE,0x58,0x70,0xA6,0xAD,0x08,0x45,0xAB,0x9E,0x89,0xBB,0xF8,0x84,0x6F,0x0D,0x9B,
318 0x77,0xBA,0x60,0x9E,0xB8,0xA6,0xB6,0x7D,0x20,0xE9,0x83,0x72,0xE1,0xE9,0xB0,0x0E,
319 0x0D,0x27,0xFB,0xD0,0x4C,0x81,0x88,0xAF,0x82,0x8F,0xB9,0x82,0xAD,0x1D,0x1B,0x54,
320 0x11,0x84,0x16,0xFC,0x0B,0x53,0xB8,0xED,0x71,0xA2,0x6A,0xD9,0xC7,0x88,0xEE,0xD6,
321 0x0C,0x5E,0xAD,0x2E,0x50,0xBA,0x56,0x12,0x95,0x5C,0x7F,0xF1,0x3B,0x48,0xB5,0x17,
322 0x53,0xA9,0xC5,0x4C,0xD6,0x8C,0x39,0xCB,0x1A,0x5B,0xB6,0x4B,0x73,0x67,0x1E,0xB5,
323 0x7D,0x13,0xAE,0x6B,0xD5,0xF4,0x59,0xE3,0xA1,0x4C,0x6A,0xEC,0xA5,0x27,0x07,0x9D,
324 0x93,0x8F,0xF5,0xBB,0x50,0x28,0x00,0x05,0x25,0xCD,0xED,0xF7,0xA9,0x11,0x22,0x7E,
325 0x92,0x4D,0xF5,0x7C,0x55,0xF4,0x1C,0x7A,0xA3,0xBC,0x24,0xC7,0xFB,0xED,0x6A,0x0A,
326 0x1E,0xD5,0x9D,0x63,0xE0,0x2B,0x91,0x59,0x48,0xF2,0xF6,0xEB,0xF9,0xEB,0x9E,0x4D,
327 0x3E,0xAE,0x44,0x9D,0xF9,0x93,0xB5,0x44,0xA1,0x36,0x3E,0x4E,0xC7,0xD9,0x47,0x83,
328 0xCE,0xDD,0xA0,0x7C,0xA1,0xB4,0x75,0x1F,0xC8,
329 };
330
331 /* Test certificate for S/MIME policy (encrypt only, no sign)
332 */
333 unsigned char Test_smime_encryptonly[1060]={
334 0x30,0x82,0x04,0x20,0x30,0x82,0x03,0x08,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x77,
335 0xCF,0x46,0x7D,0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,
336 0x30,0x81,0xA5,0x31,0x22,0x30,0x20,0x06,0x03,0x55,0x04,0x03,0x0C,0x19,0x54,0x65,
337 0x73,0x74,0x2D,0x35,0x36,0x38,0x35,0x33,0x31,0x36,0x2D,0x49,0x4E,0x54,0x45,0x52,
338 0x4D,0x45,0x44,0x49,0x41,0x54,0x45,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x0A,
339 0x0C,0x05,0x41,0x70,0x70,0x6C,0x65,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0B,
340 0x0C,0x0B,0x43,0x6F,0x72,0x65,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x31,0x0B,0x30,
341 0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,
342 0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,
343 0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,0x06,
344 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,0x75,
345 0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,0x61,
346 0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1E,0x17,0x0D,0x31,0x30,0x30,0x37,
347 0x32,0x37,0x32,0x30,0x35,0x39,0x35,0x38,0x5A,0x17,0x0D,0x31,0x32,0x30,0x37,0x32,
348 0x37,0x32,0x30,0x35,0x39,0x35,0x38,0x5A,0x30,0x81,0xB2,0x31,0x21,0x30,0x1F,0x06,
349 0x03,0x55,0x04,0x03,0x0C,0x18,0x54,0x65,0x73,0x74,0x2D,0x45,0x6E,0x63,0x72,0x79,
350 0x70,0x74,0x69,0x6F,0x6E,0x20,0x28,0x53,0x2F,0x4D,0x49,0x4D,0x45,0x29,0x31,0x13,
351 0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,
352 0x6E,0x63,0x2E,0x31,0x25,0x30,0x23,0x06,0x03,0x55,0x04,0x0B,0x0C,0x1C,0x43,0x6F,
353 0x72,0x65,0x20,0x4F,0x53,0x20,0x49,0x6E,0x66,0x6F,0x72,0x6D,0x61,0x74,0x69,0x6F,
354 0x6E,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x31,0x0B,0x30,0x09,0x06,0x03,
355 0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
356 0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,
357 0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x23,0x30,0x21,0x06,0x09,0x2A,0x86,
358 0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x14,0x73,0x6D,0x69,0x6D,0x65,0x2D,0x74,
359 0x65,0x73,0x74,0x40,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,
360 0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,
361 0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xBB,0x8F,
362 0xC3,0x01,0xD7,0x8A,0x62,0xE2,0xDD,0x26,0xE3,0x13,0x3E,0x61,0xC7,0x90,0xDE,0x98,
363 0xCB,0x4A,0xC6,0x80,0xB3,0x36,0x99,0x8A,0xDE,0x6D,0xCF,0x60,0x7B,0x38,0x2E,0x86,
364 0x0F,0x9E,0x9F,0xB0,0xCB,0x23,0xB1,0x52,0x0E,0x6E,0x70,0xD5,0x8D,0x56,0x32,0x36,
365 0x35,0x7D,0x59,0x32,0xE6,0x3F,0x67,0x2F,0xC0,0x0F,0x2B,0x85,0x47,0x20,0x70,0x22,
366 0xE5,0xB0,0x3C,0xF7,0xE3,0x4A,0x40,0xA5,0xB2,0x28,0xE5,0xB1,0x85,0x47,0x54,0x03,
367 0xD1,0xB6,0x96,0x3E,0xDB,0x8D,0xD0,0x0E,0x5E,0x7A,0x65,0x2A,0x8A,0xBE,0xF7,0xB0,
368 0x28,0x70,0x42,0x55,0x5A,0xAE,0xE6,0x58,0x91,0x20,0x5D,0x5B,0xFF,0x9B,0xF0,0x0C,
369 0x49,0x94,0x55,0x68,0x46,0x34,0x2A,0xE4,0xA1,0x69,0x89,0xC8,0xB1,0xE7,0x07,0xB7,
370 0xEC,0x2C,0x8A,0x65,0xF0,0xC6,0x51,0x3F,0x7C,0xC9,0x6F,0x42,0x71,0x15,0x30,0x9F,
371 0xB5,0xA7,0xA5,0xD1,0xFE,0x2B,0x46,0x4F,0x3D,0xFD,0xCD,0xA8,0x1B,0x82,0x7B,0xA0,
372 0x7B,0x9F,0x34,0x00,0xB7,0xC5,0x9F,0xCC,0x74,0xB4,0x35,0xC6,0x31,0x38,0x8D,0x91,
373 0x79,0xE8,0xAF,0xCB,0xE4,0x17,0x78,0x11,0x7A,0x41,0xB1,0xF8,0x4D,0x2C,0xEE,0x7E,
374 0x8D,0xEB,0x09,0x89,0xDC,0x74,0x2B,0xC1,0x25,0x57,0x3E,0x55,0x79,0x98,0x8B,0x5C,
375 0xCF,0x05,0x38,0x69,0xF9,0x99,0x07,0x42,0x6D,0x99,0x1B,0x5E,0x89,0xBD,0xB6,0x4B,
376 0x52,0x0F,0xDD,0xF9,0x67,0x53,0xDF,0xE2,0x25,0xBC,0x6C,0x72,0x19,0x6A,0x28,0xCE,
377 0x6A,0xB4,0x22,0x93,0x20,0xDE,0xB6,0xF5,0x83,0x6A,0xC6,0x82,0x36,0x2B,0x02,0x03,
378 0x01,0x00,0x01,0xA3,0x4B,0x30,0x49,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
379 0xFF,0x04,0x04,0x03,0x02,0x05,0x20,0x30,0x16,0x06,0x03,0x55,0x1D,0x25,0x01,0x01,
380 0xFF,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x04,0x30,
381 0x1F,0x06,0x03,0x55,0x1D,0x11,0x04,0x18,0x30,0x16,0x81,0x14,0x73,0x6D,0x69,0x6D,
382 0x65,0x2D,0x74,0x65,0x73,0x74,0x40,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,
383 0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,
384 0x82,0x01,0x01,0x00,0x7D,0xB4,0x4B,0x4B,0xE1,0xB3,0x29,0x22,0x72,0x7E,0x66,0xEA,
385 0x78,0x51,0xBB,0x38,0xA0,0x44,0x6E,0xAE,0xB7,0xFE,0x43,0x24,0x78,0xAE,0x93,0x3B,
386 0xF0,0x2B,0xAB,0x31,0x61,0x9F,0x6E,0x1F,0x89,0x0F,0x2C,0xD0,0xC4,0x29,0xE0,0x1C,
387 0x4C,0x7B,0x96,0x82,0x0D,0x29,0x08,0x1F,0xDE,0x35,0xA2,0x12,0x0D,0xB4,0xA0,0x5D,
388 0xE4,0xE8,0x38,0xC3,0x5C,0x99,0xFD,0x2E,0xE9,0x3B,0xC7,0xFC,0x67,0x3D,0xBD,0x1E,
389 0x46,0x3A,0xDD,0xFB,0x24,0xF0,0x83,0x77,0x4F,0xA0,0x63,0x40,0x58,0x28,0x3C,0x32,
390 0x3B,0xEB,0x8B,0x20,0x29,0xFD,0x22,0x4A,0xEC,0x3C,0x78,0xE2,0xD5,0xD3,0x54,0x35,
391 0x8F,0x4D,0x48,0x61,0x2E,0xB6,0xC1,0xE5,0x3A,0x95,0xCD,0xBF,0x73,0xA2,0x1A,0x15,
392 0xC3,0x24,0x0F,0xDB,0x86,0x08,0x55,0x01,0xBC,0x8C,0x4F,0x83,0x4E,0x90,0x55,0x84,
393 0xF8,0x82,0xB1,0x1E,0x9F,0x70,0xD3,0xE8,0xE8,0xD3,0xDB,0x97,0xE0,0x66,0xAA,0x54,
394 0x58,0x32,0x16,0x56,0xA3,0xF3,0x9B,0xCE,0xC4,0xA3,0x65,0x66,0x71,0xFD,0x20,0x87,
395 0x3A,0x34,0x74,0xAB,0x6B,0x26,0xB8,0x18,0x8A,0x77,0xFF,0x77,0x21,0x6A,0xF0,0x38,
396 0x12,0x74,0x45,0x1F,0x67,0x3D,0xBD,0xDF,0xBF,0x32,0x82,0x8E,0x4D,0xC5,0x3D,0x59,
397 0x07,0xCD,0x1A,0x05,0xB6,0x96,0xD7,0x95,0xDB,0x44,0x81,0x59,0xD7,0x2A,0x88,0x0D,
398 0x3C,0xD8,0xD5,0x2B,0x92,0xA8,0xC1,0x8D,0xDE,0x60,0x6F,0x98,0xE4,0x3C,0xB8,0xEC,
399 0x52,0x2A,0x56,0x6E,0xF1,0x76,0x56,0x64,0x3D,0xD9,0x09,0xB9,0x4B,0x73,0xEF,0x11,
400 0x78,0xFB,0xA6,0x9A,
401 };
402
403 /* Test identity for S/MIME policy (sign only, no encrypt)
404 */
405 unsigned char Test_smime_signonly_p12[2761] = {
406 0x30,0x82,0x0a,0xc5,0x02,0x01,0x03,0x30,0x82,0x0a,0x8c,0x06,0x09,0x2a,0x86,0x48,
407 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0a,0x7d,0x04,0x82,0x0a,0x79,0x30,0x82,
408 0x0a,0x75,0x30,0x82,0x04,0xef,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,
409 0x06,0xa0,0x82,0x04,0xe0,0x30,0x82,0x04,0xdc,0x02,0x01,0x00,0x30,0x82,0x04,0xd5,
410 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x1c,0x06,0x0a,0x2a,
411 0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x0e,0x04,0x08,0x03,0x00,0x56,
412 0xda,0x33,0x28,0xb6,0xbc,0x02,0x02,0x08,0x00,0x80,0x82,0x04,0xa8,0x36,0xa9,0x2d,
413 0xab,0xcc,0x17,0x76,0x6e,0x1c,0xf2,0x82,0xb1,0xc1,0xac,0x19,0xbe,0xb3,0x71,0x4f,
414 0x1a,0xe6,0x0f,0x2d,0x7e,0xd4,0x66,0x0a,0x70,0x85,0x41,0xa5,0x92,0x06,0x02,0x71,
415 0x0f,0x7a,0xed,0xef,0x52,0x96,0xd2,0x67,0xf4,0xa8,0x5b,0xde,0x6e,0xc6,0xdc,0xc6,
416 0xe8,0x6e,0x86,0x11,0x94,0x60,0x0d,0xa1,0x24,0x57,0x1f,0x51,0xd8,0x7d,0x28,0xf9,
417 0x10,0xcb,0x68,0x1b,0x32,0xe4,0xa3,0x60,0x7c,0xb2,0x2b,0x33,0x4e,0x23,0xec,0x60,
418 0x4c,0xe0,0x1a,0x39,0x03,0x60,0xb7,0x09,0x4d,0xb7,0x8c,0x94,0x91,0x44,0xa7,0xc7,
419 0x3b,0xd7,0xc5,0xc5,0x0f,0x4a,0x54,0xe5,0xee,0x41,0xd5,0x32,0xf2,0xfc,0x7a,0x4d,
420 0x68,0x5d,0xfc,0xe9,0xab,0xa0,0x74,0xb9,0x6f,0x68,0xc4,0x68,0xa1,0x91,0x5d,0x74,
421 0x2b,0x06,0xfc,0xa7,0x93,0x2c,0xc3,0x8e,0xaf,0x12,0x84,0x09,0x1f,0xa8,0xd7,0xb3,
422 0xf2,0x13,0x33,0xdf,0xd2,0xa5,0x34,0xa5,0x08,0x73,0xea,0x8f,0xc3,0x88,0xd4,0xa1,
423 0xce,0xa9,0x56,0xc4,0x4f,0xc9,0x48,0xfb,0x84,0x26,0x16,0xc8,0x1a,0x15,0x6d,0x10,
424 0x8e,0x4e,0x85,0xfc,0x8b,0xb7,0xfc,0x69,0x6a,0x79,0xc0,0xff,0xed,0xfd,0x7b,0x0b,
425 0x7f,0x5b,0x8d,0x89,0x4e,0xb6,0x25,0x0e,0x04,0x42,0xdb,0x15,0x7b,0xbc,0x7b,0x75,
426 0x91,0x12,0x7c,0x0f,0x22,0xfd,0xd4,0x4d,0x3c,0x9c,0x6c,0x10,0x40,0x9e,0x3e,0x0b,
427 0xfd,0x2e,0x2d,0x23,0x27,0x96,0x86,0x85,0x44,0xdd,0xc4,0x44,0xbf,0x74,0x09,0x2f,
428 0x90,0x48,0x3d,0x8a,0x05,0xbe,0x44,0xe5,0x75,0x1f,0x4e,0xbc,0x91,0xfd,0xf5,0x1a,
429 0xde,0xd4,0x99,0xf4,0xbe,0x2f,0x28,0xbf,0x47,0x49,0x90,0xb5,0xea,0xd6,0x48,0xcb,
430 0x7b,0xde,0xea,0x3d,0x07,0x8d,0xf4,0x7c,0xd7,0x4d,0xcb,0xc1,0xcb,0xa3,0x30,0x2f,
431 0x7c,0x59,0x09,0xad,0xb3,0x27,0x66,0x2a,0x87,0x51,0xd7,0x7b,0xbb,0xb1,0x6d,0x4e,
432 0x0e,0x1a,0x6a,0x7a,0xf8,0x31,0x99,0xa8,0x1c,0x06,0x1a,0x4e,0x83,0xa8,0xac,0xaf,
433 0x72,0xdb,0x89,0x1b,0xe1,0x9d,0x52,0x22,0x94,0xaf,0x6a,0xe0,0x5c,0x60,0xd5,0xf2,
434 0x6a,0xde,0x1f,0x51,0xb0,0x19,0x13,0xff,0xb9,0xfe,0x15,0xeb,0x4a,0x5c,0x44,0xe6,
435 0xbd,0x3d,0xbd,0xdc,0xb2,0xa8,0x96,0xa2,0x05,0x7e,0xdc,0x39,0x15,0x7a,0xc9,0xdc,
436 0xb3,0x2b,0xa2,0x1c,0xe1,0x78,0xfb,0x5b,0x12,0x35,0xc2,0x05,0xed,0x59,0xa2,0xf1,
437 0x8d,0x5b,0xe2,0xf8,0x95,0xc7,0xdd,0x20,0xf9,0xcc,0xfd,0x43,0xbe,0x03,0x0f,0xdb,
438 0xa1,0x21,0x7b,0x86,0x0e,0x0b,0x26,0xbd,0x38,0x10,0x62,0xbc,0x5c,0x43,0x48,0x6f,
439 0xbc,0x6c,0x68,0x83,0xd4,0x54,0x5b,0x80,0x25,0x13,0x69,0x18,0xce,0x8e,0xe9,0x3f,
440 0xfb,0x81,0x51,0x92,0x19,0x3f,0x4b,0x41,0x53,0x39,0x3e,0xa2,0xef,0x90,0x59,0x5c,
441 0x30,0x22,0x36,0xed,0x78,0x78,0xc5,0x70,0x9c,0x8b,0x96,0x8d,0xe8,0x7a,0x9b,0x27,
442 0xdc,0x9b,0x4f,0x2b,0x30,0x86,0x27,0x95,0x70,0x8f,0xc0,0xd5,0xd4,0x79,0x9f,0x0f,
443 0x38,0x49,0x1d,0xe9,0x76,0xcf,0x6c,0x34,0x06,0xc0,0xfa,0xa0,0xab,0x41,0x1c,0x26,
444 0x04,0x18,0x0f,0xa8,0x45,0xf5,0xdc,0x82,0x5d,0x8a,0xe6,0x2b,0x84,0xe9,0xaa,0xa2,
445 0xbd,0xf4,0xc6,0x94,0xa6,0xbb,0x6f,0x35,0x3c,0x5f,0x9a,0x45,0xd3,0x3e,0x6b,0x75,
446 0x54,0x10,0x5a,0x6f,0x0c,0x26,0xe7,0xb1,0x92,0x6c,0x93,0xf1,0xce,0x02,0x97,0xbe,
447 0xf8,0x76,0xbc,0x9b,0xff,0x09,0xe2,0x8a,0x62,0xdc,0x19,0xfa,0x33,0x94,0x07,0x4b,
448 0x7d,0x62,0xe3,0xca,0xc6,0x1e,0xc4,0x18,0xd7,0xa8,0xbb,0x79,0xd1,0x4e,0x2e,0x37,
449 0xa4,0x02,0x06,0x80,0xa4,0xed,0xbf,0x3e,0x8b,0xc7,0xcd,0xf2,0xa5,0x8f,0x68,0x1e,
450 0xb2,0x72,0xc2,0xa2,0xa7,0x8d,0x03,0x51,0x0f,0xe2,0x7a,0x04,0x03,0x83,0x2f,0x71,
451 0x16,0x85,0x7e,0xf3,0x29,0xc7,0x31,0x27,0x24,0xae,0x8b,0x08,0xe7,0x6b,0x7d,0x5f,
452 0x27,0xdd,0xdb,0x28,0x63,0x65,0xbb,0x2a,0x6e,0x63,0xc4,0xa4,0x90,0x36,0x8e,0xc4,
453 0x8b,0x55,0x6f,0x99,0x4f,0xf3,0x63,0xef,0xc7,0x3a,0xd5,0x55,0xf3,0x98,0xaa,0x9c,
454 0x20,0x9d,0x9b,0x07,0x44,0x92,0x27,0x2c,0xc5,0x22,0x78,0x85,0x66,0x71,0xd5,0x0f,
455 0xea,0xa7,0xdc,0x0c,0xad,0x07,0x2a,0xa5,0x34,0xca,0xbc,0x8e,0xff,0xfd,0x0b,0xb0,
456 0x9d,0x21,0x16,0x9d,0xfa,0x21,0xaf,0xec,0x25,0x6a,0xd7,0x7d,0xff,0xe6,0x73,0xe3,
457 0x6c,0x4e,0x9c,0xe0,0xeb,0x0c,0x56,0x32,0xa9,0xbb,0x48,0xe5,0xa7,0x4b,0x59,0x1d,
458 0x70,0x31,0xf2,0x79,0x88,0x50,0xc4,0x59,0x01,0x3c,0xc2,0x61,0xbe,0xe7,0xbc,0xc0,
459 0x6f,0xb4,0x27,0x90,0xcd,0x4f,0x44,0x60,0x9f,0x02,0x5a,0x68,0x81,0xb6,0x6f,0x78,
460 0x10,0xd3,0x3e,0xb3,0xb4,0xc5,0x6f,0xa6,0x3e,0x77,0x30,0x29,0xd7,0xa7,0xda,0x5f,
461 0xb4,0x3e,0x3f,0xf9,0xb3,0x04,0xd8,0xe5,0x75,0xc5,0x1e,0xcf,0xa6,0x85,0x4c,0x57,
462 0xf6,0xbb,0x8f,0xda,0x80,0x02,0x4b,0x79,0x0f,0x94,0xed,0x98,0xdb,0x64,0x8d,0x8f,
463 0x8e,0x90,0x5b,0x31,0x80,0x1b,0x50,0x8b,0x99,0x7b,0x23,0x94,0xf2,0x1e,0x8e,0xe6,
464 0xce,0x7f,0x2f,0x16,0x64,0x7f,0xdb,0x16,0x08,0x97,0x78,0x5c,0x4d,0xef,0x9c,0x63,
465 0x0f,0x37,0x14,0x58,0x68,0x57,0x29,0x42,0xd3,0x4d,0x97,0x62,0xe8,0x08,0xe4,0x60,
466 0x87,0x07,0x73,0x11,0x21,0x5e,0x8c,0x97,0x78,0xdb,0x2f,0x81,0xb3,0xa0,0xfd,0x17,
467 0x0b,0xf0,0x29,0x88,0x1a,0x39,0xec,0x0c,0xfb,0x30,0x0d,0x0a,0x9a,0x60,0xe2,0xaf,
468 0xf9,0xb3,0x9c,0xdd,0xa6,0x2e,0x7c,0x90,0xf7,0x31,0x3c,0x35,0xe8,0x2f,0xdd,0x54,
469 0xdf,0x45,0x54,0xcf,0xdd,0xfc,0xf6,0x36,0x3f,0x36,0x8a,0x23,0x60,0xd0,0x4b,0xe2,
470 0x0b,0xb5,0x90,0xc4,0xbe,0xaf,0xa1,0xd6,0xc2,0x69,0x0a,0x5b,0x74,0xae,0xa5,0xb3,
471 0x12,0xaf,0x06,0x98,0xfe,0xc3,0x52,0xbb,0xf0,0xde,0x67,0xd4,0x8d,0x2a,0xf4,0x35,
472 0x71,0xaf,0x5e,0x24,0xc4,0x2a,0x48,0xa6,0x42,0x32,0x10,0xb0,0x09,0x74,0x83,0x9e,
473 0x3c,0x50,0x15,0x74,0xeb,0x2e,0x29,0x64,0x3e,0xe5,0x6e,0x13,0xc0,0x5b,0x9b,0x5b,
474 0x1f,0x8f,0xe5,0x49,0x25,0x36,0x57,0x90,0x81,0xce,0x27,0xf4,0x8d,0x42,0x5d,0x04,
475 0x2c,0x44,0x7a,0xeb,0xe0,0x10,0x4e,0xba,0x21,0xf3,0x1d,0xdf,0xb0,0xe4,0x56,0xf9,
476 0x5a,0xbe,0xfe,0x1a,0x6d,0xeb,0x2d,0xe2,0x93,0x5f,0xa1,0x74,0x86,0x0c,0x64,0x68,
477 0xf4,0x67,0xf3,0xe0,0xfa,0xe6,0x9d,0x6a,0xfe,0xb6,0x5f,0x58,0x2d,0xa7,0x77,0x07,
478 0x58,0xc8,0x79,0x51,0xa5,0x8e,0xbd,0x4c,0x61,0x80,0x9d,0x91,0xda,0x32,0xee,0x09,
479 0x02,0xca,0x14,0xf8,0xfa,0x08,0xf3,0x4a,0xf5,0x6a,0x50,0xcd,0x98,0x21,0xbd,0xb4,
480 0x5e,0x4c,0x20,0x8f,0x0a,0x94,0xd0,0x6c,0x96,0xf1,0xa2,0xff,0xf6,0x1f,0x15,0xd5,
481 0x1d,0x64,0x92,0x82,0xaf,0x01,0xca,0xa0,0x38,0xe9,0x80,0xea,0xe9,0xb3,0xdf,0xed,
482 0xa8,0x03,0x31,0x5e,0x05,0x12,0xcd,0x29,0x33,0x59,0xf9,0xf2,0xbc,0x7f,0x05,0x86,
483 0x9e,0x96,0xc4,0x52,0x2d,0x1f,0x1e,0x29,0x05,0x68,0xde,0xf1,0x3c,0x2d,0x65,0x97,
484 0x7c,0xde,0x28,0x88,0xab,0xd3,0x12,0x5e,0x3d,0x15,0x45,0xc3,0x05,0x47,0x13,0x03,
485 0x65,0xad,0x49,0x5f,0x8a,0x15,0xf5,0x27,0xc1,0x13,0xa5,0x16,0x85,0x13,0x11,0xf6,
486 0x71,0x03,0x2c,0xaf,0xce,0xc4,0x36,0x17,0x0b,0xfd,0x4a,0x4c,0xce,0x9e,0x0d,0xcc,
487 0xa5,0xa3,0x30,0xce,0x61,0x30,0x82,0x05,0x7e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
488 0x0d,0x01,0x07,0x01,0xa0,0x82,0x05,0x6f,0x04,0x82,0x05,0x6b,0x30,0x82,0x05,0x67,
489 0x30,0x82,0x05,0x63,0x06,0x0b,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,
490 0x02,0xa0,0x82,0x04,0xee,0x30,0x82,0x04,0xea,0x30,0x1c,0x06,0x0a,0x2a,0x86,0x48,
491 0x86,0xf7,0x0d,0x01,0x0c,0x01,0x03,0x30,0x0e,0x04,0x08,0xb1,0xca,0xab,0x81,0x75,
492 0x32,0xf4,0x2c,0x02,0x02,0x08,0x00,0x04,0x82,0x04,0xc8,0xc8,0xe4,0x07,0x32,0x15,
493 0x32,0xb1,0xce,0xca,0xa4,0x03,0x84,0x91,0xbc,0x74,0x45,0x63,0x46,0xa8,0x20,0xcf,
494 0xa2,0x2d,0x0e,0xfb,0xf7,0xfa,0x3d,0xad,0x72,0xa4,0x97,0xc9,0x14,0xb9,0x55,0x00,
495 0x5e,0xb6,0x17,0xf9,0xba,0xe4,0xf4,0x4b,0x36,0x31,0xbb,0xfc,0x4a,0xb3,0xfe,0xd7,
496 0xf5,0xd0,0xe8,0x63,0x43,0x6b,0x7e,0xfe,0xcc,0xa8,0x2f,0x8a,0x8a,0xf3,0xfb,0x23,
497 0x0c,0xed,0x03,0x20,0x66,0xe2,0x90,0x9b,0x68,0x71,0xfb,0x44,0x68,0xe5,0x87,0x97,
498 0x0a,0x97,0x63,0x53,0x3c,0x07,0x86,0x63,0xb2,0x0f,0x8e,0xe8,0xb5,0x0a,0x0c,0xe2,
499 0x12,0x6d,0x33,0xa1,0xa5,0xc5,0xc4,0xab,0xf7,0x23,0x35,0x53,0x69,0xc1,0x37,0x28,
500 0x86,0x42,0xa1,0x9c,0xe4,0xf5,0x2e,0x8c,0x92,0x1a,0xeb,0x67,0x10,0xcb,0x24,0xb5,
501 0xd6,0x75,0x33,0x7a,0x5f,0x20,0x8f,0x1e,0x13,0x4c,0x4c,0xa1,0x53,0x87,0x8c,0xad,
502 0x04,0x28,0xe0,0x21,0x65,0xf0,0x1b,0x62,0x15,0x95,0x36,0xd1,0x21,0xe1,0x50,0x0d,
503 0xe4,0xed,0x07,0x8d,0x37,0xd3,0x06,0x2d,0x88,0x46,0x0f,0x54,0x16,0x19,0xac,0xc7,
504 0x0b,0xcf,0x83,0xe9,0x49,0xbc,0x9e,0x7f,0x38,0xed,0xe4,0xf1,0x84,0x6a,0x0e,0xd1,
505 0x92,0x39,0x61,0x36,0xa3,0x12,0xfc,0x31,0x4c,0xde,0x9d,0xcf,0xa0,0x90,0xd0,0x17,
506 0x29,0x51,0x93,0x04,0xb1,0xe9,0xab,0x5e,0x5d,0x9e,0x2f,0x99,0xe9,0x53,0x95,0x27,
507 0x39,0x5a,0x48,0x64,0x56,0x7b,0x97,0x9e,0x5d,0xf0,0xc9,0xd5,0x6b,0x57,0x0e,0xdc,
508 0x69,0x7f,0x2d,0x6e,0xd7,0x3a,0xd8,0x31,0xcb,0x14,0xf4,0x3b,0x33,0xaf,0x62,0x95,
509 0xbe,0x6b,0xe9,0xd7,0x2a,0x17,0x6c,0x9d,0x65,0x6c,0x2a,0xf5,0x38,0x39,0x95,0x8c,
510 0xc6,0x97,0xc9,0xa1,0xe8,0x07,0x09,0x62,0x71,0x92,0xc2,0x4f,0xb1,0x25,0x83,0x90,
511 0x44,0x54,0xcd,0x5c,0x3d,0x7b,0x0f,0xf1,0xdf,0x00,0xe2,0x4a,0x0e,0xd4,0xfe,0xa8,
512 0x3e,0x81,0x4e,0x6c,0x92,0x49,0xa0,0x49,0xc4,0x3a,0x80,0x78,0x1d,0xb2,0x43,0xbd,
513 0x21,0x5a,0xe0,0xbd,0x99,0xe0,0x77,0xd1,0xe6,0x2d,0x73,0xd4,0x4b,0xa9,0x07,0xcc,
514 0xbd,0x12,0xa2,0x06,0x08,0x60,0xbd,0x99,0xfd,0x9f,0xcc,0x23,0x6f,0xd2,0xd0,0xdf,
515 0xbe,0x63,0xef,0xe9,0x15,0x24,0x54,0x55,0x73,0x85,0x9e,0x26,0x62,0xd8,0xc1,0x14,
516 0xce,0xcc,0x3b,0xf6,0x87,0x68,0xfa,0x3d,0x6e,0xb1,0x1c,0x5e,0x4e,0x05,0xe4,0xbc,
517 0x95,0x1b,0xb4,0xd5,0xa1,0xfb,0xe2,0x25,0x48,0xe9,0x63,0x36,0xdf,0x33,0x8e,0xed,
518 0x1d,0xdf,0x63,0x1a,0xfd,0xb6,0xc9,0x09,0x3a,0xc2,0x9f,0x1d,0xd4,0x45,0x00,0x2a,
519 0x86,0x09,0x9c,0x30,0x4e,0xc0,0x81,0x9c,0x30,0x14,0x6b,0x4c,0x52,0xfd,0xca,0x36,
520 0xef,0x99,0x2e,0xd1,0x86,0xc0,0xdf,0x9d,0x6a,0xb5,0xfa,0xa3,0x12,0xe0,0x5f,0x73,
521 0xb4,0xfd,0xd7,0x59,0x23,0x6d,0xa8,0x77,0x8f,0x65,0x4a,0x65,0x46,0x5e,0x56,0xe0,
522 0x23,0xbb,0xc5,0x38,0xff,0xf0,0x4a,0x2e,0xab,0x20,0x75,0x02,0xc5,0x85,0x7e,0x6b,
523 0x3f,0xa4,0x00,0xf5,0x39,0x88,0xd1,0x9c,0xc9,0xe9,0x77,0xeb,0x8d,0xce,0x2e,0x74,
524 0x5c,0xb9,0x6c,0xb0,0x6d,0x9e,0x5f,0x7b,0x93,0x7b,0x22,0x0e,0xb3,0x55,0x65,0xca,
525 0x64,0xec,0xc0,0xa5,0xff,0x19,0x0a,0x2d,0x1c,0xc9,0xd3,0xe3,0xb6,0x18,0xe3,0x8c,
526 0x83,0xd8,0x43,0x01,0xf8,0x6e,0x64,0x07,0xb9,0xac,0x20,0x29,0xeb,0x36,0xf5,0x04,
527 0xd8,0x41,0xeb,0x8d,0x23,0x39,0x21,0x83,0xb6,0x82,0xbd,0x18,0xac,0xc6,0xb7,0x5b,
528 0xf7,0x4d,0x80,0x7a,0xf6,0xdc,0x40,0x04,0x9c,0xec,0xb2,0xea,0xd6,0xf1,0x5d,0xa4,
529 0x62,0x43,0x05,0x0b,0xba,0x29,0x36,0xeb,0xbd,0x23,0xb6,0x02,0xf6,0x62,0x4e,0xf3,
530 0xff,0xee,0x3d,0x92,0xbe,0x65,0xc0,0x4a,0xb1,0x60,0x60,0x46,0x23,0x85,0x67,0x71,
531 0xe4,0x25,0x6b,0x58,0xdc,0x91,0x4c,0x05,0x54,0xfa,0x4b,0xa5,0x60,0x82,0x3e,0xa2,
532 0x4f,0x3e,0xc7,0xe5,0xf0,0x2b,0xa6,0x9d,0x55,0xdc,0x98,0x46,0xd7,0xec,0x3e,0x47,
533 0x5b,0x4c,0x02,0x46,0x9c,0x2d,0x25,0x6d,0x55,0x25,0xfc,0x67,0xc2,0xe9,0xbf,0xa1,
534 0xb0,0x5b,0x97,0xf8,0x4f,0xae,0xdf,0xab,0x50,0xa0,0x0b,0x5b,0xc8,0x78,0xcc,0xcd,
535 0x50,0x55,0xc6,0x46,0x21,0x01,0x7e,0xac,0x38,0xe2,0x10,0x34,0x0b,0x22,0x64,0xa7,
536 0xa5,0xe4,0x7f,0x60,0x51,0x75,0xdf,0x32,0x87,0xd4,0xa6,0x06,0x4f,0x8c,0x60,0x15,
537 0xd0,0x1f,0xc1,0xbb,0xa4,0xca,0x4a,0xac,0x80,0xf1,0x7f,0x3a,0xfc,0x4a,0xe7,0x4e,
538 0xb8,0xc2,0xdb,0x84,0xd8,0x5c,0xeb,0x44,0x23,0xec,0x9e,0x92,0x72,0xb7,0x45,0x02,
539 0xee,0x52,0x08,0x47,0xb6,0x09,0x5d,0xdc,0xe5,0x26,0xae,0x61,0x42,0x77,0x13,0x85,
540 0xa2,0x4f,0xf0,0xb0,0x46,0x88,0x2a,0x3c,0x09,0x98,0x89,0xe3,0xf1,0x69,0x89,0x0a,
541 0x76,0xd9,0x8e,0x7e,0x0c,0xd7,0xcc,0x16,0xda,0xfd,0xfb,0x96,0x2b,0xd7,0xe2,0x8d,
542 0x54,0x3f,0x75,0x2f,0x66,0x6b,0x72,0x8f,0xbd,0x5c,0x3c,0x05,0xa7,0xe4,0x11,0x06,
543 0xcf,0x4a,0xd6,0x32,0x95,0x42,0x71,0xc6,0x2b,0xf9,0x8b,0xe6,0xda,0x0c,0x37,0xa8,
544 0xed,0x7b,0x71,0x9a,0xea,0x8e,0xa1,0xbd,0x27,0x8f,0x45,0x00,0x48,0x40,0xba,0xf4,
545 0x41,0x0e,0xb6,0x98,0x88,0xed,0xc7,0x3d,0xbd,0x59,0x52,0xc4,0xeb,0xbc,0xb8,0x0b,
546 0x22,0x5e,0x68,0x79,0xc9,0x71,0x3d,0xd7,0x31,0x4c,0x55,0x40,0xcd,0x1f,0x41,0x0c,
547 0xd7,0xb0,0x02,0x47,0xb0,0x9f,0xfa,0xb2,0x60,0xd4,0x3c,0x64,0xe8,0xc5,0xae,0xe8,
548 0x12,0xad,0x84,0xc3,0xe1,0xfd,0x1e,0x20,0x6f,0x20,0x2e,0xbe,0xa9,0xd4,0x30,0xb6,
549 0x6c,0xa5,0xf0,0x03,0x75,0xae,0x1b,0xb1,0x15,0x36,0x8d,0xba,0x0f,0x1e,0xb7,0x74,
550 0x8b,0xa4,0x41,0xfd,0x13,0x7a,0xa9,0x16,0x22,0x54,0xe4,0x60,0x38,0x52,0xb6,0x60,
551 0x8b,0x7f,0x7a,0xb9,0x2a,0xb0,0x28,0x63,0x71,0xeb,0x29,0x52,0xab,0x66,0x70,0x66,
552 0x72,0x12,0xe9,0x4d,0xf4,0x01,0xba,0x88,0xb6,0x15,0xe1,0xb9,0x67,0x10,0x0a,0x59,
553 0xc8,0x12,0x1b,0x81,0x6a,0x4c,0x79,0x0f,0x94,0xd7,0xa7,0xa8,0x4c,0x25,0xf2,0xd3,
554 0x4d,0x23,0x6c,0x9d,0x65,0x81,0x75,0x72,0xd9,0xca,0xa5,0x32,0xa5,0x9a,0xcc,0xef,
555 0xfe,0xb2,0x30,0x2f,0x6c,0x17,0x53,0xac,0x9d,0xc6,0xd5,0x6a,0x85,0x35,0xfa,0x17,
556 0xe4,0xfa,0xb8,0x93,0x18,0xc6,0x82,0x42,0xa4,0xaf,0x72,0x7d,0xd4,0xbd,0xf2,0xe3,
557 0x7b,0x6e,0x56,0x2d,0x25,0xeb,0xeb,0x53,0x4e,0x34,0xaa,0x86,0x5d,0xcb,0xe1,0xd6,
558 0x22,0x4d,0x74,0xee,0x37,0xbd,0x8d,0x43,0xf8,0x3b,0xdb,0xf6,0x9a,0xef,0xe9,0x7f,
559 0x3d,0x7f,0x74,0xe6,0x25,0xbb,0xf9,0x4a,0xf8,0x20,0x07,0x94,0x30,0x43,0x48,0xab,
560 0x0e,0x1d,0x97,0xd6,0x01,0xa1,0x5b,0x9e,0x92,0xa2,0xeb,0xbe,0x22,0xe8,0x2f,0xb0,
561 0x31,0x24,0xb4,0xb5,0x2b,0x73,0xf2,0xdd,0x29,0x5b,0xfd,0x1b,0x18,0x3e,0x3a,0xe6,
562 0xa3,0x4b,0x0b,0x19,0xe3,0x4c,0x83,0x8b,0xe3,0x5f,0x94,0xd7,0x5a,0x33,0xb3,0x3d,
563 0x3c,0x3f,0xf2,0x16,0x39,0x84,0x48,0x6b,0xc4,0x21,0x87,0x68,0xa7,0xe7,0x94,0xb4,
564 0x4f,0x36,0x97,0x28,0x9a,0xbd,0xd4,0x5c,0xf5,0x89,0x5a,0x46,0xf4,0x4b,0x1f,0xe9,
565 0x5c,0x48,0xae,0x51,0xe5,0x6f,0xb3,0xea,0xe2,0x6e,0x4e,0x72,0x2d,0x87,0x8c,0x5d,
566 0x07,0x3e,0xfb,0x1c,0x95,0x88,0x9e,0xde,0xec,0xc2,0xd1,0x7c,0xef,0x6d,0x4e,0x19,
567 0x0c,0xbc,0x6f,0x9f,0xd1,0xa0,0x8e,0x71,0xc8,0x13,0xe6,0xc9,0x21,0xcb,0x31,0x77,
568 0x13,0x38,0x14,0xe9,0x25,0xea,0x5c,0x35,0x48,0x06,0x2c,0x4d,0xbe,0x53,0x76,0x51,
569 0x1d,0x7a,0x88,0x31,0x62,0x30,0x3b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
570 0x09,0x14,0x31,0x2e,0x1e,0x2c,0x00,0x54,0x00,0x65,0x00,0x73,0x00,0x74,0x00,0x2d,
571 0x00,0x53,0x00,0x69,0x00,0x67,0x00,0x6e,0x00,0x4f,0x00,0x6e,0x00,0x6c,0x00,0x79,
572 0x00,0x20,0x00,0x28,0x00,0x53,0x00,0x2f,0x00,0x4d,0x00,0x49,0x00,0x4d,0x00,0x45,
573 0x00,0x29,0x30,0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,
574 0x16,0x04,0x14,0x6f,0x7c,0x20,0x36,0xbe,0x29,0x2b,0xca,0x1a,0xbf,0x51,0xb7,0x15,
575 0x8a,0xf9,0x7c,0x2b,0x4e,0x04,0xe8,0x30,0x30,0x30,0x21,0x30,0x09,0x06,0x05,0x2b,
576 0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14,0x0e,0xb5,0xcf,0xf5,0x4e,0x2b,0x2c,0x5d,
577 0x2e,0x43,0xc9,0x60,0xf2,0x16,0x0f,0xd2,0xe6,0x50,0x93,0x0b,0x04,0x08,0xf0,0x18,
578 0xb1,0xdb,0x61,0x97,0x53,0xcb,0x02,0x01,0x01
579 };
580
581 /* Test identity (PKCS12 data)
582 */
583 unsigned char Test_p12[2721] = {
584 0x30,0x82,0x0a,0x9d,0x02,0x01,0x03,0x30,0x82,0x0a,0x64,0x06,0x09,0x2a,0x86,0x48,
585 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0a,0x55,0x04,0x82,0x0a,0x51,0x30,0x82,
586 0x0a,0x4d,0x30,0x82,0x04,0xd7,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,
587 0x06,0xa0,0x82,0x04,0xc8,0x30,0x82,0x04,0xc4,0x02,0x01,0x00,0x30,0x82,0x04,0xbd,
588 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x1c,0x06,0x0a,0x2a,
589 0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x0e,0x04,0x08,0xba,0x25,0x0b,
590 0x36,0xab,0xc2,0xe7,0x34,0x02,0x02,0x08,0x00,0x80,0x82,0x04,0x90,0xe2,0x74,0x80,
591 0xf1,0xf9,0xff,0xb5,0x9a,0xa4,0xe2,0x43,0x70,0x41,0xa1,0x90,0x19,0xb2,0xd5,0x8e,
592 0x00,0x4b,0xfc,0x07,0xd6,0x72,0x99,0x9c,0x89,0xa8,0x0c,0x97,0x4a,0x9c,0x10,0x30,
593 0x11,0x80,0xc1,0x42,0xda,0x56,0xdd,0x1b,0xfa,0x9e,0x5f,0x85,0x72,0x1d,0xde,0xdf,
594 0x78,0x8f,0xd4,0x69,0xf0,0x39,0xfb,0xf1,0xf4,0x96,0xc1,0x2d,0x97,0x20,0x98,0xe2,
595 0x38,0xd0,0xe1,0xda,0x01,0x59,0x64,0x71,0xd6,0xd9,0xa2,0x46,0x38,0x87,0x54,0x4c,
596 0x4d,0x3f,0x8a,0x9b,0x75,0xf4,0x98,0xec,0xf1,0xe4,0x01,0x60,0x8d,0x04,0x54,0x28,
597 0x4c,0xbb,0x90,0x08,0x98,0xb1,0x6b,0x61,0xe3,0x03,0xcd,0x00,0x19,0x87,0xa2,0xc2,
598 0xb5,0x7b,0x57,0xd4,0x22,0x77,0xd1,0x68,0x9a,0xfe,0xe3,0x43,0xef,0x2b,0xb6,0x11,
599 0x7c,0x63,0x9c,0x28,0xab,0x86,0xdf,0x1b,0x95,0x58,0x54,0xa5,0x3d,0x18,0xb0,0xad,
600 0x20,0x76,0x92,0xf5,0xef,0x20,0x8a,0x0c,0x21,0xdb,0x83,0x15,0x1e,0xa5,0x6f,0xeb,
601 0xd3,0xc8,0x40,0x14,0x7f,0x69,0x46,0x73,0x20,0x60,0x2b,0x3e,0x27,0xd7,0xb9,0x33,
602 0x8c,0xe6,0x43,0xc8,0xf6,0xa5,0x53,0xa7,0x36,0x03,0x3d,0xa9,0xdd,0x85,0x59,0xde,
603 0x70,0xc2,0x65,0x38,0x06,0x04,0x00,0x01,0xcc,0xed,0xdf,0x1f,0xab,0x83,0xed,0xeb,
604 0xc0,0x3d,0x33,0x4e,0x99,0x22,0xcc,0x63,0xc7,0x14,0x9c,0x50,0x60,0x38,0xc3,0xa5,
605 0xe2,0xfe,0x78,0x04,0x01,0x0f,0x1d,0xde,0xe0,0x3e,0x86,0x05,0x02,0xfc,0x3c,0x7f,
606 0x38,0xf7,0xb0,0xd0,0xbb,0x0c,0xe1,0x1b,0xdc,0x6e,0xb0,0x12,0x7a,0xae,0x13,0x5d,
607 0x80,0xd7,0x0e,0xb2,0xe8,0x5d,0x2a,0xbf,0x2e,0x67,0xc3,0xd8,0x8d,0xa1,0x9f,0x2c,
608 0xbb,0xc4,0x33,0xca,0xf4,0x43,0x89,0xbd,0x4e,0x19,0xa5,0x71,0x1c,0x5f,0x6b,0x4d,
609 0xd4,0xf7,0xdd,0xd3,0xfd,0x13,0xdc,0xde,0x76,0x2c,0x38,0x8e,0xef,0xb2,0x00,0x9c,
610 0xfd,0xa5,0x52,0xa0,0xec,0xa3,0xfe,0xcc,0x80,0xee,0x8d,0xed,0x25,0xf9,0xa8,0x30,
611 0x99,0x04,0x6f,0x61,0x4e,0x2f,0x08,0x6c,0xa5,0xe2,0x5b,0x15,0xae,0x58,0xbd,0xbd,
612 0xa1,0x36,0xa9,0xa1,0xb5,0xed,0x1e,0x95,0xf5,0x90,0x35,0xa2,0x5c,0xc3,0x9b,0x1f,
613 0x98,0x5d,0xdd,0xcf,0xd4,0x08,0xd4,0xb7,0x90,0x58,0xb8,0xc7,0x9d,0x60,0x25,0x57,
614 0xa1,0x39,0xc3,0x2c,0x75,0x07,0xd9,0x4c,0xdd,0x2f,0xc8,0xf5,0x7a,0xee,0x06,0xcf,
615 0xdc,0xc3,0x22,0x89,0x37,0xa0,0x9f,0x9f,0x45,0x46,0x2d,0x98,0xac,0xdb,0x33,0x80,
616 0xb3,0x29,0x76,0x6f,0x1b,0x9e,0x71,0xc7,0x41,0x9f,0x12,0x00,0x4e,0x09,0x0c,0xab,
617 0xc7,0xda,0x58,0x60,0x6c,0x0a,0x6e,0x09,0xbe,0x2e,0x2f,0x4f,0x0a,0x63,0x38,0x60,
618 0xca,0xc9,0xe9,0x67,0x70,0xcb,0x4e,0xed,0xa9,0xd3,0xd4,0xbc,0xa2,0x69,0x32,0xcb,
619 0x62,0x69,0xa0,0x32,0x36,0x09,0x96,0x1f,0xdc,0xea,0x73,0xe6,0x84,0x3d,0x84,0xbf,
620 0x62,0x82,0x4d,0x23,0xb1,0xc5,0x64,0xa8,0x57,0x07,0x37,0x3c,0x54,0x63,0x61,0xe1,
621 0x24,0xeb,0xd9,0xdd,0x2e,0xb8,0x8f,0xbd,0xa9,0x3e,0x55,0xd7,0xea,0xfb,0x5a,0xc9,
622 0x68,0xd9,0x9d,0x0e,0x75,0xb1,0x86,0xf0,0xa4,0xb2,0x3f,0xd7,0x77,0x7d,0x5f,0x5f,
623 0x87,0x00,0x07,0x24,0x16,0x20,0x0a,0x5b,0x4b,0x52,0xb6,0x1a,0x39,0xd6,0x32,0x43,
624 0x7a,0xb4,0xf8,0x81,0x59,0xec,0xbd,0x97,0xb6,0xe7,0x41,0x2b,0x68,0x19,0xb4,0x06,
625 0xec,0xbf,0x34,0x36,0xa2,0x9a,0x7f,0xa0,0xa9,0x16,0x9e,0x98,0x40,0x37,0x22,0x21,
626 0x3e,0x43,0xe3,0xaf,0x30,0x6e,0x50,0xf5,0xba,0xe4,0x00,0x14,0x25,0x08,0xbf,0xa8,
627 0xdf,0x71,0x4b,0x3d,0x27,0x8b,0x44,0xbb,0xed,0x2c,0xcb,0x75,0x6a,0x1d,0xb8,0x8b,
628 0xe9,0xe2,0x99,0x0b,0xe5,0xcd,0x0e,0x24,0xa8,0x68,0x91,0xca,0xc9,0x48,0x5c,0xdb,
629 0x60,0xa0,0x43,0x52,0x82,0x74,0x17,0xd7,0x47,0x91,0xd7,0x92,0x04,0xba,0x3f,0xe4,
630 0x54,0xc9,0x41,0xb9,0xa4,0xcf,0x2f,0x0f,0x7e,0xce,0xa2,0x82,0xe7,0xed,0x3a,0x48,
631 0x83,0xdb,0xdb,0x9f,0x1d,0xa2,0x44,0x56,0xf0,0x76,0x7a,0x20,0x6b,0xd7,0x8e,0xc1,
632 0x34,0x67,0x28,0xc3,0x1e,0x8d,0x03,0xf0,0x91,0x87,0x83,0xeb,0x26,0xa3,0x38,0xe0,
633 0xc6,0xd9,0x1d,0x3a,0xa6,0xe4,0xf0,0x31,0xe9,0x23,0xce,0x6c,0x0a,0xe4,0xab,0x3c,
634 0x3c,0xf2,0x68,0x8a,0x41,0xda,0x19,0x5b,0x40,0x9c,0xde,0xc7,0x84,0x0b,0x2b,0xa7,
635 0xfd,0x95,0x37,0xf7,0x42,0x17,0xac,0x90,0x6e,0x11,0x53,0xfb,0x75,0x4b,0x37,0x88,
636 0xd2,0x1f,0xaa,0x73,0x98,0x0d,0x74,0xb3,0x69,0x54,0x2b,0x9e,0x5f,0xaf,0x93,0x21,
637 0x07,0x05,0x60,0xc6,0x61,0x4e,0x5d,0xaf,0x36,0x79,0xca,0x85,0x4a,0x6c,0x58,0xeb,
638 0xcf,0xaf,0x99,0xd9,0xb5,0x82,0x46,0xb4,0x73,0x95,0x1a,0xbc,0x78,0xdd,0xb7,0x47,
639 0x10,0xeb,0x03,0x50,0x63,0x06,0x73,0xdc,0xc4,0xa1,0xa8,0xa3,0x44,0xc1,0x4d,0xc9,
640 0x2c,0x73,0x75,0x0f,0xb0,0xe0,0xa5,0x43,0xd1,0x8a,0x29,0xa9,0x60,0x71,0x4d,0x82,
641 0xae,0x5c,0xa5,0x87,0x93,0x4c,0xa2,0xfd,0xb5,0xb3,0xda,0xf4,0x90,0x61,0x87,0x6e,
642 0xe8,0x8d,0xfc,0x52,0x17,0x06,0x87,0x32,0x37,0x6a,0xff,0xe7,0x58,0xa2,0x46,0x25,
643 0xd0,0x3a,0xd8,0xf7,0xc4,0x1b,0xda,0x58,0x5d,0xb8,0xa2,0x5d,0x4d,0x8b,0x1a,0x90,
644 0x20,0x12,0x00,0xf3,0x7f,0xb0,0x53,0x97,0x6d,0xfb,0xa0,0x5c,0x4a,0x6c,0xb5,0xb5,
645 0xc3,0xb0,0x3a,0x32,0x71,0xbc,0x61,0xe5,0x37,0x60,0xea,0x4a,0xf5,0xd8,0x05,0xc2,
646 0xd4,0x62,0xb2,0x94,0xb0,0x73,0xd6,0x82,0x08,0x60,0x71,0xee,0x7e,0xd5,0xf7,0x30,
647 0x89,0xe8,0xb5,0x1a,0x08,0xb8,0xea,0x11,0x57,0x9d,0x99,0x2d,0xef,0xd0,0x5a,0xb7,
648 0x24,0xc8,0x1d,0x87,0x81,0x70,0xbb,0xb9,0x88,0xed,0x04,0x32,0xab,0x55,0x7e,0xea,
649 0x1a,0x77,0x80,0x7a,0x88,0x08,0xc7,0xa1,0x53,0x05,0xb1,0x85,0x43,0x5a,0x11,0x4f,
650 0x2a,0x7e,0xda,0xfe,0x83,0x12,0x47,0xc4,0xd7,0x6b,0xfb,0x8a,0x0c,0x90,0x77,0x84,
651 0xc0,0xb3,0xa6,0x60,0x96,0xd3,0x2f,0x5f,0x3f,0x62,0xe4,0xda,0x13,0xf4,0x35,0x50,
652 0x20,0x5b,0x1a,0xd0,0xc7,0x39,0x06,0x08,0x6a,0x0d,0x5e,0xb7,0x8b,0x37,0x56,0x1c,
653 0x52,0x7c,0x9b,0x6a,0xd6,0x7e,0x8e,0xb0,0x36,0xb7,0x44,0x36,0x30,0xb9,0x0f,0x39,
654 0x51,0x48,0xc3,0xa3,0xa1,0x98,0x57,0x6b,0xba,0xf6,0x62,0xaf,0xf4,0x2b,0x6c,0x50,
655 0xa1,0x55,0xf4,0x58,0x37,0xc4,0x4a,0xd2,0xcb,0xb6,0x59,0x19,0x82,0x3d,0x5e,0x3d,
656 0x38,0xc3,0x74,0xab,0x0c,0xd0,0xb2,0xc5,0xb0,0x87,0x30,0xa2,0xef,0x0a,0x85,0xb0,
657 0xe5,0x6c,0x39,0x13,0x8f,0x54,0xfe,0xf4,0x3c,0x16,0x4b,0xfd,0xfa,0x2a,0xef,0x66,
658 0xa8,0x2a,0x8d,0xc0,0x7b,0x53,0x55,0x4b,0xba,0x19,0xa3,0xa3,0x5f,0x16,0xb4,0x06,
659 0xb2,0x56,0xa7,0xca,0xfa,0x6a,0x1f,0xf2,0x0f,0xe5,0x58,0x8a,0x6d,0x45,0x43,0xb3,
660 0xd5,0xd2,0x35,0x4f,0x52,0x75,0x47,0x74,0x6f,0x7c,0x25,0x98,0xb2,0xa9,0xef,0x37,
661 0x8e,0xa9,0x89,0xff,0x18,0xb6,0x56,0x75,0x32,0x8e,0x98,0xed,0x35,0x8b,0xca,0xad,
662 0x91,0xaf,0xdd,0xd4,0xdf,0xff,0x23,0x99,0x45,0x30,0xad,0x9d,0xec,0xce,0x94,0x4a,
663 0x6d,0xaa,0xd7,0x6b,0x73,0xa3,0x33,0x0d,0x8b,0x1d,0xd0,0xde,0xc6,0x30,0x82,0x05,
664 0x6e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x05,0x5f,
665 0x04,0x82,0x05,0x5b,0x30,0x82,0x05,0x57,0x30,0x82,0x05,0x53,0x06,0x0b,0x2a,0x86,
666 0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,0x02,0xa0,0x82,0x04,0xee,0x30,0x82,0x04,
667 0xea,0x30,0x1c,0x06,0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x03,0x30,
668 0x0e,0x04,0x08,0xe9,0x3c,0x06,0x49,0x97,0xcf,0x08,0xfe,0x02,0x02,0x08,0x00,0x04,
669 0x82,0x04,0xc8,0x95,0xff,0x56,0xf1,0x44,0xdd,0xe9,0x3d,0x50,0x22,0xbd,0xda,0x8c,
670 0x1d,0x0f,0x6f,0xde,0x2d,0x96,0x46,0x21,0x32,0xc9,0xde,0x6d,0x96,0x45,0xfd,0x05,
671 0x67,0xde,0x46,0x22,0x87,0xc3,0xbe,0xb9,0xb1,0x30,0x9d,0x8b,0xb0,0x6b,0x35,0xd9,
672 0xa0,0x09,0x49,0x43,0x77,0x93,0x3b,0x6f,0xdd,0xc9,0xba,0xdd,0xa4,0xf9,0x81,0xb0,
673 0xc8,0x61,0x2e,0xd8,0xe9,0xd0,0xb4,0xa4,0xe8,0x49,0x5a,0x48,0xe7,0x88,0x21,0xdc,
674 0x1d,0x84,0x12,0x08,0x08,0x74,0x52,0x36,0x4a,0x30,0x6b,0xb0,0x57,0x91,0x71,0x0c,
675 0x56,0x64,0xc8,0x6d,0x4e,0xfa,0xc6,0xdf,0xec,0xc6,0xc6,0x97,0x76,0xe0,0x5d,0x14,
676 0xb7,0x67,0xdc,0xec,0xc9,0x83,0xec,0x8e,0xae,0x3d,0x3d,0x85,0xd2,0x26,0xc9,0x8c,
677 0x2a,0xb1,0xf1,0xd7,0xc6,0xe3,0x64,0xf8,0x31,0x59,0xf5,0x6d,0x29,0xd3,0xce,0x29,
678 0x8c,0xaa,0x0e,0x3d,0x5d,0x8f,0x9e,0x00,0xb6,0xfd,0xfb,0x7a,0x3a,0x2f,0xaa,0x1e,
679 0x01,0x0a,0xd6,0xb5,0xdf,0x34,0x60,0x60,0xe0,0x5a,0x94,0x68,0x6d,0x87,0x26,0x3e,
680 0x85,0x83,0x1a,0xb9,0x82,0x71,0xc5,0xb1,0x28,0x67,0x9e,0x2c,0xbe,0x07,0x4a,0x8b,
681 0xd2,0xa1,0x2e,0x5c,0xb1,0xff,0x26,0xae,0x2e,0xc9,0xc2,0x3a,0x78,0x12,0x50,0x0b,
682 0xbd,0x01,0x48,0x41,0x89,0x1f,0xa1,0x74,0xe8,0xe0,0xc7,0x70,0x88,0xac,0xa2,0x04,
683 0x21,0x82,0x4b,0x8f,0x2a,0x81,0x13,0x4a,0xbb,0x80,0x59,0x7c,0xef,0xc4,0x26,0xb8,
684 0x9d,0x43,0x76,0xef,0x2e,0x53,0xc3,0x10,0xd8,0xd8,0x76,0x2b,0xf0,0x00,0xca,0xf3,
685 0xf7,0xa5,0xff,0x2a,0x7d,0x2b,0x9e,0xec,0x2d,0xf4,0x0c,0x1c,0x0e,0xa5,0xef,0x92,
686 0xd5,0x26,0x2d,0x22,0xf8,0x67,0xcf,0x9d,0xc3,0x06,0xd7,0xdf,0x9a,0x91,0x94,0xaa,
687 0x73,0x70,0x6b,0xf9,0xa6,0x32,0x21,0xb2,0x8a,0x2a,0xe2,0x6c,0x9b,0x6e,0x8d,0xc7,
688 0xa5,0x18,0xa3,0xf4,0x8f,0xaf,0x6e,0xe3,0x4c,0x76,0xe9,0xe6,0x81,0x7f,0xa1,0x3b,
689 0x53,0x3f,0xb1,0x0f,0x94,0x5b,0x57,0x23,0xfe,0x19,0x51,0xf8,0xc5,0xd6,0x6d,0xa9,
690 0x55,0x53,0xb6,0xf8,0x93,0x29,0xe8,0x4b,0xca,0x1f,0x9c,0xe5,0xdb,0x30,0xa2,0x13,
691 0x26,0xed,0x90,0xea,0x5e,0xa5,0xc8,0xf6,0x04,0xf3,0xc0,0xd0,0x0d,0x7c,0x33,0x66,
692 0x8d,0xfd,0x69,0x70,0x91,0x96,0xe4,0x9f,0x70,0xfa,0x4b,0xbc,0x07,0xbf,0xf7,0x0e,
693 0x9f,0xcc,0x3a,0xef,0x5a,0xc8,0x5f,0xd7,0x17,0x5a,0xaa,0x35,0x68,0x09,0xb7,0x5a,
694 0xc9,0xab,0x33,0x40,0x17,0xb7,0xd2,0x66,0xe6,0xea,0x74,0xca,0xd5,0x71,0x89,0x8b,
695 0x95,0x07,0x2c,0xbd,0x43,0xc9,0x7a,0xa3,0xb5,0x8b,0x11,0x61,0x95,0x4e,0x39,0xeb,
696 0x66,0xfb,0x06,0xfb,0xf2,0xd4,0x56,0xb5,0x2b,0xca,0x93,0xde,0x22,0xbe,0xc2,0x62,
697 0xbd,0xbc,0x58,0x0d,0x49,0x4d,0x08,0x82,0x8a,0x63,0x74,0x7c,0x64,0x0d,0xf5,0x36,
698 0x82,0xc2,0x14,0x6a,0xa1,0x34,0x34,0x94,0x55,0x74,0xc6,0x69,0xe6,0xd4,0x3c,0x6c,
699 0x03,0x0f,0xa5,0xa5,0x23,0x58,0xbb,0x97,0x75,0x97,0x70,0x4e,0x6a,0x94,0x57,0xba,
700 0x5a,0xbb,0xab,0x3f,0xfe,0x8f,0x1d,0x5a,0x1f,0x7a,0x6d,0x79,0xaa,0x67,0xd8,0xdc,
701 0x03,0x88,0x2f,0x2c,0xa7,0x79,0xc0,0xd7,0x85,0x42,0xf9,0xc3,0x23,0x67,0x09,0x22,
702 0x3a,0xb8,0x04,0x5c,0xa9,0x75,0x18,0x35,0x16,0x39,0x7a,0xf2,0x01,0xb7,0x5e,0xe6,
703 0xa1,0xc8,0x2b,0x29,0x9c,0x38,0xb1,0x8b,0x50,0xd8,0xe9,0x8b,0x6a,0x38,0x5b,0xe0,
704 0xfe,0x88,0x21,0xb6,0xc9,0xf6,0x6a,0x66,0x17,0xe7,0x37,0x42,0xe9,0x62,0x63,0x41,
705 0xca,0xa1,0xc7,0x0c,0x5c,0xf6,0xdc,0xf5,0xf4,0x5f,0xc1,0x84,0xc5,0x8f,0xe8,0x87,
706 0x5e,0xb2,0xf5,0x0a,0x9f,0x8f,0x8d,0x71,0x25,0x3b,0x54,0xb8,0xd2,0x15,0x3f,0x69,
707 0x27,0x9b,0xea,0xf7,0x83,0xf5,0xf2,0x24,0xd9,0xd8,0xd6,0x62,0x13,0x43,0xe5,0x64,
708 0xb3,0xf2,0x49,0x70,0x02,0xf4,0x76,0x42,0xae,0xed,0x00,0xbf,0x18,0x5b,0xe0,0x1c,
709 0x41,0x37,0x0e,0xbd,0x13,0x2d,0xa1,0x31,0x0c,0x8c,0xd6,0xc4,0x27,0xe4,0x2a,0x74,
710 0xa3,0x90,0x63,0x56,0x05,0x59,0x6a,0xdc,0x45,0x9e,0x04,0x14,0xd3,0x32,0x77,0xff,
711 0xb2,0x50,0x73,0xba,0x2a,0xd3,0x70,0x69,0xbe,0xec,0xf6,0xee,0xed,0xf9,0x88,0x65,
712 0x4e,0x61,0x32,0x09,0x73,0xdc,0x16,0x16,0x8a,0xec,0x09,0x44,0xcb,0x2c,0x03,0x44,
713 0xaf,0xd7,0xcd,0x0d,0x91,0x52,0xf1,0xba,0xed,0x64,0x7b,0xd9,0xa1,0x1a,0x40,0xdb,
714 0xf8,0x46,0x86,0x74,0x30,0x2d,0x72,0x62,0x2a,0x8c,0xd0,0xa2,0x6f,0xcd,0x21,0x02,
715 0xc9,0xc4,0xd0,0x81,0x23,0x1c,0x81,0xd9,0x71,0xc1,0xee,0x70,0x37,0x8e,0x23,0x9d,
716 0x2c,0xd6,0x4b,0x2b,0x08,0x92,0x95,0xbb,0xf4,0xae,0x78,0x14,0xa6,0x16,0xdc,0xf7,
717 0xba,0xc1,0x18,0x96,0x13,0x5a,0xa4,0x12,0xcd,0x96,0x2b,0xb3,0x21,0x0a,0xd6,0x7e,
718 0x25,0xd8,0xe9,0x59,0xd5,0x18,0x91,0x85,0xc1,0xe3,0xee,0xf8,0x9b,0x4f,0x42,0x04,
719 0x03,0x7d,0xe8,0xcc,0x2a,0xa3,0x8e,0x95,0x9b,0x47,0xb0,0x89,0x7f,0xd5,0x53,0xbd,
720 0x54,0x7b,0x73,0xa2,0x0a,0x62,0x51,0x34,0x3b,0xc5,0x41,0x5d,0xa5,0x5c,0x94,0x69,
721 0xd5,0xfd,0x5e,0x71,0xc1,0x6e,0x18,0x80,0x1f,0xab,0x94,0xcd,0x0d,0x44,0x47,0xd4,
722 0xa9,0xf3,0x3a,0xfd,0xf8,0x47,0xe4,0x9c,0xd7,0x5d,0x54,0x6f,0x4b,0xea,0xf1,0x8f,
723 0x9f,0xca,0x3c,0x24,0xe6,0x8b,0xa5,0x29,0x5b,0x07,0x05,0x60,0x41,0xce,0x77,0x2b,
724 0xfe,0xe0,0x4e,0x47,0x92,0x2d,0xca,0x5b,0x6e,0x08,0xcc,0x25,0x8e,0xc8,0x93,0x96,
725 0x49,0x6d,0x3f,0x25,0xbf,0x8e,0x37,0xe3,0xdf,0xb9,0xea,0xf0,0x2b,0x56,0xc8,0x30,
726 0x7d,0xff,0x32,0xfa,0x9c,0xf1,0x35,0x6b,0x68,0xf2,0xfd,0x1e,0x23,0xf2,0x95,0x81,
727 0x68,0xd8,0xec,0x95,0x5b,0x85,0xa8,0x42,0xa6,0xcc,0xf5,0x03,0x95,0xf1,0x3f,0xd2,
728 0x86,0x3a,0x1f,0x11,0xd2,0xcf,0x4b,0x32,0xf2,0xb9,0x46,0x3e,0xf5,0xbb,0x0d,0xa0,
729 0x5b,0x85,0xea,0xe0,0xbd,0x7c,0x3b,0x75,0x80,0x1c,0x8a,0x6d,0x92,0x39,0x27,0xbf,
730 0xc5,0x8e,0xb4,0x5a,0xaf,0xd5,0x8b,0x34,0x53,0x85,0x76,0x60,0xe6,0xd4,0xb8,0xe2,
731 0x2f,0x9e,0x66,0x24,0x28,0x66,0x06,0x25,0x62,0x77,0x35,0xce,0x36,0x68,0x2a,0xdc,
732 0x82,0x94,0xd8,0x21,0x96,0x7b,0x05,0x10,0x3b,0xcc,0xfb,0x43,0x11,0xd0,0x25,0xfc,
733 0x1c,0x5a,0x1c,0xee,0x3d,0x1c,0x75,0xf8,0x41,0xa7,0x10,0x48,0xd7,0xee,0x9e,0xa4,
734 0x62,0xb0,0x64,0xaa,0x55,0xd9,0xd7,0xb6,0x4b,0xe9,0x84,0xa8,0x64,0xcc,0xb3,0x3a,
735 0xe7,0x83,0xf0,0x8a,0xd3,0xe3,0x86,0xda,0xb5,0xc7,0x8e,0x9c,0x84,0xde,0x06,0x5d,
736 0x8f,0x4d,0x68,0x35,0x69,0x88,0xc2,0xd1,0xea,0xab,0x1b,0xa7,0xf0,0x8e,0x05,0x3d,
737 0xdb,0x8b,0x27,0x20,0xd2,0xb1,0x20,0xab,0x9a,0xda,0x4d,0x03,0xbd,0xa4,0x17,0xf6,
738 0x01,0xb5,0x25,0x62,0x02,0xe5,0x17,0xdd,0x71,0x8a,0xe8,0x2b,0x01,0x56,0x35,0x31,
739 0x79,0x6f,0x7f,0x98,0x3f,0x5c,0x3d,0x0d,0x11,0x43,0x44,0x31,0xe0,0x94,0xa0,0x6a,
740 0xaa,0x8e,0x24,0x0d,0x8f,0xe2,0x81,0x75,0x0d,0x9f,0x54,0xf8,0x0e,0x23,0x19,0xb9,
741 0xa9,0x6e,0x11,0xfc,0x08,0xb4,0x73,0x77,0xda,0x3b,0x00,0x63,0xc4,0xb8,0x79,0xb4,
742 0xf9,0xb2,0x41,0x55,0xd5,0xb6,0xd3,0x91,0x4d,0x77,0xeb,0xc9,0xb9,0x42,0xba,0xef,
743 0x05,0xae,0x2f,0xc3,0x1a,0x7d,0x9b,0x01,0xef,0xee,0x8f,0x0b,0x2c,0x68,0xab,0xc6,
744 0x43,0xb3,0x87,0x1f,0xca,0xba,0xe7,0x30,0xe9,0x7a,0xda,0x55,0xec,0x77,0xd1,0xb6,
745 0x44,0xcb,0x91,0x43,0xa9,0x2b,0xc1,0x26,0xed,0x14,0x85,0x31,0x52,0x30,0x2b,0x06,
746 0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x14,0x31,0x1e,0x1e,0x1c,0x00,0x54,
747 0x00,0x65,0x00,0x73,0x00,0x74,0x00,0x20,0x00,0x53,0x00,0x53,0x00,0x4c,0x00,0x20,
748 0x00,0x55,0x00,0x73,0x00,0x65,0x00,0x72,0x00,0x00,0x30,0x23,0x06,0x09,0x2a,0x86,
749 0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,0x16,0x04,0x14,0xf1,0x1b,0x6e,0xf2,0x3a,
750 0xc4,0x3a,0xe1,0xd6,0x4b,0x7d,0x31,0xf3,0x2c,0xd4,0x63,0x06,0x66,0x37,0xe0,0x30,
751 0x30,0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14,
752 0x85,0xed,0x34,0x3d,0xde,0xa1,0x8a,0x94,0xcd,0x12,0x95,0xf7,0x2d,0xb2,0x60,0xfd,
753 0xbd,0x67,0xe9,0x2d,0x04,0x08,0x71,0xfc,0x54,0xf2,0x12,0x3c,0x22,0xf1,0x02,0x01,
754 0x01
755 };
756
757 /* Test identity (PKCS12 data), SMIME cert, expired in 2008
758 */
759 unsigned char TestIDSMIME2007_p12[2805] = {
760 0x30,0x82,0x0a,0xf1,0x02,0x01,0x03,0x30,0x82,0x0a,0xb8,0x06,0x09,0x2a,0x86,0x48,
761 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0a,0xa9,0x04,0x82,0x0a,0xa5,0x30,0x82,
762 0x0a,0xa1,0x30,0x82,0x05,0x17,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,
763 0x06,0xa0,0x82,0x05,0x08,0x30,0x82,0x05,0x04,0x02,0x01,0x00,0x30,0x82,0x04,0xfd,
764 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x1c,0x06,0x0a,0x2a,
765 0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x0e,0x04,0x08,0x3f,0x0b,0xd9,
766 0x3c,0x80,0x6d,0x5e,0x7b,0x02,0x02,0x08,0x00,0x80,0x82,0x04,0xd0,0x08,0x25,0x32,
767 0xdc,0x7b,0xed,0x8a,0x29,0xf8,0x56,0x84,0x51,0x5c,0x6d,0xe6,0xe6,0x34,0xf8,0x03,
768 0xb3,0x80,0xe2,0xf4,0x0e,0x3f,0x1f,0xad,0x12,0x11,0x27,0x56,0xe8,0x89,0x59,0x90,
769 0x03,0xf0,0xa7,0xc2,0xde,0xd0,0x70,0xbf,0x2c,0xea,0x01,0xe7,0xbd,0xba,0xaf,0xfc,
770 0x07,0x84,0x2f,0xdb,0x65,0xa0,0x7b,0x4b,0x6a,0xab,0xe4,0xbd,0xd0,0xbb,0x31,0xaf,
771 0x90,0x8c,0xa8,0x71,0x10,0x23,0x96,0x67,0x44,0xdd,0x02,0x72,0xd2,0x0f,0xca,0xcb,
772 0x4f,0xc2,0x14,0x04,0xfa,0xde,0x31,0xa5,0x2f,0x97,0xc0,0x2a,0xdd,0xdd,0x91,0x62,
773 0xa7,0xf7,0x9b,0x43,0x57,0x7d,0x4d,0x1c,0xb1,0x92,0xba,0xae,0xa1,0x24,0x6c,0x99,
774 0x81,0x49,0x56,0x46,0x8b,0xea,0x7c,0x16,0x19,0x76,0xf7,0x40,0x06,0x82,0xe2,0x5b,
775 0x3f,0xd8,0x2c,0x87,0x60,0xf7,0xae,0xaa,0xa5,0xba,0x96,0xbf,0x5c,0x86,0x57,0x81,
776 0x8d,0xbf,0x6c,0xe1,0xd1,0xb9,0x20,0x93,0x27,0xfc,0xe6,0x35,0x80,0xaa,0xfb,0xe6,
777 0x4b,0xfd,0x4f,0xa4,0x06,0x05,0x46,0x85,0x66,0x15,0xfb,0x83,0x2b,0x42,0x26,0x98,
778 0xc8,0x69,0x24,0xa1,0x71,0xb4,0x56,0x38,0x3d,0x5e,0xc2,0x13,0x34,0xab,0x2f,0xb1,
779 0x33,0x6e,0xf0,0x07,0x80,0xdd,0x0e,0x6f,0x19,0x01,0xaf,0xff,0x5f,0xc3,0xea,0x24,
780 0x5a,0x6d,0xad,0xb3,0x10,0xbb,0x63,0x02,0x14,0x38,0xa9,0x21,0x83,0xb9,0xc3,0x23,
781 0xba,0xfc,0x56,0x76,0x4d,0x46,0x43,0xd1,0x09,0x37,0x1f,0x79,0xe5,0x70,0x93,0xb5,
782 0x0f,0x21,0xe3,0xef,0x0b,0x4d,0x87,0x0c,0x68,0xf5,0x16,0xc0,0x13,0xee,0x28,0xe8,
783 0x49,0xaa,0x60,0x61,0xe5,0x76,0xe6,0x8e,0xd6,0xae,0x52,0x70,0xb2,0x70,0xbf,0xeb,
784 0xd2,0xd8,0xb8,0x92,0x71,0x6e,0xb8,0x59,0xdf,0xee,0xad,0xc1,0x55,0x14,0x4b,0x52,
785 0x0c,0x20,0x4c,0x79,0x93,0x71,0xe6,0xc5,0xbc,0xf3,0xf3,0x14,0x13,0xd0,0xcd,0x1c,
786 0x62,0x21,0xc0,0xcf,0x4e,0xf5,0xda,0x52,0xbf,0x2c,0x86,0x8f,0xb5,0x67,0xf5,0x72,
787 0xbb,0xe9,0xb8,0x86,0x17,0xd9,0x35,0x49,0xae,0x0a,0x99,0x94,0xa5,0xaa,0x96,0xf4,
788 0x95,0xfe,0x4a,0xe2,0x13,0x46,0xcb,0xd9,0x8b,0x48,0x50,0xff,0x34,0x88,0x12,0xe7,
789 0x9b,0x00,0x8d,0x57,0x94,0x44,0xa5,0xe6,0xd1,0x7f,0x34,0xbb,0x33,0x9f,0xc3,0x12,
790 0x3b,0xb2,0xba,0xb6,0xb3,0x15,0x9e,0xaf,0x90,0x5e,0x2e,0x61,0x0d,0xe6,0x02,0x25,
791 0x41,0x55,0x18,0xc9,0x4a,0x5a,0x0a,0xb2,0xf5,0x99,0x8a,0x27,0xc7,0xd7,0x01,0x96,
792 0x9e,0x4c,0x05,0x7f,0x54,0x90,0x08,0x92,0x9c,0xf2,0xbd,0x0d,0x7d,0x37,0x5a,0x57,
793 0x1d,0x5b,0xcb,0xce,0xc1,0x58,0x5e,0x50,0x73,0x4d,0x61,0x28,0x18,0x90,0x2d,0xac,
794 0x91,0x4b,0x5e,0x5f,0x57,0x29,0x58,0x65,0xba,0xa4,0x11,0x92,0xa8,0xf4,0xac,0xa8,
795 0x39,0x1c,0x52,0x14,0x09,0x13,0xdd,0x4e,0xfa,0xef,0xba,0x4f,0x48,0xc3,0x46,0x4e,
796 0xb9,0x8d,0xff,0x5e,0x28,0xb8,0xcc,0x99,0x7f,0x3a,0xdc,0xf4,0x90,0x5c,0x41,0x14,
797 0x4b,0xbc,0x6b,0xa3,0x01,0x78,0x87,0xc1,0x86,0xd7,0xad,0x98,0xa0,0xc6,0x82,0x35,
798 0x76,0x41,0x6f,0xf1,0xee,0x54,0xbd,0xef,0xef,0xfc,0x2b,0x88,0x56,0x61,0xb1,0x93,
799 0xa0,0xe5,0x8e,0x1e,0xb4,0xb1,0x39,0xb3,0xd3,0x85,0xe0,0xa2,0x61,0x4b,0xe8,0x24,
800 0xc3,0xdd,0x48,0x2a,0xfd,0x5a,0x98,0x7a,0x98,0x2a,0xc7,0x81,0x4c,0x3d,0x3b,0x0c,
801 0x42,0x69,0x42,0x87,0xf1,0x5f,0x13,0x47,0xf6,0x89,0xc5,0x5e,0x47,0x84,0x59,0x81,
802 0x97,0xef,0x22,0x79,0x16,0x37,0xdc,0x74,0x66,0x30,0x81,0xbc,0x45,0x21,0xe4,0x75,
803 0x69,0xe4,0x64,0x2b,0x98,0x97,0x61,0xe1,0x34,0xdf,0x4a,0x37,0x65,0x74,0xdc,0xe1,
804 0x71,0x37,0xd6,0x2c,0x54,0x83,0x7a,0x91,0xc4,0xa6,0xfe,0x09,0x12,0xf3,0xf5,0x2b,
805 0xec,0xe9,0x63,0xa3,0x25,0x0f,0x6f,0xd1,0xb0,0x95,0x3f,0x7f,0xab,0xa7,0x25,0x9b,
806 0x85,0xdb,0xcf,0x6e,0x0e,0xc0,0x8d,0xd3,0xca,0x0e,0xd2,0x98,0xeb,0x77,0x39,0xf4,
807 0x1a,0x30,0xe6,0x76,0x6d,0xba,0xc0,0x61,0x55,0x4e,0xbe,0x88,0x32,0xb2,0xae,0x16,
808 0x27,0xbd,0x61,0xc5,0x48,0x26,0x0f,0x05,0x1a,0x42,0xa6,0xd9,0x29,0xf8,0x58,0x96,
809 0x16,0x1d,0xad,0xf4,0x58,0xc6,0x79,0x46,0xdf,0x1f,0x25,0x43,0xaa,0xf5,0xc3,0x1f,
810 0x75,0x36,0x1c,0x17,0xd2,0x4d,0x88,0xf6,0x37,0x35,0x21,0x1f,0x0f,0x45,0x85,0x13,
811 0x50,0x85,0x0a,0xa2,0xb4,0x96,0x7a,0xe4,0x0a,0x27,0x74,0x87,0x1b,0x11,0xaa,0x7c,
812 0x35,0xf6,0xb6,0x49,0x8d,0x58,0x30,0x16,0xb7,0x36,0xd6,0xd8,0x82,0xe6,0x3d,0xa4,
813 0xdf,0xa7,0xc4,0xc7,0xfe,0x81,0x01,0xa6,0xda,0x63,0x10,0x9f,0x2b,0x84,0x14,0x62,
814 0xb8,0x37,0x9b,0xb4,0x3f,0x62,0x6b,0x76,0x36,0x39,0xb7,0x41,0xaf,0xb9,0xc9,0xf8,
815 0xa5,0x20,0x1f,0x0c,0xfc,0x71,0xca,0x6f,0x56,0x4d,0x6b,0x23,0x5b,0xb2,0x77,0x6f,
816 0x83,0xcc,0x8e,0x8c,0x78,0xda,0x4a,0xbf,0x92,0xd4,0x20,0xfe,0x43,0x6a,0xd4,0x7e,
817 0xd5,0x6c,0x56,0xdb,0xf8,0x94,0x01,0xc8,0x6f,0xdb,0x00,0x9c,0x0b,0x4c,0x97,0xa5,
818 0x2b,0xc1,0x46,0x19,0x91,0x34,0x05,0x9b,0x33,0x20,0xb2,0x79,0xe5,0x00,0x3d,0xb2,
819 0x54,0x4f,0xfa,0x23,0xaa,0xfa,0x3d,0x0c,0x83,0xcf,0x81,0xd1,0xd0,0x12,0x03,0x34,
820 0xda,0x6b,0xbb,0x63,0xbe,0x1b,0x3c,0x53,0x91,0x2b,0x7e,0xd7,0x76,0x62,0x6e,0xc9,
821 0xb1,0x3d,0x74,0x9f,0x96,0xfb,0x66,0xad,0x35,0xba,0x23,0x10,0x9b,0xab,0xc3,0x8a,
822 0x87,0xd1,0x0b,0xa2,0x99,0x34,0x8a,0x43,0x90,0xe9,0x65,0xe7,0x69,0x09,0x61,0x5f,
823 0xce,0x42,0x58,0x69,0xdf,0x8b,0x0c,0x5a,0xa0,0x6a,0x25,0x33,0x29,0x9e,0x23,0xbb,
824 0x77,0xf9,0xa4,0x2f,0x66,0x86,0xc5,0x38,0xf6,0x3d,0xcb,0x03,0xbf,0x94,0x9d,0x56,
825 0x73,0x53,0x9d,0xf4,0xc6,0xad,0x22,0x6d,0xff,0x92,0x90,0x63,0x80,0x5b,0xd2,0x4b,
826 0x18,0xcd,0xc5,0xe1,0xdb,0x4d,0x96,0xc4,0x29,0x0b,0x0e,0xb8,0x18,0x53,0x66,0x49,
827 0x20,0x8e,0xef,0x25,0x93,0x48,0x12,0xe6,0x36,0xd4,0x33,0xcc,0x4d,0x99,0xbd,0x94,
828 0x96,0x61,0xb2,0x7a,0x76,0x7f,0xa1,0xd9,0x1b,0x77,0xfc,0xb7,0x54,0xaf,0x6c,0xeb,
829 0xec,0x90,0x15,0x21,0x2f,0xe2,0x40,0x05,0x23,0x0c,0x2a,0xe2,0xda,0xa0,0x9b,0x0c,
830 0xc7,0x8b,0x31,0xd7,0x8e,0x91,0x95,0x39,0x79,0xd7,0x6d,0xbf,0x86,0x24,0x4d,0xcd,
831 0x72,0x43,0x05,0x56,0xc0,0xe1,0x0c,0xed,0x51,0xa3,0xa9,0x85,0x74,0x41,0x20,0xe2,
832 0x37,0x66,0x80,0x40,0x02,0xf2,0x4b,0x60,0x36,0x4f,0xcf,0x12,0x5a,0x22,0xbc,0x6c,
833 0x21,0xb1,0x2f,0x0c,0x4a,0x26,0xc2,0x14,0x23,0xb3,0x91,0x17,0x48,0x9e,0x27,0x6d,
834 0x6a,0x2f,0xaf,0x58,0xe4,0xf7,0x4d,0x40,0x4b,0xd9,0x52,0xa0,0xf6,0x5e,0xc3,0x36,
835 0xda,0xa6,0x27,0x81,0x1e,0x7c,0x61,0x45,0x93,0x1a,0xa6,0x9d,0x16,0x61,0x95,0xed,
836 0x20,0x2c,0x49,0x6d,0x8f,0x8d,0x1a,0x44,0x89,0x0a,0xce,0x3c,0x00,0x9c,0x76,0x76,
837 0xa5,0x0b,0x40,0x52,0xf2,0xb9,0x30,0xae,0xab,0x04,0x41,0xa1,0x30,0x2f,0x43,0x1b,
838 0x68,0xdb,0x7c,0x4d,0x6c,0xe6,0x05,0xfc,0xa4,0xab,0xd2,0x0a,0x75,0x0c,0xd9,0x40,
839 0x09,0xf1,0xcb,0x5e,0x0a,0x09,0x2c,0x75,0xbc,0x79,0xa5,0xd5,0xb5,0xde,0x07,0xfd,
840 0x27,0x31,0x96,0xad,0x66,0xc6,0xa6,0x5e,0x0a,0x57,0x06,0x39,0x03,0xe4,0x84,0x61,
841 0xcf,0x25,0x6c,0xcd,0x56,0xf4,0xe7,0xd1,0xff,0x93,0x6c,0x2d,0xd6,0xcf,0x0d,0xe6,
842 0x1e,0xe5,0x57,0x37,0xa6,0x6d,0xec,0xa1,0xde,0xe8,0x1f,0x64,0x90,0x5e,0x70,0xe2,
843 0xe8,0x05,0x24,0xac,0x36,0xe1,0xea,0x75,0xdf,0x60,0xe2,0xbf,0xc2,0x30,0x82,0x05,
844 0x82,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x05,0x73,
845 0x04,0x82,0x05,0x6f,0x30,0x82,0x05,0x6b,0x30,0x82,0x05,0x67,0x06,0x0b,0x2a,0x86,
846 0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,0x02,0xa0,0x82,0x04,0xee,0x30,0x82,0x04,
847 0xea,0x30,0x1c,0x06,0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x03,0x30,
848 0x0e,0x04,0x08,0xf4,0xa6,0x0f,0xb4,0x2e,0x8e,0x48,0xa6,0x02,0x02,0x08,0x00,0x04,
849 0x82,0x04,0xc8,0x0a,0x64,0x3b,0x68,0x4a,0x9a,0xf0,0xf6,0x80,0x65,0x2d,0xca,0xa6,
850 0x74,0x33,0x32,0xf3,0x71,0x97,0x27,0x24,0x3c,0xd1,0xaf,0x8b,0xfb,0xee,0x69,0x40,
851 0xfc,0xff,0x45,0x32,0x3a,0x1a,0xd1,0x35,0x2d,0xae,0xce,0xd6,0x84,0x5b,0x2b,0x20,
852 0x91,0xf8,0x26,0xa6,0x13,0x19,0x21,0x3e,0x8d,0xbb,0x30,0xef,0xdd,0x99,0x58,0x00,
853 0x61,0x57,0xe5,0x1b,0xc6,0x96,0xbe,0x7f,0x9e,0x95,0x47,0x7c,0xdf,0xf1,0x09,0x8f,
854 0xb9,0xa8,0x99,0x0d,0xf1,0x2a,0xe0,0xfd,0x08,0x92,0xf7,0x56,0x45,0x2e,0xb0,0xf4,
855 0x2b,0xf9,0x36,0x43,0xb2,0xbf,0x63,0x82,0x59,0x41,0x25,0x70,0xd6,0x49,0xe8,0x15,
856 0x7f,0x77,0x7c,0x7c,0xb3,0xab,0x7e,0xb6,0x16,0xd9,0xf7,0x22,0xa6,0x23,0x00,0x6a,
857 0x0e,0x62,0xfa,0xd6,0xe2,0x51,0x13,0x0e,0x99,0x9e,0x12,0x48,0xfa,0x71,0xea,0x47,
858 0xeb,0xf7,0xd9,0x9d,0x6f,0xa1,0x77,0x55,0xff,0x30,0xf7,0x68,0x33,0xee,0x26,0x16,
859 0xf6,0x43,0x63,0x4e,0xb7,0x16,0x97,0xd3,0x49,0x1c,0xf1,0x9e,0xe0,0xe5,0x77,0x52,
860 0xca,0x13,0x48,0x8f,0x11,0x23,0x0d,0x87,0x38,0xa7,0xf3,0x81,0x65,0x96,0xff,0xc7,
861 0xb4,0x0f,0x39,0x59,0xff,0x39,0x5a,0x55,0x2b,0x7b,0xab,0x34,0x11,0x42,0x47,0x42,
862 0x0c,0xb0,0x71,0x64,0x73,0xa5,0x1d,0x88,0x6e,0xa4,0x61,0x3c,0x67,0x18,0x67,0x2b,
863 0x42,0xa1,0x2e,0x60,0xae,0x82,0x3e,0x37,0xc8,0x2e,0x8a,0x80,0x2e,0x9c,0x5d,0xe4,
864 0x37,0x58,0xcb,0x6e,0x38,0x75,0x76,0x9a,0xaf,0x25,0xd3,0xb2,0xbe,0xf5,0x36,0x4f,
865 0x09,0x05,0xe2,0xe3,0x20,0x03,0x64,0x6f,0x94,0x3b,0xec,0x40,0x8c,0xe1,0x7e,0xed,
866 0x94,0xfa,0xed,0x9c,0x4d,0x1d,0xd7,0x31,0x1b,0x9d,0xf3,0xf5,0x1b,0xa0,0xf9,0xc8,
867 0xd6,0xf0,0x5e,0xe5,0x26,0x17,0x42,0x18,0xd8,0xe3,0x04,0x65,0xdf,0xa3,0xe6,0x16,
868 0x16,0xd5,0xfb,0xbe,0x08,0x1e,0xbf,0xd2,0x0e,0xd5,0x2b,0x4b,0x78,0xb2,0x80,0xf3,
869 0x8c,0xe6,0x74,0x89,0xe8,0xce,0xa6,0x2b,0xa5,0x38,0x1f,0x2f,0x87,0x93,0x51,0x35,
870 0xe8,0xad,0x6c,0x8d,0x95,0xbd,0xc0,0x24,0xa5,0x14,0x25,0x2d,0xdf,0x4e,0x77,0x32,
871 0x68,0xc0,0x91,0xad,0x51,0x95,0x25,0x44,0x7a,0xd7,0x4c,0x75,0xdf,0x73,0xe5,0x2b,
872 0xeb,0x1c,0xd3,0xe9,0x42,0xa7,0x5a,0x58,0x85,0x06,0xf0,0xcb,0x38,0x51,0x6d,0x09,
873 0x57,0x14,0x6f,0xd8,0x55,0x0c,0x7a,0x77,0x7f,0xb5,0x20,0xe8,0xd0,0xbd,0x88,0x5a,
874 0xad,0xe6,0xf5,0x02,0x2c,0x7d,0x0b,0xfb,0xe4,0x07,0xad,0xa2,0xd5,0x0c,0xc5,0xbc,
875 0x66,0xc4,0x19,0x48,0xe8,0xa2,0x60,0xdd,0xd2,0xf8,0x03,0x9a,0xd9,0x68,0x4d,0xa9,
876 0xd8,0xfa,0xda,0xa3,0x6f,0xcc,0x53,0xea,0x11,0x7e,0xa0,0xa8,0x8f,0xec,0xdb,0xc0,
877 0x2a,0x40,0xc6,0x84,0x58,0x4f,0x2a,0x23,0x4c,0xbc,0xfe,0xaa,0x78,0x58,0x9c,0xdd,
878 0x6c,0xd5,0x63,0xe9,0xe6,0x78,0xc2,0x73,0x14,0xd5,0x11,0xc3,0x2a,0xf5,0x8a,0x46,
879 0x78,0xfc,0x5a,0x59,0xc9,0x9a,0x7f,0xba,0x94,0x44,0xb3,0x45,0x83,0x08,0x94,0x4d,
880 0x72,0x0b,0x0f,0xd6,0x89,0x9a,0x75,0x6b,0x31,0xcb,0xeb,0x55,0x85,0x38,0x2c,0x3e,
881 0x9b,0x86,0xf0,0x58,0x0f,0x4c,0x93,0x24,0xec,0xd5,0xa3,0x61,0x3a,0x79,0x76,0xab,
882 0x37,0x63,0x2d,0x79,0xde,0x6d,0xa3,0x7f,0xf2,0xf0,0x8c,0x45,0xe6,0xce,0x97,0xc6,
883 0x88,0xfd,0x93,0xe0,0xf9,0xd0,0x93,0x6a,0x77,0xa4,0x28,0xc3,0x02,0x77,0x87,0xf6,
884 0x22,0xfa,0x2b,0x0b,0x31,0xcf,0xe2,0xce,0xaa,0xd9,0x65,0xa6,0x96,0x53,0x8d,0xc7,
885 0x67,0xaf,0x0c,0x0f,0xbc,0x51,0xdf,0x0b,0xc4,0xf8,0x06,0x46,0x07,0x12,0x95,0xce,
886 0x38,0x8e,0xe7,0x8f,0x8d,0x46,0x68,0xbe,0xa5,0x40,0xdc,0xed,0xab,0x76,0x5c,0x87,
887 0xac,0xb3,0x5f,0xb9,0xfd,0x9d,0x79,0x54,0x28,0xc2,0x19,0x2e,0x46,0x3f,0x1f,0x67,
888 0xe2,0x58,0x30,0x4e,0x89,0xdd,0x2f,0x44,0x59,0xde,0xe4,0xf4,0x0d,0x4c,0x33,0xe4,
889 0x98,0x6d,0xb4,0x1f,0x03,0x6b,0x0f,0x8e,0xde,0x86,0x1b,0x33,0x37,0x74,0x14,0xbe,
890 0xa9,0x4a,0xac,0xf4,0x9b,0xa7,0x37,0xe8,0xdd,0x94,0x67,0x25,0x5c,0xb4,0x5b,0x79,
891 0xfd,0xd3,0x24,0x21,0x11,0xbe,0x76,0x1f,0x98,0x8b,0x73,0x87,0x0c,0x96,0x82,0x59,
892 0x04,0x22,0x8c,0x9b,0x57,0x0c,0xca,0x16,0xb3,0x02,0xc6,0xdc,0x6f,0xd2,0x9c,0xcd,
893 0x0f,0x31,0xea,0x97,0x94,0xf7,0x43,0xfe,0xe2,0x8f,0xc7,0x07,0x98,0x57,0x30,0x72,
894 0x55,0x43,0xca,0xfa,0xde,0x92,0xf9,0x06,0x9e,0x56,0x73,0x80,0x84,0xbb,0x44,0xe5,
895 0x7d,0x04,0xfc,0x49,0x8d,0x28,0xfa,0x91,0xe3,0x50,0x76,0xc2,0xf8,0x87,0x29,0x04,
896 0xa4,0xfd,0xfb,0x28,0x20,0xe3,0x07,0xb6,0xf4,0xbf,0xe7,0xc4,0x6a,0x93,0x8c,0x12,
897 0xda,0x9d,0x9a,0x5d,0x8c,0x0a,0xd7,0xf5,0x9f,0xbd,0x71,0x00,0xfc,0x22,0xea,0xa4,
898 0x45,0x6f,0xd4,0xc6,0x7d,0x7a,0x47,0x38,0x15,0x17,0xc6,0xde,0xb3,0xeb,0x1b,0x9a,
899 0xea,0x94,0xc1,0x74,0xd1,0x65,0x25,0xc1,0x11,0x82,0x5d,0xb3,0x66,0x7f,0x05,0xd3,
900 0xe1,0x0a,0xfe,0x29,0xcf,0xdd,0x18,0x30,0xff,0x00,0x7f,0xef,0xc1,0x50,0x54,0x7c,
901 0x8b,0x89,0x3c,0x6a,0x12,0x9d,0xd4,0x5a,0xcc,0x48,0x76,0xab,0x64,0xd3,0x54,0x36,
902 0x70,0x9e,0x04,0x69,0x3d,0x20,0x9d,0x62,0x5d,0xe6,0x55,0x8e,0xd0,0x53,0x5c,0xb4,
903 0x54,0x79,0x73,0x69,0x6f,0x56,0xfa,0x60,0x1d,0x61,0xeb,0xeb,0x76,0xb4,0xd5,0x7a,
904 0xc9,0x51,0xfc,0xa9,0xed,0x4a,0xfa,0x5c,0x5c,0xb5,0x20,0x6a,0x44,0xf7,0xaa,0xf0,
905 0x27,0x90,0x55,0xda,0x2d,0xb4,0x11,0x59,0x21,0x65,0x0e,0x87,0xd2,0x53,0x21,0xd2,
906 0x81,0x93,0xf7,0xfe,0x3b,0xec,0x49,0x7e,0x1c,0xdc,0xc2,0x8f,0xdb,0xef,0x3c,0x0a,
907 0x40,0x89,0x94,0xf3,0x2d,0x77,0x84,0x15,0x03,0x00,0x29,0xfa,0x1b,0xea,0x55,0x7d,
908 0xdc,0xdb,0x69,0x95,0xe5,0x72,0xa5,0x17,0x8f,0xfb,0xfc,0x86,0xfc,0x72,0x91,0x09,
909 0x9b,0x32,0x1a,0x06,0x5c,0xa5,0x26,0x4b,0x61,0x40,0x97,0x40,0xce,0x17,0xca,0xe7,
910 0x79,0xe6,0xcc,0x6c,0xa3,0x81,0x9c,0x9f,0x36,0x74,0x36,0x9f,0xd9,0x5d,0x3e,0x29,
911 0xa0,0xce,0xa1,0x84,0xf6,0xaf,0x33,0x2b,0x8b,0x32,0xb4,0x45,0xb1,0x3d,0x72,0x87,
912 0x20,0x8c,0x88,0x02,0x0d,0x93,0x50,0xcc,0x31,0xce,0x03,0xf8,0x85,0x4a,0xdc,0xed,
913 0xc0,0xcc,0xb3,0xda,0x06,0xbd,0x12,0xd5,0xfc,0xd2,0xbb,0x75,0x4b,0xca,0xb2,0x77,
914 0x18,0xe1,0x5e,0xf5,0x9f,0x0c,0x8c,0xe2,0x17,0x73,0xe5,0xa3,0x80,0x40,0xd8,0x42,
915 0xb1,0xf7,0xd0,0x04,0x9f,0x2e,0xc2,0x2b,0x9b,0x5e,0xcb,0xae,0xb4,0x5f,0x95,0x53,
916 0xf5,0xc1,0x72,0xf1,0xff,0xa2,0x5a,0xcf,0x1b,0x78,0x5c,0x99,0xdf,0x09,0x24,0xbf,
917 0xbf,0x86,0xc3,0x0e,0x65,0x9a,0xe6,0xdc,0xde,0x88,0x28,0x94,0xd7,0xc0,0x6d,0xf6,
918 0x93,0x52,0xa6,0x7f,0x74,0x92,0x9b,0x0b,0x62,0xd5,0x2c,0xb4,0xad,0x7c,0xc0,0xc6,
919 0x3b,0x1b,0xd2,0xbd,0x89,0xa8,0x64,0x02,0x9c,0x81,0x9a,0xd8,0x51,0x04,0x22,0x10,
920 0x62,0x46,0x38,0xaa,0xaa,0x3b,0x00,0x5c,0xe8,0x58,0x09,0x25,0xf7,0x53,0x1d,0x72,
921 0xab,0x44,0x80,0xb4,0x33,0x91,0xf8,0x8e,0xe1,0x00,0x5c,0x07,0xdb,0x81,0x71,0x25,
922 0x86,0x3b,0xa7,0x8e,0x31,0x02,0x89,0x43,0x8f,0x0a,0xa8,0xac,0x6b,0x2a,0xe3,0xba,
923 0x4d,0xdf,0x8c,0x20,0x46,0xea,0xd4,0x98,0x2f,0x47,0x98,0xfb,0x03,0x5e,0xdd,0x92,
924 0xc5,0x73,0xa2,0x54,0xf7,0x9f,0x5f,0xda,0xb5,0x1d,0xb5,0xab,0x78,0x2b,0x72,0x43,
925 0x07,0x0a,0x34,0x22,0xb6,0x23,0xde,0x90,0x0f,0x85,0x7b,0x31,0x66,0x30,0x3f,0x06,
926 0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x14,0x31,0x32,0x1e,0x30,0x00,0x54,
927 0x00,0x65,0x00,0x73,0x00,0x74,0x00,0x20,0x00,0x49,0x00,0x64,0x00,0x65,0x00,0x6e,
928 0x00,0x74,0x00,0x69,0x00,0x74,0x00,0x79,0x00,0x20,0x00,0x53,0x00,0x4d,0x00,0x49,
929 0x00,0x4d,0x00,0x45,0x00,0x20,0x00,0x32,0x00,0x30,0x00,0x30,0x00,0x37,0x30,0x23,
930 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,0x16,0x04,0x14,0x69,
931 0x6e,0x3e,0x79,0x39,0x9b,0x28,0xf4,0x29,0xd4,0x38,0x78,0xcd,0xbd,0x11,0x46,0xb5,
932 0x73,0xec,0x96,0x30,0x30,0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,
933 0x05,0x00,0x04,0x14,0x5b,0xc7,0xc7,0x83,0x6c,0xc1,0x23,0xf1,0xeb,0xe8,0xd7,0xc8,
934 0x3f,0x4c,0x59,0x18,0x49,0x61,0xdb,0x72,0x04,0x08,0xde,0xab,0x8d,0x3a,0xff,0xf8,
935 0x2d,0x69,0x02,0x01,0x01
936 };
937
938 /* Test identity (PKCS12 data), SSL cert, expired in 2008
939 */
940 unsigned char TestIDSSL2007_p12[2753] = {
941 0x30,0x82,0x0a,0xbd,0x02,0x01,0x03,0x30,0x82,0x0a,0x84,0x06,0x09,0x2a,0x86,0x48,
942 0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x0a,0x75,0x04,0x82,0x0a,0x71,0x30,0x82,
943 0x0a,0x6d,0x30,0x82,0x04,0xe7,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,
944 0x06,0xa0,0x82,0x04,0xd8,0x30,0x82,0x04,0xd4,0x02,0x01,0x00,0x30,0x82,0x04,0xcd,
945 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x30,0x1c,0x06,0x0a,0x2a,
946 0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x06,0x30,0x0e,0x04,0x08,0x7a,0xe7,0xca,
947 0x1b,0x57,0x26,0xac,0x5e,0x02,0x02,0x08,0x00,0x80,0x82,0x04,0xa0,0x1a,0x44,0x31,
948 0x1c,0x4d,0xa9,0x00,0x7f,0x14,0x71,0x83,0x3b,0x68,0xf8,0xf0,0x6e,0x42,0xd0,0x6a,
949 0x8c,0x02,0xbf,0x6e,0x0c,0xcd,0xee,0x7e,0x48,0xab,0x8b,0x7e,0xc7,0xe4,0x66,0x3f,
950 0x4d,0x3f,0x05,0xcd,0xa5,0x41,0x5c,0xa2,0x2e,0x59,0x4c,0x62,0x4c,0xa7,0xca,0x31,
951 0x10,0xd8,0xc7,0x8c,0xa1,0x6c,0x1d,0x9b,0x27,0x7a,0xa8,0x00,0x7a,0xb9,0xd3,0x4b,
952 0x09,0xf0,0xf7,0x75,0xb6,0x53,0xdf,0x54,0xba,0x2e,0x26,0xf5,0x1c,0x49,0x94,0x72,
953 0xcb,0x06,0xf3,0xa3,0x28,0xcb,0x48,0xb4,0x70,0x4a,0x0a,0xf8,0xfb,0x82,0xad,0x7f,
954 0x50,0x78,0xb7,0x11,0x41,0xd5,0x2b,0x11,0x5c,0x95,0x90,0x0f,0xcb,0xd8,0x95,0xe6,
955 0x77,0x74,0x84,0xe5,0x4c,0x24,0xa0,0xd4,0x7a,0x0a,0xd6,0xc8,0x10,0xa4,0x7a,0xcb,
956 0x5d,0x81,0x61,0x33,0xb7,0x75,0x6a,0x98,0xbe,0xd4,0xaf,0x3c,0x8c,0x61,0x66,0x43,
957 0x6f,0x12,0x4b,0x1e,0x72,0x10,0x76,0xbb,0xc6,0x57,0xbd,0xdb,0x2c,0x99,0xa7,0x53,
958 0x1e,0xe5,0x6a,0x42,0x80,0xb9,0x24,0x4f,0x1a,0x2c,0x96,0x0b,0x64,0xd3,0x63,0x36,
959 0x6f,0x75,0x74,0x8e,0xd0,0x50,0x5d,0xab,0x4b,0xec,0x59,0x04,0xdb,0x23,0xfb,0x9a,
960 0xbf,0xe0,0x88,0x24,0xc6,0x00,0x7e,0xd9,0x12,0x11,0xf0,0xe5,0xe2,0x96,0xb7,0x85,
961 0x6b,0x90,0x03,0xab,0x18,0xa4,0x07,0xcc,0xda,0x19,0x76,0x49,0xde,0x41,0x32,0xda,
962 0x0f,0x9c,0x8d,0xca,0x96,0xbb,0x39,0xbe,0xeb,0x3d,0xb8,0xe6,0xc1,0xea,0xc5,0xa6,
963 0xc3,0x69,0x72,0x96,0x53,0xde,0x36,0x8b,0xee,0x2c,0x6b,0x2e,0x3d,0xad,0xdd,0x9b,
964 0x8a,0xd9,0x1c,0xdd,0x92,0xf3,0x38,0xa7,0xec,0x5d,0xa6,0x46,0x54,0x70,0x71,0x0b,
965 0xa9,0x1a,0x2a,0x54,0x67,0x6e,0x82,0x8e,0xcb,0x5c,0x2d,0x23,0x2f,0x9b,0x0a,0xc8,
966 0xb1,0xf8,0xea,0x9b,0x16,0x72,0xc5,0xf5,0x2c,0x94,0x10,0xdf,0x3f,0xde,0x84,0xa0,
967 0x97,0x96,0xfc,0xd7,0x49,0x4e,0xa6,0x37,0x0c,0x2a,0x39,0x08,0x5e,0xbe,0x58,0x9c,
968 0x94,0x59,0x98,0x71,0x5b,0x30,0x16,0xcc,0x6f,0x64,0xb5,0xe1,0x1e,0x31,0x34,0x6d,
969 0x4a,0xe6,0xb0,0x20,0x31,0x81,0xe4,0x0e,0x48,0x7e,0x4c,0xc4,0xfa,0x9c,0x57,0xf9,
970 0xee,0x58,0xfb,0xc2,0x1b,0xd7,0x96,0xdd,0x91,0x0f,0x86,0x40,0xc9,0x45,0x29,0x07,
971 0x65,0x48,0xd1,0x1d,0xf8,0x1c,0x6d,0x1d,0x5d,0xce,0x76,0xce,0x70,0x33,0x4f,0x1d,
972 0xcc,0x4a,0x87,0xd0,0x9a,0xf3,0xb5,0x40,0xf3,0x35,0xcc,0x89,0x26,0x72,0x94,0x53,
973 0x79,0x59,0xbb,0xe6,0xc4,0x24,0x63,0x46,0x83,0x27,0xb7,0xf8,0xff,0x80,0x4c,0x0a,
974 0x98,0xee,0xe7,0x4a,0x73,0x11,0x90,0xbf,0x94,0x1c,0x03,0x91,0x78,0xe8,0x01,0x3a,
975 0xa1,0xf3,0x53,0xea,0x78,0xb1,0x09,0x4e,0xea,0x2d,0xaa,0xb4,0xce,0xce,0xb1,0xc6,
976 0x51,0xb6,0x59,0x52,0x89,0x7e,0xab,0x4c,0xe3,0xd3,0x9b,0x6b,0xa7,0xf2,0xca,0x70,
977 0x53,0x95,0x8a,0x13,0xfc,0xc0,0xa2,0x24,0xd2,0x94,0xb5,0xe5,0x95,0x38,0x01,0x39,
978 0x0a,0x28,0x1d,0x83,0xd1,0x2a,0x03,0xfa,0xf6,0x6e,0x63,0x80,0x17,0x05,0x18,0x33,
979 0x11,0x56,0xe1,0x7e,0x66,0x94,0xbf,0x1b,0x8b,0x11,0xcf,0x41,0xbf,0x71,0xd9,0xa3,
980 0x6f,0xbb,0xf5,0xae,0x43,0x1d,0x2f,0xf1,0x88,0x00,0x72,0xca,0x49,0x83,0x3e,0xe3,
981 0x87,0x5e,0x0f,0x58,0x97,0xaa,0x2b,0x92,0x40,0xdd,0x8b,0x17,0xce,0xd8,0x11,0x05,
982 0xa4,0x03,0x51,0x0b,0xfa,0x35,0x4c,0xde,0x5b,0xda,0x88,0xdd,0x3a,0xe7,0x93,0x60,
983 0xca,0xe2,0x8e,0x84,0xcd,0x5b,0x6d,0xb6,0x5c,0x53,0xbc,0x85,0x75,0x96,0xaa,0x00,
984 0x06,0x19,0x84,0x66,0x4d,0x41,0x89,0xdd,0x84,0x81,0xbe,0xb6,0xa3,0x69,0x71,0xf4,
985 0x3e,0x31,0x89,0xae,0x9e,0x77,0x68,0xff,0x21,0x78,0xa2,0x43,0xc9,0x0e,0x36,0xe0,
986 0xa0,0xb6,0xae,0x40,0xf1,0xf4,0xe3,0xc8,0xa9,0x89,0x80,0x32,0x45,0x07,0x37,0xf1,
987 0x1d,0xc3,0x1e,0x79,0x0b,0x8b,0x1d,0x7d,0xc9,0xd6,0xa2,0x91,0xc8,0xd8,0x05,0xc0,
988 0xc0,0x25,0x27,0x97,0x5f,0x60,0x3f,0xc7,0xc9,0x3e,0xf2,0xac,0x7e,0x4c,0x4b,0x42,
989 0x15,0x85,0x1a,0xe0,0xe1,0xfa,0xf9,0x27,0xaf,0x8d,0x6f,0x90,0x52,0x33,0x6c,0x55,
990 0xa7,0x9d,0x9c,0x0b,0xc1,0xf8,0xe5,0xa9,0xd7,0x9c,0x81,0xce,0x08,0x49,0x9c,0xb1,
991 0x91,0x00,0xdd,0x6f,0xaf,0x17,0xf8,0x01,0xb5,0x9e,0x53,0x2a,0xa0,0xdd,0x47,0x6e,
992 0xb3,0x1b,0xd3,0x9d,0xc1,0x8c,0x07,0x9b,0x78,0x8c,0x2e,0xad,0xbb,0x7d,0xe1,0x0a,
993 0x11,0x35,0xf7,0xfa,0xf4,0x00,0xf3,0xc2,0xa6,0xf1,0x3f,0xa1,0xdc,0xe1,0xc2,0x2a,
994 0x4b,0x22,0x31,0x20,0x45,0x93,0xbb,0x5e,0xfc,0xe5,0xd7,0xcb,0x69,0x1b,0xad,0x3a,
995 0x48,0x59,0x9c,0xc7,0x74,0xbb,0x79,0x56,0xb7,0x73,0x92,0x54,0x49,0xc9,0xbc,0x5d,
996 0xf2,0x74,0xc8,0x63,0xa8,0x9c,0x99,0x67,0x4d,0x75,0x64,0x10,0x46,0xe7,0x0f,0xf1,
997 0xb0,0x4e,0x8b,0x9d,0x4f,0xa7,0x67,0xe9,0xec,0xbf,0x1b,0x0a,0xfd,0xde,0xe4,0xf6,
998 0xcd,0xba,0x12,0xce,0x4e,0xb5,0x29,0xbf,0x59,0x0b,0xf7,0xea,0xc7,0x7c,0xfb,0xe4,
999 0xe6,0x36,0x86,0x52,0x18,0xf6,0xe5,0x14,0xe1,0x92,0x02,0x98,0x08,0x0f,0xbc,0xd0,
1000 0x40,0xf3,0xb1,0x87,0xcc,0x6b,0xee,0xee,0x1a,0x8c,0x40,0x13,0x53,0x9e,0x61,0xb3,
1001 0x17,0x02,0x7e,0x97,0x22,0x90,0x6f,0xf0,0x64,0x75,0x42,0xf4,0xf9,0x8f,0x38,0x46,
1002 0x27,0x5c,0x14,0x82,0x80,0x71,0xe9,0x7d,0xe9,0xc8,0x32,0xb2,0xae,0xbd,0x90,0x28,
1003 0xda,0xc0,0xc1,0x6d,0x06,0x03,0x6c,0x83,0x68,0x3b,0xdf,0xb4,0xb4,0x48,0x04,0x0e,
1004 0xbb,0x6e,0xa8,0xa5,0xa5,0x1b,0x36,0xbe,0xfc,0x40,0xd3,0x97,0xc3,0x62,0xb9,0x34,
1005 0x94,0xbf,0x01,0xfb,0x21,0xae,0xbb,0xd9,0xdd,0x0d,0xe0,0xf4,0xce,0x25,0x9a,0x7c,
1006 0xc4,0x10,0xfc,0xac,0x53,0x1d,0x11,0xdc,0x5c,0x4c,0x6e,0x65,0xb3,0x9c,0xca,0x76,
1007 0x3d,0x5d,0x2d,0x21,0x64,0xa6,0x3c,0xc1,0xa1,0x35,0xe7,0x38,0x8b,0x39,0x9f,0x7f,
1008 0x93,0x68,0x6f,0xeb,0x96,0x4f,0x7c,0xd3,0x49,0xbe,0x65,0xdb,0x82,0x91,0x2a,0xb4,
1009 0x62,0x38,0xdd,0x73,0xa7,0x7f,0x66,0x54,0xfa,0x92,0x65,0xbf,0x71,0xc6,0x62,0x38,
1010 0x96,0xe2,0xf4,0x16,0xc6,0xf7,0x7e,0x9d,0x7a,0x4f,0x35,0x5f,0x0e,0x29,0xe6,0x38,
1011 0x7b,0x05,0x02,0x61,0xfb,0x16,0xb4,0x43,0xe9,0xb1,0x74,0x3d,0x50,0xe3,0x51,0x5c,
1012 0x54,0x5e,0x3e,0xe0,0xb1,0xfe,0x20,0x2d,0xe0,0x05,0x25,0x2f,0x1f,0x9a,0x25,0xe9,
1013 0xec,0xb6,0xb8,0x9a,0xe9,0xff,0x3a,0x7a,0xc8,0x53,0xfd,0xc4,0x61,0xb1,0xa1,0x22,
1014 0xc6,0x85,0x7a,0x11,0x07,0x84,0xe9,0x58,0x15,0x74,0x33,0x08,0x1f,0x59,0xe9,0x0d,
1015 0x7f,0x7e,0x38,0xd9,0x77,0x22,0x46,0xb5,0xfc,0xd5,0x3b,0x1d,0x47,0x7a,0x4a,0x16,
1016 0x35,0xa8,0x67,0x99,0x6d,0x72,0x66,0x0d,0xd4,0xb3,0x3b,0xdf,0xb8,0x9f,0x7f,0x59,
1017 0x37,0x97,0x65,0xdf,0x79,0x0c,0x15,0xe3,0x14,0x99,0xc0,0x1a,0xcc,0x9a,0x98,0x6a,
1018 0xb7,0x59,0x35,0x21,0x31,0x3e,0xf4,0xa2,0xce,0xc4,0xca,0x60,0xf8,0xa0,0x43,0xb6,
1019 0xbe,0x8a,0x0a,0x95,0xea,0xe7,0xa0,0xdb,0x4f,0x36,0x22,0xf8,0xb6,0x60,0xff,0x15,
1020 0x69,0x45,0x84,0x53,0xad,0x48,0x00,0x0e,0x20,0xb3,0x62,0x07,0xbd,0x02,0x46,0x19,
1021 0xf6,0x3d,0xb8,0x55,0x4b,0x5f,0xac,0x3a,0x6a,0x86,0xcf,0x07,0x79,0x30,0x82,0x05,
1022 0x7e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x82,0x05,0x6f,
1023 0x04,0x82,0x05,0x6b,0x30,0x82,0x05,0x67,0x30,0x82,0x05,0x63,0x06,0x0b,0x2a,0x86,
1024 0x48,0x86,0xf7,0x0d,0x01,0x0c,0x0a,0x01,0x02,0xa0,0x82,0x04,0xee,0x30,0x82,0x04,
1025 0xea,0x30,0x1c,0x06,0x0a,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x0c,0x01,0x03,0x30,
1026 0x0e,0x04,0x08,0xd3,0x22,0x2a,0xd2,0xd9,0xd0,0xd6,0xd3,0x02,0x02,0x08,0x00,0x04,
1027 0x82,0x04,0xc8,0x7b,0x88,0x0e,0x83,0x90,0x25,0x3f,0x51,0xab,0x13,0xf1,0x35,0x1f,
1028 0xec,0x56,0xcb,0xfc,0x31,0x6b,0xd1,0x1a,0x6c,0x35,0x51,0x31,0xb7,0x27,0x2e,0xe6,
1029 0x8c,0x75,0x7d,0xa6,0x58,0xfd,0x08,0x0b,0xe4,0x39,0x63,0xc6,0x3e,0x2d,0xee,0x2b,
1030 0xe5,0x58,0x90,0x48,0xb5,0x57,0x38,0x97,0x48,0xf3,0x2c,0xac,0xf1,0xf8,0x10,0x9c,
1031 0x56,0x02,0xc7,0x9d,0x7f,0x9e,0xe0,0x9c,0x96,0xe7,0x0c,0x9f,0x54,0xab,0x9f,0x26,
1032 0x17,0xac,0x86,0x88,0x5e,0x4a,0x9c,0xce,0xea,0xc8,0x48,0x83,0x0c,0x2e,0xf0,0xa0,
1033 0x6c,0x96,0x07,0x26,0x47,0x63,0xc1,0xac,0x27,0xd1,0x1a,0x25,0x88,0x43,0x8e,0x9d,
1034 0xe0,0x5f,0x80,0xd9,0xd1,0x1a,0x86,0x92,0x12,0x80,0xe1,0x99,0x13,0xc3,0xab,0x53,
1035 0x97,0xbe,0x51,0x17,0xc4,0x5a,0x9d,0xc0,0xcd,0xe4,0xc5,0xd6,0x44,0x56,0xaa,0x8d,
1036 0x5b,0x3d,0xc8,0x66,0xaf,0x6c,0xd2,0x96,0xc6,0x83,0x57,0x7a,0x0e,0x66,0x68,0xd6,
1037 0x30,0xf0,0xaa,0xde,0x13,0x92,0x5e,0x21,0x2c,0x36,0x96,0x77,0x1f,0xd0,0xaa,0x4b,
1038 0x14,0x9f,0x9f,0xe5,0xa4,0x3f,0xbf,0x7a,0x9b,0x38,0xff,0x91,0x1d,0x0d,0xd4,0x32,
1039 0x34,0x2b,0x3f,0xd8,0xfb,0x09,0x71,0xdf,0x1b,0x61,0xa3,0x36,0x81,0xaa,0x49,0xa3,
1040 0xe4,0x5c,0xc4,0x8d,0xc5,0xab,0xc0,0x43,0xbe,0xc1,0x41,0xa2,0xcc,0x28,0x36,0x65,
1041 0xa6,0xb6,0x73,0x96,0x6a,0x5f,0x1a,0xd9,0xb8,0x48,0x49,0x7b,0x12,0xda,0x2a,0xdb,
1042 0xaa,0xaf,0x46,0x8b,0x39,0x7e,0xa7,0x78,0x88,0x15,0x95,0x32,0x13,0x76,0xbb,0x2d,
1043 0xf5,0xd5,0x41,0x6a,0x9b,0xb8,0xe6,0x6d,0x43,0xa6,0xc3,0x53,0xb7,0xc5,0x68,0x9d,
1044 0xa9,0x84,0x30,0x42,0x59,0x33,0x81,0x79,0x22,0x91,0x1e,0x34,0x31,0x9b,0xd4,0xf3,
1045 0x2a,0xda,0xe2,0xa3,0x95,0x7a,0x2a,0x9c,0x67,0x57,0xee,0x2b,0x89,0xfc,0x64,0x67,
1046 0x00,0x98,0x21,0x63,0xc7,0x19,0x95,0x69,0x9b,0x42,0x73,0x5c,0x68,0x59,0xfc,0x64,
1047 0xe5,0x22,0x57,0x54,0x58,0x06,0xff,0xa3,0x87,0x7d,0x05,0xc8,0xc4,0xfd,0xc7,0x29,
1048 0x1b,0x1d,0x88,0x0b,0x08,0x96,0x94,0x9b,0xd8,0xee,0x47,0x99,0x06,0xfa,0x64,0x67,
1049 0xfd,0xb0,0xb1,0xa1,0xf5,0x26,0x7e,0xb1,0x46,0xb1,0x0c,0x82,0x52,0x5f,0xc5,0x94,
1050 0x23,0x75,0xff,0xb3,0x42,0x18,0xa2,0x9f,0x65,0xfb,0x06,0xb0,0x8a,0x29,0xc1,0x6e,
1051 0x84,0xd9,0xd4,0x39,0x77,0x02,0x47,0xe3,0x5f,0xf2,0xb4,0x84,0xc0,0x75,0x48,0x4b,
1052 0x3a,0xef,0x48,0x2e,0x8d,0xa1,0xe5,0xc6,0x86,0x44,0x00,0xd9,0x4d,0x73,0xed,0x68,
1053 0x8c,0x91,0x56,0x3e,0x2c,0x18,0xd0,0x58,0xd8,0x04,0x15,0xe0,0xd8,0xa8,0xe6,0x46,
1054 0x36,0x54,0xc5,0x8c,0x2b,0x98,0xa5,0x01,0x73,0xf0,0x67,0x95,0x41,0x4e,0xa3,0xd6,
1055 0x8d,0x24,0xc4,0xc3,0x8f,0x28,0x7c,0x76,0x76,0x84,0x6c,0x95,0x94,0x22,0xde,0xe2,
1056 0x9d,0xcb,0x37,0xb6,0x97,0x6b,0xf3,0x58,0x1d,0x5a,0x98,0x88,0xac,0xd9,0xb1,0x59,
1057 0x16,0x11,0xd8,0x0b,0x68,0xce,0xdf,0x4b,0x1a,0x28,0x3c,0xeb,0x14,0xb2,0x28,0xa7,
1058 0xad,0x54,0x55,0xa1,0x6b,0x50,0x86,0x55,0x00,0xae,0xf6,0xdf,0x6b,0xb3,0x42,0xb3,
1059 0x7b,0xbb,0x0d,0x91,0x14,0xdb,0x82,0xea,0xe9,0x08,0x9f,0xf6,0x6f,0xd0,0x10,0xd7,
1060 0x83,0x1e,0xfc,0x5e,0x58,0xca,0x01,0xdd,0xb4,0xc8,0xbe,0x80,0xe3,0x07,0x71,0x0a,
1061 0x74,0x01,0xd4,0xf1,0x50,0xe1,0x51,0x22,0xb1,0x43,0x98,0xf1,0x5e,0xdd,0xb4,0x65,
1062 0x5a,0x18,0x0c,0x8b,0x1b,0x4e,0xe1,0xce,0xb1,0x0e,0x81,0xda,0x6b,0x98,0xc4,0xcb,
1063 0xd9,0xd2,0xb2,0x1e,0xea,0xac,0x0c,0x08,0x86,0xa4,0x60,0xab,0x84,0x50,0x13,0xf8,
1064 0x48,0xfb,0x64,0xf3,0x33,0x88,0x83,0x72,0x22,0xe8,0x6a,0x43,0xd3,0xb4,0xc7,0xd2,
1065 0x04,0xed,0x07,0x75,0x26,0x96,0x2d,0x84,0xb9,0x10,0x02,0xd2,0xda,0xc8,0xc8,0x0b,
1066 0x95,0xe3,0x69,0x1e,0x57,0x16,0x7a,0xb5,0x1c,0xe7,0x46,0x89,0xfc,0xed,0x49,0x69,
1067 0x47,0xb8,0x07,0xe4,0xcb,0xd1,0x52,0xd6,0x8c,0x32,0xaa,0x91,0x8d,0x45,0x19,0xf1,
1068 0x54,0x23,0x3c,0x5f,0xcc,0xc7,0x60,0xfc,0x89,0x00,0x9a,0xa3,0xc2,0xf0,0x48,0xda,
1069 0xbf,0xe4,0xfd,0x78,0x3b,0x6c,0x2d,0x34,0x91,0x6b,0x0d,0x21,0xb4,0xba,0xe8,0x6d,
1070 0x80,0xbc,0xfb,0x91,0xcb,0xce,0x77,0x01,0x4e,0xfe,0x7b,0xf2,0x08,0x78,0x2e,0x3f,
1071 0x16,0xd4,0xfd,0xf0,0x76,0x68,0xce,0x43,0xdc,0xb2,0xe2,0x82,0x64,0x8f,0xc8,0x71,
1072 0x0f,0x6e,0xc6,0x3b,0x4a,0x6b,0x6a,0xd7,0xf6,0x21,0x46,0xcd,0x05,0xce,0x19,0xab,
1073 0x28,0x28,0x55,0x19,0x1d,0x07,0xaf,0x38,0xd9,0x9c,0xdf,0xe8,0x91,0x68,0x16,0xdd,
1074 0x36,0x19,0x71,0x46,0x86,0x08,0x0a,0x08,0x34,0xc5,0x3b,0x53,0xaa,0x35,0x27,0x6e,
1075 0xe4,0xf3,0xa1,0xd6,0x04,0x78,0xf9,0x63,0xec,0x1e,0xfe,0x30,0x38,0xb3,0xe7,0xd8,
1076 0x27,0x9f,0x98,0xd5,0xb9,0x4d,0xb9,0x80,0x4f,0xb0,0x81,0xc6,0xaa,0xc2,0xe6,0xbf,
1077 0x98,0x63,0x05,0xc6,0xab,0x4e,0xc8,0x7e,0xf4,0x37,0x68,0xad,0x63,0x08,0x6e,0x8f,
1078 0xe5,0xd9,0x62,0x43,0xa3,0x0d,0x61,0x84,0x41,0x02,0xd0,0xc6,0x33,0x19,0x76,0xb8,
1079 0x31,0xb1,0x27,0x2f,0x81,0x40,0x71,0x35,0x3c,0xf6,0xf2,0xc7,0x9b,0x85,0x9c,0x2e,
1080 0xa0,0xf6,0xd2,0x3a,0xd9,0x7e,0xdd,0x82,0x56,0xf4,0x61,0x97,0x79,0xdb,0x27,0x5d,
1081 0xa7,0x5b,0x8d,0x01,0x9d,0x68,0x9b,0x3a,0x4e,0xe1,0x3c,0xaf,0x61,0x0f,0xbf,0xfa,
1082 0x61,0x12,0x2f,0xde,0x7a,0x71,0x0a,0xdd,0x6e,0x29,0x11,0x8e,0xa4,0x93,0x31,0x85,
1083 0x2a,0x31,0xa8,0xd7,0x3f,0xfb,0xf4,0xd2,0xd4,0x7f,0x0c,0xb2,0x8d,0x63,0x25,0x47,
1084 0x18,0x04,0x00,0x28,0x90,0xd3,0xc0,0x7e,0xca,0xfa,0x0d,0xc4,0xab,0xd4,0x7a,0x17,
1085 0xb7,0xdc,0xce,0x7d,0xc2,0xe8,0x5b,0x68,0x7c,0xa9,0x3c,0xac,0x4e,0x2c,0xde,0x0c,
1086 0x4a,0x09,0x09,0x03,0x77,0x12,0xb9,0x31,0xc9,0x0d,0x6e,0x2b,0xac,0x96,0x7b,0xb0,
1087 0x3d,0x37,0x03,0x32,0xc6,0xe1,0x64,0x16,0xc1,0x1b,0xfa,0xa3,0x32,0xe9,0xea,0x25,
1088 0x0c,0xa1,0xbf,0xae,0xaa,0xba,0xbd,0x24,0xba,0x9d,0x5f,0x15,0x20,0x59,0x2d,0xe5,
1089 0x09,0xe6,0x71,0x70,0xcd,0xf5,0x44,0x12,0xcf,0x17,0x8b,0x33,0x4b,0x67,0x86,0x53,
1090 0xd3,0x66,0x80,0x2e,0xfb,0x6b,0x95,0x38,0x35,0x2d,0x39,0xb8,0x19,0xb7,0x01,0xe0,
1091 0xe2,0x7d,0x29,0xd3,0x89,0xc7,0xc9,0x4f,0xb4,0xf9,0x48,0x20,0x6a,0x40,0xd3,0x71,
1092 0x28,0xf4,0xdf,0x3a,0xff,0xf0,0xd1,0x7a,0x78,0xbd,0x92,0xe4,0xa2,0x05,0x47,0xf5,
1093 0xfa,0x25,0x4f,0x22,0x3f,0x8f,0x85,0x72,0xaa,0x0f,0xfa,0x21,0x84,0x63,0xbc,0xb6,
1094 0xe0,0x49,0x1e,0xdf,0x0a,0xee,0x4b,0xa8,0x96,0xbf,0x2f,0xa7,0x31,0x64,0xc3,0xa1,
1095 0x19,0xe1,0x2b,0x69,0xbf,0x0f,0xcc,0x76,0x49,0x9f,0xdd,0x4e,0xf0,0x77,0xf0,0xae,
1096 0x83,0x20,0xe2,0xd6,0x21,0x1a,0x3a,0x1a,0xb4,0xbf,0x57,0x02,0x9c,0xf6,0xb1,0x47,
1097 0x83,0x59,0x0c,0x43,0xce,0x9a,0x3d,0xb3,0x9b,0x9c,0xd2,0x30,0xcd,0x40,0x58,0xfe,
1098 0xec,0xa9,0x59,0xa8,0xf6,0x28,0x31,0xbf,0xc3,0xfb,0xad,0x37,0x07,0xd4,0x34,0xe7,
1099 0x58,0xfa,0xca,0xe7,0xe3,0xbb,0x3d,0xd8,0xf6,0xd7,0x9c,0xf5,0x6f,0xc0,0xbd,0x9e,
1100 0x3a,0x91,0x30,0x7c,0xe4,0xff,0x8d,0xbe,0x85,0x91,0x27,0x92,0x51,0xdc,0xd6,0x66,
1101 0x7e,0x5a,0xfb,0xf7,0xbe,0x34,0xce,0x5e,0xa4,0x50,0xf1,0x6d,0xc0,0x32,0x3b,0xaa,
1102 0x8c,0x52,0x25,0xcc,0x75,0x26,0x2b,0xa8,0x2f,0x6f,0x02,0x81,0x18,0x07,0x5f,0xbe,
1103 0xc3,0xed,0xa3,0x93,0x73,0xc9,0xd4,0x79,0xec,0x34,0x78,0x31,0x62,0x30,0x3b,0x06,
1104 0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x09,0x14,0x31,0x2e,0x1e,0x2c,0x00,0x54,
1105 0x00,0x65,0x00,0x73,0x00,0x74,0x00,0x20,0x00,0x49,0x00,0x64,0x00,0x65,0x00,0x6e,
1106 0x00,0x74,0x00,0x69,0x00,0x74,0x00,0x79,0x00,0x20,0x00,0x53,0x00,0x53,0x00,0x4c,
1107 0x00,0x20,0x00,0x32,0x00,0x30,0x00,0x30,0x00,0x37,0x30,0x23,0x06,0x09,0x2a,0x86,
1108 0x48,0x86,0xf7,0x0d,0x01,0x09,0x15,0x31,0x16,0x04,0x14,0xd0,0xcb,0xd6,0x5c,0xe1,
1109 0x73,0x7a,0xb8,0xa8,0x2a,0xf8,0xc9,0xe6,0xdc,0xbb,0xc2,0xec,0x00,0x2e,0x6a,0x30,
1110 0x30,0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14,
1111 0x47,0x2e,0x9e,0xca,0x71,0x3b,0x36,0xcf,0x34,0x59,0x7e,0x0a,0x6e,0xe0,0xeb,0x79,
1112 0xcb,0x82,0x47,0x76,0x04,0x08,0xff,0xe9,0xf7,0xee,0x2f,0x48,0xcc,0x24,0x02,0x01,
1113 0x01
1114 };
1115
1116
1117 static int quiet = 0;
1118 static int debug = 0;
1119 static int verbose = 0;
1120
1121 #define MAXNAMELEN MAXPATHLEN
1122 #define MAXITEMS INT32_MAX
1123
1124 #pragma mark -- Utility Functions --
1125
1126
1127 void PrintTestResult(char *testStr, OSStatus status, OSStatus expected)
1128 {
1129 if (verbose) {
1130 fprintf(stdout, "%s: %s (result=%d, expected=%d)\n", testStr,
1131 (status==expected) ? "OK" : "FAILED",
1132 (int)status, (int)expected);
1133 }
1134 if (debug) {
1135 fprintf(stdout, "\n");
1136 }
1137 fflush(stdout);
1138 }
1139
1140
1141 void PrintStringToMatch(CFStringRef nameStr)
1142 {
1143 char *buf = (char*)malloc(MAXNAMELEN);
1144 if (buf) {
1145 if (CFStringGetCString(nameStr, buf, (CFIndex)MAXNAMELEN, kCFStringEncodingUTF8)) {
1146 fprintf(stdout, "### String to match is \"%s\"\n", buf);
1147 fflush(stdout);
1148 }
1149 free(buf);
1150 }
1151 }
1152
1153
1154 void PrintSecCertificate(SecCertificateRef certificate)
1155 {
1156 CFStringRef nameStr;
1157 OSStatus status = SecCertificateCopyCommonName(certificate, &nameStr);
1158 if (status) {
1159 fprintf(stderr, "### SecCertificateCopyCommonName error %d\n", (int)status);
1160 }
1161 else {
1162 char *buf = (char*)malloc(MAXNAMELEN);
1163 if (buf) {
1164 if (CFStringGetCString(nameStr, buf, (CFIndex)MAXNAMELEN, kCFStringEncodingUTF8)) {
1165 fprintf(stdout, "### Found certificate name: \"%s\"\n", buf);
1166 }
1167 free(buf);
1168 }
1169 CFRelease(nameStr);
1170 }
1171 }
1172
1173
1174 void PrintSecIdentity(SecIdentityRef identity)
1175 {
1176 SecCertificateRef certRef;
1177 OSStatus status = SecIdentityCopyCertificate(identity, &certRef);
1178 if (status) {
1179 fprintf(stderr, "### SecIdentityCopyCertificate error %d\n", (int)status);
1180 }
1181 else {
1182 PrintSecCertificate(certRef);
1183 CFRelease(certRef);
1184 }
1185 }
1186
1187
1188 void PrintCFStringWithFormat(const char *formatStr, CFStringRef inStr)
1189 {
1190 char *buf = (char*)malloc(MAXNAMELEN);
1191 if (buf) {
1192 if (CFStringGetCString(inStr, buf, (CFIndex)MAXNAMELEN, kCFStringEncodingUTF8)) {
1193 fprintf(stdout, formatStr, buf);
1194 fflush(stdout);
1195 }
1196 free(buf);
1197 }
1198 }
1199
1200
1201 void PrintCFThing(CFTypeRef thing)
1202 {
1203 fprintf(stderr, "### Results: %p\n", (void*)thing);
1204
1205 CFTypeID thingID = (thing) ? CFGetTypeID(thing) : 0;
1206 if (thingID == SecCertificateGetTypeID()) {
1207 // print a SecCertificateRef
1208 PrintSecCertificate((SecCertificateRef)thing);
1209 }
1210 else if (thingID == SecIdentityGetTypeID()) {
1211 // print a SecIdentityRef
1212 PrintSecIdentity((SecIdentityRef)thing);
1213 }
1214 else if (thingID == SecKeychainItemGetTypeID() ||
1215 thingID == SecIdentityGetTypeID() ||
1216 thingID == CFDictionaryGetTypeID() ||
1217 thingID == CFArrayGetTypeID() ||
1218 thingID == CFStringGetTypeID() ||
1219 thingID == CFDataGetTypeID()) {
1220 CFShow(thing);
1221 }
1222 else {
1223 fprintf(stderr, "### ERROR: result is not a supported CFType! (%ld)\n",
1224 thingID);
1225 }
1226 }
1227
1228 //%%% FIXME need to break this up into separate functions
1229 int TestAddItems()
1230 {
1231 SecCertificateRef certs[5];
1232 SecKeychainRef keychain;
1233 CFDataRef tmpData;
1234 OSStatus status;
1235
1236 #if AUTO_TEST
1237 /* the regression suite environment does not have a keychain; must create one */
1238 status = SecKeychainCreate("SecItemTest.keychain", 4, "test", FALSE, NULL, &keychain);
1239 #else
1240 status = SecKeychainCopyDefault(&keychain);
1241 #endif
1242 if (status) {
1243 fprintf(stderr, "Unable to get default keychain: error %d\n", (int)status);
1244 goto error_exit;
1245 }
1246
1247 /* add test leaf */
1248 tmpData = CFDataCreateWithBytesNoCopy(NULL, LEAF_CERT, sizeof(LEAF_CERT), kCFAllocatorNull);
1249 certs[0] = SecCertificateCreateWithData(NULL, tmpData);
1250 CFRelease(tmpData);
1251 // will add this below using SecItemAdd instead of SecCertificateAddToKeychain
1252 #if 0
1253 status = SecCertificateAddToKeychain(certs[0], keychain);
1254 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1255 fprintf(stderr, "Unable to add test leaf certificate: error %d\n", (int)status);
1256 goto error_exit;
1257 }
1258 #endif
1259 /* add test intermediate */
1260 tmpData = CFDataCreateWithBytesNoCopy(NULL, INTERMEDIATE_CERT, sizeof(INTERMEDIATE_CERT), kCFAllocatorNull);
1261 certs[1] = SecCertificateCreateWithData(NULL, tmpData);
1262 CFRelease(tmpData);
1263 // will add this below using SecItemAdd instead of SecCertificateAddToKeychain
1264 #if 0
1265 status = SecCertificateAddToKeychain(certs[1], keychain);
1266 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1267 fprintf(stderr, "Unable to add test intermediate certificate: error %d\n", (int)status);
1268 goto error_exit;
1269 }
1270 #endif
1271 /* add test root */
1272 tmpData = CFDataCreateWithBytesNoCopy(NULL, ROOT_CERT, sizeof(ROOT_CERT), kCFAllocatorNull);
1273 certs[2] = SecCertificateCreateWithData(NULL, tmpData);
1274 CFRelease(tmpData);
1275 // will add this below using SecItemAdd instead of SecCertificateAddToKeychain
1276 #if 0
1277 status = SecCertificateAddToKeychain(certs[2], keychain);
1278 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1279 fprintf(stderr, "Unable to add test root certificate: error %d\n", (int)status);
1280 goto error_exit;
1281 }
1282 #endif
1283
1284 /* use SecItemAdd to add an array containing certs 1-3 */
1285 CFArrayRef certArray = CFArrayCreate(NULL, (const void**) certs, 3, &kCFTypeArrayCallBacks);
1286 CFMutableDictionaryRef attrs = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1287 CFDictionaryAddValue(attrs, kSecClass, kSecClassCertificate); // we are adding certificates
1288 CFDictionaryAddValue(attrs, kSecUseItemList, certArray); // add these items (to default keychain, since we aren't specifying one)
1289 status = SecItemAdd(attrs, NULL);
1290 CFRelease(attrs);
1291 CFRelease(certArray);
1292 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1293 fprintf(stderr, "Unable to add 3 test certificates: error %d\n", (int)status);
1294 goto error_exit;
1295 }
1296
1297
1298 /* add test cert for S/MIME policy (encrypt only, no sign) */
1299 tmpData = CFDataCreateWithBytesNoCopy(NULL, Test_smime_encryptonly, sizeof(Test_smime_encryptonly), kCFAllocatorNull);
1300 certs[3] = SecCertificateCreateWithData(NULL, tmpData);
1301 CFRelease(tmpData);
1302 status = SecCertificateAddToKeychain(certs[3], keychain);
1303 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1304 fprintf(stderr, "Unable to add test S/MIME certificate: error %d\n", (int)status);
1305 goto error_exit;
1306 }
1307
1308 /* add test cert for Code Signing policy */
1309 tmpData = CFDataCreateWithBytesNoCopy(NULL, Test_codesign, sizeof(Test_codesign), kCFAllocatorNull);
1310 certs[4] = SecCertificateCreateWithData(NULL, tmpData);
1311 CFRelease(tmpData);
1312 status = SecCertificateAddToKeychain(certs[4], keychain);
1313 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1314 fprintf(stderr, "Unable to add test Code Signing certificate: error %d\n", (int)status);
1315 goto error_exit;
1316 }
1317
1318 /* import test SSL identity */
1319 {
1320 CFDataRef p12DataRef = CFDataCreateWithBytesNoCopy(NULL, Test_p12, (CFIndex)sizeof(Test_p12), kCFAllocatorNull);
1321 SecExternalFormat format = kSecFormatPKCS12;
1322 SecExternalItemType itemType = kSecItemTypeAggregate;
1323 SecItemImportExportFlags flags = 0;
1324 #if 0
1325 /* deprecated method, using CDSA constants */
1326 SecKeyImportExportParameters keyParams = {
1327 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1328 0, // SecKeyImportExportFlags flags
1329 CFSTR("test"), // CFTypeRef passphrase
1330 CFSTR("title"), // CFStringRef alertTitle
1331 CFSTR("pw:"), // CFStringRef alertPrompt
1332 NULL, // SecAccessRef accessRef (unspecified, use default)
1333 CSSM_KEYUSE_SIGN, // CSSM_KEYUSE keyUsage (0=unspecified)
1334 CSSM_KEYATTR_PERMANENT // CSSM_KEYATTR_FLAGS keyAttributes
1335 };
1336 status = SecKeychainItemImport(p12DataRef,
1337 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1338 #else
1339 CFTypeRef keyUsages[1] = { kSecAttrCanSign };
1340 CFArrayRef keyUsagesArray = CFArrayCreate(NULL, keyUsages, 1, &kCFTypeArrayCallBacks);
1341 CFTypeRef keyAttrs[1] = { kSecAttrIsPermanent };
1342 CFArrayRef keyAttrsArray = CFArrayCreate(NULL, keyAttrs, 1, &kCFTypeArrayCallBacks);
1343 SecItemImportExportKeyParameters keyParams = {
1344 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1345 0, // SecKeyImportExportFlags flags
1346 CFSTR("test"), // CFTypeRef passphrase
1347 CFSTR("title"), // CFStringRef alertTitle
1348 CFSTR("pw:"), // CFStringRef alertPrompt
1349 NULL, // SecAccessRef accessRef (unspecified, use default)
1350 keyUsagesArray, // CFArrayRef keyUsages
1351 keyAttrsArray // CFArrayRef keyAttributes
1352 };
1353 status = SecItemImport(p12DataRef,
1354 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1355 CFRelease(keyUsagesArray);
1356 CFRelease(keyAttrsArray);
1357 #endif
1358 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1359 fprintf(stderr, "Unable to import test SSL identity: error %d\n", (int)status);
1360 goto error_exit;
1361 }
1362 }
1363
1364 /* import test S/MIME signing identity */
1365 {
1366 CFDataRef p12DataRef = CFDataCreateWithBytesNoCopy(NULL, Test_smime_signonly_p12, (CFIndex)sizeof(Test_smime_signonly_p12), kCFAllocatorNull);
1367 SecExternalFormat format = kSecFormatPKCS12;
1368 SecExternalItemType itemType = kSecItemTypeAggregate;
1369 SecItemImportExportFlags flags = 0;
1370 #if 0
1371 /* deprecated method, using CDSA constants */
1372 SecKeyImportExportParameters keyParams = {
1373 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1374 0, // SecKeyImportExportFlags flags
1375 CFSTR("test"), // CFTypeRef passphrase
1376 CFSTR("title"), // CFStringRef alertTitle
1377 CFSTR("pw:"), // CFStringRef alertPrompt
1378 NULL, // SecAccessRef accessRef (unspecified, use default)
1379 CSSM_KEYUSE_SIGN, // CSSM_KEYUSE keyUsage (0=unspecified)
1380 CSSM_KEYATTR_PERMANENT // CSSM_KEYATTR_FLAGS keyAttributes
1381 };
1382 status = SecKeychainItemImport(p12DataRef,
1383 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1384 #else
1385 CFTypeRef keyUsages[1] = { kSecAttrCanSign };
1386 CFArrayRef keyUsagesArray = CFArrayCreate(NULL, keyUsages, 1, &kCFTypeArrayCallBacks);
1387 CFTypeRef keyAttrs[1] = { kSecAttrIsPermanent };
1388 CFArrayRef keyAttrsArray = CFArrayCreate(NULL, keyAttrs, 1, &kCFTypeArrayCallBacks);
1389 SecItemImportExportKeyParameters keyParams = {
1390 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1391 0, // SecKeyImportExportFlags flags
1392 CFSTR("test"), // CFTypeRef passphrase
1393 CFSTR("title"), // CFStringRef alertTitle
1394 CFSTR("pw:"), // CFStringRef alertPrompt
1395 NULL, // SecAccessRef accessRef (unspecified, use default)
1396 keyUsagesArray, // CFArrayRef keyUsages
1397 keyAttrsArray // CFArrayRef keyAttributes
1398 };
1399 status = SecItemImport(p12DataRef,
1400 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1401 CFRelease(keyUsagesArray);
1402 CFRelease(keyAttrsArray);
1403 #endif
1404 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1405 fprintf(stderr, "Unable to import test S/MIME identity: error %d\n", (int)status);
1406 goto error_exit;
1407 }
1408 }
1409
1410 /* import expired SSL identity */
1411 {
1412 CFDataRef p12DataRef = CFDataCreateWithBytesNoCopy(NULL, TestIDSSL2007_p12, (CFIndex)sizeof(TestIDSSL2007_p12), kCFAllocatorNull);
1413 SecExternalFormat format = kSecFormatPKCS12;
1414 SecExternalItemType itemType = kSecItemTypeAggregate;
1415 SecItemImportExportFlags flags = 0;
1416 CFTypeRef keyUsages[1] = { kSecAttrCanSign };
1417 CFArrayRef keyUsagesArray = CFArrayCreate(NULL, keyUsages, 1, &kCFTypeArrayCallBacks);
1418 CFTypeRef keyAttrs[1] = { kSecAttrIsPermanent };
1419 CFArrayRef keyAttrsArray = CFArrayCreate(NULL, keyAttrs, 1, &kCFTypeArrayCallBacks);
1420 SecItemImportExportKeyParameters keyParams = {
1421 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1422 0, // SecKeyImportExportFlags flags
1423 CFSTR("test"), // CFTypeRef passphrase
1424 CFSTR("title"), // CFStringRef alertTitle
1425 CFSTR("pw:"), // CFStringRef alertPrompt
1426 NULL, // SecAccessRef accessRef (unspecified, use default)
1427 keyUsagesArray, // CFArrayRef keyUsages
1428 keyAttrsArray // CFArrayRef keyAttributes
1429 };
1430 status = SecItemImport(p12DataRef,
1431 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1432 CFRelease(keyUsagesArray);
1433 CFRelease(keyAttrsArray);
1434 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1435 fprintf(stderr, "Unable to import TestIDSSL2007_p12 identity: error %d\n", (int)status);
1436 goto error_exit;
1437 }
1438 }
1439
1440 /* import expired S/MIME identity */
1441 {
1442 CFDataRef p12DataRef = CFDataCreateWithBytesNoCopy(NULL, TestIDSMIME2007_p12, (CFIndex)sizeof(TestIDSMIME2007_p12), kCFAllocatorNull);
1443 SecExternalFormat format = kSecFormatPKCS12;
1444 SecExternalItemType itemType = kSecItemTypeAggregate;
1445 SecItemImportExportFlags flags = 0;
1446 CFTypeRef keyUsages[1] = { kSecAttrCanSign };
1447 CFArrayRef keyUsagesArray = CFArrayCreate(NULL, keyUsages, 1, &kCFTypeArrayCallBacks);
1448 CFTypeRef keyAttrs[1] = { kSecAttrIsPermanent };
1449 CFArrayRef keyAttrsArray = CFArrayCreate(NULL, keyAttrs, 1, &kCFTypeArrayCallBacks);
1450 SecItemImportExportKeyParameters keyParams = {
1451 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
1452 0, // SecKeyImportExportFlags flags
1453 CFSTR("test"), // CFTypeRef passphrase
1454 CFSTR("title"), // CFStringRef alertTitle
1455 CFSTR("pw:"), // CFStringRef alertPrompt
1456 NULL, // SecAccessRef accessRef (unspecified, use default)
1457 keyUsagesArray, // CFArrayRef keyUsages
1458 keyAttrsArray // CFArrayRef keyAttributes
1459 };
1460 status = SecItemImport(p12DataRef,
1461 NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
1462 CFRelease(keyUsagesArray);
1463 CFRelease(keyAttrsArray);
1464 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1465 fprintf(stderr, "Unable to import TestIDSMIME2007_p12 identity: error %d\n", (int)status);
1466 goto error_exit;
1467 }
1468 }
1469
1470 /* add generic password items */
1471 status = SecKeychainAddGenericPassword(keychain,
1472 strlen("Test Service 42"), "Test Service 42",
1473 strlen("nobody"), "nobody",
1474 strlen("weakpass"), "weakpass",
1475 NULL);
1476 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1477 fprintf(stderr, "Unable to add \"Test Service 42\" generic password: error %d\n", (int)status);
1478 goto error_exit;
1479 }
1480 status = SecKeychainAddGenericPassword(keychain,
1481 strlen("Test Service 69"), "Test Service 69",
1482 strlen("nobody"), "nobody",
1483 strlen("weakpass"), "weakpass",
1484 NULL);
1485 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1486 fprintf(stderr, "Unable to add \"Test Service 69\" generic password: error %d\n", (int)status);
1487 goto error_exit;
1488 }
1489
1490 /* add internet password items */
1491 status = SecKeychainAddInternetPassword(keychain,
1492 strlen("test1.subdomain.apple.com"), "test1.subdomain.apple.com",
1493 0, NULL,
1494 strlen("nobody"), "nobody",
1495 0, NULL,
1496 80, kSecProtocolTypeHTTP, kSecAuthenticationTypeDefault,
1497 strlen("weakpass"), "weakpass",
1498 NULL);
1499 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1500 fprintf(stderr, "Unable to add \"test1.subdomain.apple.com\" internet password: error %d\n", (int)status);
1501 goto error_exit;
1502 }
1503 status = SecKeychainAddInternetPassword(keychain,
1504 strlen("test2.subdomain.apple.com"), "test2.subdomain.apple.com",
1505 0, NULL,
1506 strlen("nobody"), "nobody",
1507 0, NULL,
1508 443, kSecProtocolTypeHTTPS, kSecAuthenticationTypeDefault,
1509 strlen("weakpass"), "weakpass",
1510 NULL);
1511 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1512 fprintf(stderr, "Unable to add \"test2.subdomain.apple.com\" internet password: error %d\n", (int)status);
1513 goto error_exit;
1514 }
1515
1516 /* add a Mail password */
1517 status = SecKeychainAddInternetPassword(keychain,
1518 strlen("mail.apple.com"), "mail.apple.com",
1519 0, NULL,
1520 strlen("testacct"), "testacct",
1521 0, NULL,
1522 143, kSecProtocolTypeIMAP, kSecAuthenticationTypeDefault,
1523 strlen("testpass"), "testpass",
1524 NULL);
1525 if (status && status != errSecDuplicateItem) { // ignore error if duplicate
1526 fprintf(stderr, "Unable to add \"mail.apple.com\" internet password: error %d\n", (int)status);
1527 goto error_exit;
1528 }
1529
1530 /* if an item was already in the keychain from a previous run, we can ignore the error */
1531 if (status == errSecDuplicateItem)
1532 status = noErr;
1533
1534 error_exit:
1535
1536 if (keychain) CFRelease(keychain);
1537 PrintTestResult("TestAddItems", status, noErr);
1538
1539 return (int)status;
1540 }
1541
1542
1543 int CheckResults(CFTypeRef results, CFIndex minMatchesExpected, CFIndex maxMatchesExpected)
1544 {
1545 OSStatus status = noErr;
1546 if (debug) {
1547 PrintCFThing(results);
1548 }
1549 if (minMatchesExpected > 0) {
1550 CFIndex matchesFound;
1551 if (CFGetTypeID(results) == CFArrayGetTypeID()) {
1552 // multiple items returned as an array
1553 matchesFound = CFArrayGetCount(results);
1554 }
1555 else {
1556 // single item returned as either a dictionary or an item reference
1557 matchesFound = (results) ? 1 : 0;
1558 }
1559 if (debug) {
1560 fprintf(stdout, "### Items matched: %d (minimum expected: %d",
1561 (int)matchesFound, (int)minMatchesExpected);
1562 if (maxMatchesExpected < MAXITEMS)
1563 fprintf(stdout, ", maximum expected: %d", (int)minMatchesExpected);
1564 fprintf(stdout, ")\n");
1565 fflush(stdout);
1566 }
1567 if (matchesFound < minMatchesExpected ||
1568 matchesFound > maxMatchesExpected) {
1569 /* should not happen, unless SecItemCopyMatching has a bug */
1570 status = errSecInternalError;
1571 }
1572 }
1573 return (int)status;
1574 }
1575
1576
1577 #pragma mark -- Individual Test Cases --
1578
1579
1580 int FindCertificateByEmail(CFStringRef emailStr,
1581 CFTypeRef returnType,
1582 CFTypeRef matchLimit,
1583 CFIndex minMatchesExpected,
1584 OSStatus expected)
1585 {
1586 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1587 &kCFTypeDictionaryKeyCallBacks,
1588 &kCFTypeDictionaryValueCallBacks);
1589
1590 /* set up the query */
1591 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1592 CFDictionaryAddValue( query, kSecMatchEmailAddressIfPresent, emailStr );
1593 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
1594 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
1595
1596 CFTypeRef results = NULL;
1597 if (debug) {
1598 PrintStringToMatch(emailStr);
1599 }
1600
1601 OSStatus status = SecItemCopyMatching(query, &results);
1602
1603 if (!status && results) {
1604 status = CheckResults(results, minMatchesExpected, MAXITEMS);
1605 CFRelease(results);
1606 }
1607 if (query)
1608 CFRelease(query);
1609
1610 PrintTestResult("FindCertificateByEmail", status, expected);
1611
1612 return (status==expected) ? (int)noErr : (int)status;
1613 }
1614
1615
1616 int FindCertificateByLabel(CFStringRef labelStr,
1617 CFTypeRef returnType,
1618 CFTypeRef matchLimit,
1619 CFIndex minMatchesExpected,
1620 CFIndex maxMatchesExpected,
1621 OSStatus expected)
1622 {
1623 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1624 &kCFTypeDictionaryKeyCallBacks,
1625 &kCFTypeDictionaryValueCallBacks);
1626
1627 /* set up the query */
1628 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1629 CFDictionaryAddValue( query, kSecAttrLabel, labelStr );
1630 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
1631 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
1632
1633 CFTypeRef results = NULL;
1634 if (debug) {
1635 PrintStringToMatch(labelStr);
1636 }
1637
1638 OSStatus status = SecItemCopyMatching(query, &results);
1639
1640 if (!status && results) {
1641 status = CheckResults(results, minMatchesExpected, maxMatchesExpected);
1642 CFRelease(results);
1643 }
1644 if (query)
1645 CFRelease(query);
1646
1647 PrintTestResult("FindCertificateByLabel", status, expected);
1648
1649 return (status==expected) ? (int)noErr : (int)status;
1650 }
1651
1652
1653 int FindCertificateByNameInSubject(CFStringRef nameStr,
1654 CFTypeRef matchType,
1655 CFTypeRef returnType,
1656 CFTypeRef matchLimit,
1657 CFIndex minMatchesExpected,
1658 OSStatus expected)
1659 {
1660 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1661 &kCFTypeDictionaryKeyCallBacks,
1662 &kCFTypeDictionaryValueCallBacks);
1663
1664 /* set up the query */
1665 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1666 CFDictionaryAddValue( query, matchType, nameStr );
1667 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
1668 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
1669
1670 CFTypeRef results = NULL;
1671 if (debug) {
1672 PrintStringToMatch(nameStr);
1673 }
1674
1675 OSStatus status = SecItemCopyMatching(query, &results);
1676
1677 if (!status && results) {
1678 status = CheckResults(results, minMatchesExpected, MAXITEMS);
1679 CFRelease(results);
1680 }
1681 if (query)
1682 CFRelease(query);
1683
1684 PrintTestResult("FindCertificateByNameInSubject", status, expected);
1685
1686 return (status==expected) ? (int)noErr : (int)status;
1687 }
1688
1689
1690 int FindCertificateByNameAndPolicy(CFStringRef nameStr,
1691 CFTypeRef policyIdentifier,
1692 Boolean isClientPolicy,
1693 CFTypeRef returnType,
1694 CFTypeRef matchLimit,
1695 CFIndex minMatchesExpected,
1696 OSStatus expected)
1697 {
1698 /* given the policy OID, create a SecPolicyRef */
1699 SecPolicyRef policy = SecPolicyCreateWithOID(policyIdentifier);
1700 if (policy == NULL)
1701 return errSecPolicyNotFound;
1702 if (isClientPolicy == TRUE) {
1703 /* specify the kSecPolicyClient property key for this policy */
1704 const void *keys[] = { kSecPolicyClient };
1705 const void *values[] = { kCFBooleanTrue };
1706 CFDictionaryRef properties = CFDictionaryCreate(NULL, keys, values,
1707 sizeof(keys) / sizeof(*keys),
1708 &kCFTypeDictionaryKeyCallBacks,
1709 &kCFTypeDictionaryValueCallBacks);
1710 SecPolicySetProperties(policy, properties);
1711 }
1712
1713 const void *keys[] = {
1714 kSecClass,
1715 kSecMatchSubjectContains,
1716 kSecMatchPolicy,
1717 kSecMatchLimit,
1718 returnType
1719 };
1720 const void *values[] = {
1721 kSecClassCertificate,
1722 nameStr,
1723 policy,
1724 matchLimit,
1725 kCFBooleanTrue
1726 };
1727
1728 OSStatus status = noErr;
1729 CFTypeRef results = NULL;
1730 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
1731 sizeof(keys) / sizeof(*keys),
1732 &kCFTypeDictionaryKeyCallBacks,
1733 &kCFTypeDictionaryValueCallBacks);
1734
1735 if (debug) {
1736 PrintStringToMatch(nameStr);
1737 PrintStringToMatch(CFCopyDescription(policyIdentifier));
1738 }
1739
1740 status = SecItemCopyMatching(query, &results);
1741
1742 if (!status && results) {
1743 status = CheckResults(results, minMatchesExpected, MAXITEMS);
1744 CFRelease(results);
1745 }
1746 if (query)
1747 CFRelease(query);
1748 if (policy)
1749 CFRelease(policy);
1750
1751 PrintTestResult("FindCertificateByNameAndPolicy", status, expected);
1752
1753 return (status==expected) ? (int)noErr : (int)status;
1754 }
1755
1756
1757 int FindCertificateByNameAndValidDate(CFStringRef nameStr,
1758 CFTypeRef validOnDate,
1759 CFTypeRef returnType,
1760 CFTypeRef matchLimit,
1761 CFIndex minMatchesExpected,
1762 OSStatus expected)
1763 {
1764 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1765 &kCFTypeDictionaryKeyCallBacks,
1766 &kCFTypeDictionaryValueCallBacks);
1767
1768 /* set up the query */
1769 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1770 CFDictionaryAddValue( query, kSecMatchSubjectContains, nameStr );
1771 CFDictionaryAddValue( query, kSecMatchValidOnDate, validOnDate ); // value may be a CFDateRef or a CFNullRef
1772 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
1773 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
1774
1775 CFTypeRef results = NULL;
1776 if (debug) {
1777 PrintStringToMatch(nameStr);
1778 PrintStringToMatch(CFCopyDescription(validOnDate));
1779 }
1780
1781 OSStatus status = SecItemCopyMatching(query, &results);
1782
1783 if (!status && results) {
1784 status = CheckResults(results, minMatchesExpected, MAXITEMS);
1785 CFRelease(results);
1786 }
1787 if (query)
1788 CFRelease(query);
1789
1790 PrintTestResult("FindCertificateByNameAndValidDate", status, expected);
1791
1792 return (status==expected) ? (int)noErr : (int)status;
1793 }
1794
1795
1796 int FindCertificateForSMIMEEncryption(CFStringRef emailAddr,
1797 CFTypeRef validOnDate,
1798 CFTypeRef returnType,
1799 CFTypeRef matchLimit,
1800 CFIndex minMatchesExpected,
1801 OSStatus expected)
1802 {
1803 /* create a SecPolicyRef for S/MIME */
1804 SecPolicyRef policy = SecPolicyCreateWithOID(kSecPolicyAppleSMIME);
1805 if (policy == NULL)
1806 return errSecPolicyNotFound;
1807
1808 CFMutableDictionaryRef properties = CFDictionaryCreateMutable(NULL, 0,
1809 &kCFTypeDictionaryKeyCallBacks,
1810 &kCFTypeDictionaryValueCallBacks);
1811
1812 /* property 1: must match email address */
1813 CFDictionaryAddValue( properties, kSecPolicyName, emailAddr );
1814 /* property 2: must have "key encipherment" key usage to be used for encryption */
1815 CFDictionaryAddValue( properties, kSecPolicyKU_KeyEncipherment, kCFBooleanTrue );
1816
1817 SecPolicySetProperties(policy, properties);
1818
1819 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1820 &kCFTypeDictionaryKeyCallBacks,
1821 &kCFTypeDictionaryValueCallBacks);
1822
1823 /* set up the query */
1824 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1825 CFDictionaryAddValue( query, kSecMatchPolicy, policy );
1826 CFDictionaryAddValue( query, kSecMatchValidOnDate, validOnDate );
1827 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
1828 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
1829
1830 CFTypeRef results = NULL;
1831 if (debug) {
1832 PrintStringToMatch(emailAddr);
1833 PrintStringToMatch(CFCopyDescription(kSecPolicyAppleSMIME));
1834 PrintStringToMatch(CFCopyDescription(validOnDate));
1835 }
1836
1837 OSStatus status = SecItemCopyMatching(query, &results);
1838
1839 if (!status && results) {
1840 status = CheckResults(results, minMatchesExpected, MAXITEMS);
1841 CFRelease(results);
1842 }
1843 if (query)
1844 CFRelease(query);
1845 if (policy)
1846 CFRelease(policy);
1847 if (properties)
1848 CFRelease(properties);
1849
1850 PrintTestResult("FindCertificateForSMIMEEncryption", status, expected);
1851
1852 return (status==expected) ? (int)noErr : (int)status;
1853 }
1854
1855
1856 int FindPreferredCertificateForSMIMEEncryption(CFStringRef emailAddr,
1857 CFTypeRef validOnDate)
1858 {
1859 // Note: this function assumes that a preferred certificate has been set up
1860 // previously for the given email address. This is handled in the calling
1861 // function.
1862
1863 OSStatus status = noErr;
1864 SecCertificateRef preferredCertificate = NULL;
1865 SecCertificateRef validatedCertificate = NULL;
1866
1867 // Pass an explicit key usage value to SecCertificateCopyPreferred to test <rdar://8192797>
1868 CFArrayRef keyUsage = CFArrayCreate(kCFAllocatorDefault, (const void **)&kSecAttrCanEncrypt, 1, &kCFTypeArrayCallBacks);
1869
1870 preferredCertificate = SecCertificateCopyPreferred(emailAddr, keyUsage);
1871 if (!preferredCertificate)
1872 status = errSecItemNotFound; // our test expects a preferred certificate to exist, so we return an error
1873 if (keyUsage)
1874 CFRelease(keyUsage);
1875
1876 if (!status && preferredCertificate) {
1877 // We found a preferred certificate, but it may have expired.
1878 // Verify the preferred certificate by looking up all certificates which
1879 // are valid for SMIME encryption, and using the kSecMatchItemList query
1880 // parameter to filter out everything but our preferred certificate. If
1881 // we end up with 0 results, the preferred certificate wasn't valid.
1882
1883 // set up the S/MIME policy first to check for the Key Encipherment key usage (needed for encryption)
1884 SecPolicyRef policy = SecPolicyCreateWithOID(kSecPolicyAppleSMIME);
1885 CFDictionaryRef properties = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&kSecPolicyKU_KeyEncipherment, (const void **)&kCFBooleanTrue, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1886 status = SecPolicySetProperties(policy, properties);
1887 CFRelease(properties);
1888
1889 // set up an item list consisting of just our preferred certificate
1890 CFArrayRef itemList = CFArrayCreate(kCFAllocatorDefault, (const void **)&preferredCertificate, 1, &kCFTypeArrayCallBacks);
1891
1892 // set up the query
1893 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
1894 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1895 CFDictionaryAddValue( query, kSecMatchPolicy, policy );
1896 CFDictionaryAddValue( query, kSecMatchValidOnDate, validOnDate );
1897 CFDictionaryAddValue( query, kSecMatchItemList, itemList );
1898 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne ); // only need to match one item!
1899 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue );
1900
1901 if (debug) {
1902 PrintStringToMatch(emailAddr);
1903 PrintStringToMatch(CFCopyDescription(validOnDate));
1904 }
1905
1906 status = SecItemCopyMatching(query, (CFTypeRef*)&validatedCertificate);
1907
1908 if (!status && validatedCertificate) {
1909 status = CheckResults(validatedCertificate, 1, 1); // expect exactly 1 result
1910 CFRelease(validatedCertificate);
1911 }
1912 if (query)
1913 CFRelease(query);
1914 if (policy)
1915 CFRelease(policy);
1916 if (itemList)
1917 CFRelease(itemList);
1918 }
1919 else if (!quiet)
1920 fprintf(stderr, "FindPreferredCertificateForSMIMEEncryption: unexpected error %d\n", (int)status);
1921
1922 if (preferredCertificate)
1923 CFRelease(preferredCertificate);
1924
1925 PrintTestResult("FindPreferredCertificateForSMIMEEncryption", status, noErr);
1926
1927 return (status==noErr) ? (int)noErr : (int)status;
1928 }
1929
1930
1931 int SetPreferredCertificateForSMIMEEncryption(CFStringRef nameStr,
1932 CFStringRef emailAddr)
1933 {
1934 // find the certificate exactly matching the given common name
1935 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
1936 &kCFTypeDictionaryKeyCallBacks,
1937 &kCFTypeDictionaryValueCallBacks);
1938
1939 CFDictionaryAddValue( query, kSecClass, kSecClassCertificate );
1940 CFDictionaryAddValue( query, kSecMatchSubjectWholeString, nameStr );
1941 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne );
1942 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue );
1943
1944 CFTypeRef results = NULL;
1945 OSStatus status = SecItemCopyMatching(query, &results);
1946
1947 if (!quiet && status)
1948 fprintf(stderr, "SetPreferredCertificateForSMIMEEncryption: SecItemCopyMatching error %d\n", (int)status);
1949
1950 if (!status && results) {
1951 // since we asked for kSecMatchLimitOne, the result is a single item
1952 SecCertificateRef certificate = (SecCertificateRef) results;
1953 if (SecCertificateGetTypeID() != CFGetTypeID(certificate)) {
1954 fprintf(stderr, "SetPreferredCertificateForSMIMEEncryption: unexpected result type!\n");
1955 }
1956 else {
1957 // Pass an explicit key usage value to SecCertificateSetPreferred to test <rdar://8192797>
1958 CFArrayRef keyUsage = CFArrayCreate(kCFAllocatorDefault, (const void **)&kSecAttrCanEncrypt, 1, &kCFTypeArrayCallBacks);
1959 status = SecCertificateSetPreferred(certificate, emailAddr, keyUsage);
1960 if (!quiet && status)
1961 fprintf(stderr, "SetPreferredCertificateForSMIMEEncryption: SecCertificateSetPreferred error %d\n", (int)status);
1962 if (keyUsage)
1963 CFRelease(keyUsage);
1964 }
1965 CFRelease(results);
1966 }
1967 if (query)
1968 CFRelease(query);
1969
1970 return (status==noErr) ? (int)noErr : (int)status;
1971 }
1972
1973
1974 int FindIdentityByName(CFStringRef nameStr,
1975 CFTypeRef returnType,
1976 CFTypeRef matchLimit,
1977 CFIndex minMatchesExpected,
1978 OSStatus expected)
1979 {
1980 const void *keys[] = {
1981 kSecClass,
1982 kSecMatchSubjectContains,
1983 kSecMatchLimit,
1984 returnType
1985 };
1986 const void *values[] = {
1987 kSecClassIdentity,
1988 nameStr,
1989 matchLimit,
1990 kCFBooleanTrue
1991 };
1992
1993 OSStatus status = noErr;
1994 CFTypeRef results = NULL;
1995 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
1996 sizeof(keys) / sizeof(*keys),
1997 &kCFTypeDictionaryKeyCallBacks,
1998 &kCFTypeDictionaryValueCallBacks);
1999
2000 if (debug) PrintStringToMatch(nameStr);
2001
2002 status = SecItemCopyMatching(query, &results);
2003
2004 if (!status && results) {
2005 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2006 CFRelease(results);
2007 }
2008 if (query)
2009 CFRelease(query);
2010
2011 PrintTestResult("FindIdentityByName", status, expected);
2012
2013 return (status==expected) ? (int)noErr : (int)status;
2014 }
2015
2016
2017 int FindIdentityByPolicy(CFTypeRef policyIdentifier,
2018 Boolean isClientPolicy,
2019 CFTypeRef returnType,
2020 CFTypeRef matchLimit,
2021 CFIndex minMatchesExpected,
2022 OSStatus expected)
2023 {
2024 /* given the policy OID, create a SecPolicyRef */
2025 SecPolicyRef policy = SecPolicyCreateWithOID(policyIdentifier);
2026 if (policy == NULL)
2027 return errSecPolicyNotFound;
2028 if (isClientPolicy == TRUE) {
2029 /* specify the kSecPolicyClient property key for this policy */
2030 const void *keys[] = { kSecPolicyClient };
2031 const void *values[] = { kCFBooleanTrue };
2032 CFDictionaryRef properties = CFDictionaryCreate(NULL, keys, values,
2033 sizeof(keys) / sizeof(*keys),
2034 &kCFTypeDictionaryKeyCallBacks,
2035 &kCFTypeDictionaryValueCallBacks);
2036 SecPolicySetProperties(policy, properties);
2037 }
2038
2039 const void *keys[] = {
2040 kSecClass,
2041 kSecMatchPolicy,
2042 kSecMatchLimit,
2043 returnType
2044 };
2045 const void *values[] = {
2046 kSecClassIdentity,
2047 policy,
2048 matchLimit,
2049 kCFBooleanTrue
2050 };
2051
2052 OSStatus status = noErr;
2053 CFTypeRef results = NULL;
2054 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2055 sizeof(keys) / sizeof(*keys),
2056 &kCFTypeDictionaryKeyCallBacks,
2057 &kCFTypeDictionaryValueCallBacks);
2058
2059 if (debug) PrintStringToMatch(CFCopyDescription(policyIdentifier));
2060
2061 status = SecItemCopyMatching(query, &results);
2062
2063 if (!status && results) {
2064 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2065 CFRelease(results);
2066 }
2067 if (query)
2068 CFRelease(query);
2069 if (policy)
2070 CFRelease(policy);
2071
2072 PrintTestResult("FindIdentityByPolicy", status, expected);
2073
2074 return (status==expected) ? (int)noErr : (int)status;
2075 }
2076
2077
2078 int FindIdentityByPolicyAndValidDate(CFTypeRef policyIdentifier,
2079 Boolean isClientPolicy,
2080 CFTypeRef validOnDate,
2081 CFStringRef forbidStr,
2082 CFTypeRef returnType,
2083 CFTypeRef matchLimit,
2084 CFIndex minMatchesExpected,
2085 OSStatus expected)
2086 {
2087 /* given the policy OID, create a SecPolicyRef */
2088 SecPolicyRef policy = SecPolicyCreateWithOID(policyIdentifier);
2089 if (policy == NULL)
2090 return errSecPolicyNotFound;
2091 if (isClientPolicy == TRUE) {
2092 /* specify the kSecPolicyClient property key for this policy */
2093 const void *keys[] = { kSecPolicyClient };
2094 const void *values[] = { kCFBooleanTrue };
2095 CFDictionaryRef properties = CFDictionaryCreate(NULL, keys, values,
2096 sizeof(keys) / sizeof(*keys),
2097 &kCFTypeDictionaryKeyCallBacks,
2098 &kCFTypeDictionaryValueCallBacks);
2099 SecPolicySetProperties(policy, properties);
2100 }
2101
2102 const void *keys[] = {
2103 kSecClass,
2104 kSecMatchPolicy,
2105 kSecMatchValidOnDate,
2106 kSecMatchLimit,
2107 returnType
2108 };
2109 const void *values[] = {
2110 kSecClassIdentity,
2111 policy,
2112 validOnDate,
2113 matchLimit,
2114 kCFBooleanTrue
2115 };
2116
2117 OSStatus status = noErr;
2118 CFTypeRef results = NULL;
2119 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2120 sizeof(keys) / sizeof(*keys),
2121 &kCFTypeDictionaryKeyCallBacks,
2122 &kCFTypeDictionaryValueCallBacks);
2123
2124 if (debug) PrintStringToMatch(CFCopyDescription(policyIdentifier));
2125
2126 status = SecItemCopyMatching(query, &results);
2127
2128 // check returned items for forbidStr as a substring in the label attribute;
2129 // return errSecInternalError if found
2130 if (!status && results && forbidStr) {
2131 if (CFArrayGetTypeID() == CFGetTypeID(results)) {
2132 CFArrayRef items = (CFArrayRef) results;
2133 CFIndex ix, count = CFArrayGetCount(results);
2134 for (ix=0; ix<count; ix++) {
2135 CFTypeRef anItem = (CFTypeRef) CFArrayGetValueAtIndex(items, ix);
2136 if (anItem && CFDictionaryGetTypeID() == CFGetTypeID(anItem)) {
2137 CFDictionaryRef item = (CFDictionaryRef) anItem;
2138 CFStringRef label = NULL;
2139 if (CFDictionaryGetValueIfPresent(item, kSecAttrLabel, (const void **)&label) && label) {
2140 CFRange range = CFStringFind(label, forbidStr, 0);
2141 if (!(range.length < 1)) {
2142 status = errSecInternalError; // shouldn't have found this, but we did.
2143 break;
2144 } // found forbidStr
2145 } // found label attribute
2146 } // item is a dictionary
2147 } // item for-loop
2148 } // result is an array
2149 } // check forbidStr
2150
2151
2152 if (!status && results) {
2153 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2154 CFRelease(results);
2155 }
2156 if (query)
2157 CFRelease(query);
2158 if (policy)
2159 CFRelease(policy);
2160
2161 PrintTestResult("FindIdentityByPolicyAndValidDate", status, expected);
2162
2163 return (status==expected) ? (int)noErr : (int)status;
2164 }
2165
2166
2167 int FindIdentityByNameAndValidDate(CFStringRef nameStr,
2168 CFTypeRef validOnDate,
2169 CFTypeRef returnType,
2170 CFTypeRef matchLimit,
2171 CFIndex minMatchesExpected,
2172 OSStatus expected)
2173 {
2174 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
2175 &kCFTypeDictionaryKeyCallBacks,
2176 &kCFTypeDictionaryValueCallBacks);
2177
2178 /* set up the query */
2179 CFDictionaryAddValue( query, kSecClass, kSecClassIdentity );
2180 CFDictionaryAddValue( query, kSecMatchSubjectContains, nameStr );
2181 CFDictionaryAddValue( query, kSecMatchValidOnDate, validOnDate ); // value may be a CFDateRef or a CFNullRef
2182 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit );
2183 CFDictionaryAddValue( query, returnType, kCFBooleanTrue );
2184
2185 CFTypeRef results = NULL;
2186 if (debug) {
2187 PrintStringToMatch(nameStr);
2188 PrintStringToMatch(CFCopyDescription(validOnDate));
2189 }
2190
2191 OSStatus status = SecItemCopyMatching(query, &results);
2192
2193 if (!status && results) {
2194 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2195 CFRelease(results);
2196 }
2197 if (query)
2198 CFRelease(query);
2199
2200 PrintTestResult("FindIdentityByNameAndValidDate", status, expected);
2201
2202 return (status==expected) ? (int)noErr : (int)status;
2203 }
2204
2205
2206 int FindPreferredIdentityForSMIMESigning(CFStringRef emailAddr,
2207 CFTypeRef validOnDate)
2208 {
2209 // Note: this function assumes that a preferred identity has been set up
2210 // previously for the given email address. This is handled in the calling
2211 // function.
2212
2213 OSStatus status = noErr;
2214 SecIdentityRef preferredIdentity = NULL;
2215 SecIdentityRef validatedIdentity = NULL;
2216
2217 // Pass an explicit key usage value to SecIdentityCopyPreferred to test <rdar://8192797>
2218 CFArrayRef keyUsage = CFArrayCreate(kCFAllocatorDefault, (const void **)&kSecAttrCanSign, 1, &kCFTypeArrayCallBacks);
2219
2220 preferredIdentity = SecIdentityCopyPreferred(emailAddr, keyUsage, NULL);
2221 if (!preferredIdentity)
2222 status = errSecItemNotFound; // our test expects a preferred identity to exist, so we return an error
2223 if (keyUsage)
2224 CFRelease(keyUsage);
2225
2226 if (!status && preferredIdentity) {
2227 // We found a preferred identity, but it may have expired.
2228 // Verify the preferred identity by looking up all identities which
2229 // are valid for SMIME signing, and using the kSecMatchItemList query
2230 // parameter to filter out everything but our preferred identity. If
2231 // we end up with 0 results, the preferred identity wasn't valid.
2232
2233 // set up the S/MIME policy first to check for Digital Signature key usage
2234 SecPolicyRef policy = SecPolicyCreateWithOID(kSecPolicyAppleSMIME);
2235 CFDictionaryRef properties = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&kSecPolicyKU_DigitalSignature, (const void **)&kCFBooleanTrue, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
2236 status = SecPolicySetProperties(policy, properties);
2237 CFRelease(properties);
2238
2239 // set up an item list consisting of just our preferred identity
2240 CFArrayRef itemList = CFArrayCreate(kCFAllocatorDefault, (const void **)&preferredIdentity, 1, &kCFTypeArrayCallBacks);
2241
2242 // set up the query
2243 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
2244 CFDictionaryAddValue( query, kSecClass, kSecClassIdentity );
2245 CFDictionaryAddValue( query, kSecMatchPolicy, policy );
2246 CFDictionaryAddValue( query, kSecMatchValidOnDate, validOnDate );
2247 CFDictionaryAddValue( query, kSecMatchItemList, itemList );
2248 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne ); // only need to match one item!
2249 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue );
2250
2251 if (debug) {
2252 PrintStringToMatch(emailAddr);
2253 PrintStringToMatch(CFCopyDescription(validOnDate));
2254 }
2255
2256 status = SecItemCopyMatching(query, (CFTypeRef*)&validatedIdentity);
2257
2258 if (!status && validatedIdentity) {
2259 status = CheckResults(validatedIdentity, 1, 1); // expect exactly 1 result
2260 CFRelease(validatedIdentity);
2261 }
2262 if (query)
2263 CFRelease(query);
2264 if (policy)
2265 CFRelease(policy);
2266 if (itemList)
2267 CFRelease(itemList);
2268 }
2269 else if (!quiet)
2270 fprintf(stderr, "FindPreferredIdentityForSMIMESigning: unexpected error %d\n", (int)status);
2271
2272 if (preferredIdentity)
2273 CFRelease(preferredIdentity);
2274
2275 PrintTestResult("FindPreferredIdentityForSMIMESigning", status, noErr);
2276
2277 return (status==noErr) ? (int)noErr : (int)status;
2278 }
2279
2280
2281 int SetPreferredIdentityForSMIMESigning(CFStringRef nameStr,
2282 CFStringRef emailAddr)
2283 {
2284 // find the identity exactly matching the given common name
2285 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
2286 &kCFTypeDictionaryKeyCallBacks,
2287 &kCFTypeDictionaryValueCallBacks);
2288
2289 CFDictionaryAddValue( query, kSecClass, kSecClassIdentity );
2290 CFDictionaryAddValue( query, kSecMatchSubjectWholeString, nameStr );
2291 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne );
2292 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue );
2293
2294 CFTypeRef results = NULL;
2295 OSStatus status = SecItemCopyMatching(query, &results);
2296
2297 if (!quiet && status)
2298 fprintf(stderr, "SetPreferredIdentityForSMIMESigning: SecItemCopyMatching error %d\n", (int)status);
2299
2300 if (!status && results) {
2301 // since we asked for kSecMatchLimitOne, the result is a single SecIdentityRef
2302 SecIdentityRef identity = (SecIdentityRef) results;
2303 if (SecIdentityGetTypeID() != CFGetTypeID(identity)) {
2304 fprintf(stderr, "SetPreferredCertificateForSMIMEEncryption: unexpected result type!\n");
2305 }
2306 else {
2307 // Pass an explicit key usage value to SecIdentitySetPreferred to test <rdar://8192797>
2308 CFArrayRef keyUsage = CFArrayCreate(kCFAllocatorDefault, (const void **)&kSecAttrCanSign, 1, &kCFTypeArrayCallBacks);
2309 status = SecIdentitySetPreferred(identity, emailAddr, keyUsage);
2310 if (!quiet && status)
2311 fprintf(stderr, "SetPreferredIdentityForSMIMESigning: SecIdentitySetPreferred error %d\n", (int)status);
2312 if (keyUsage)
2313 CFRelease(keyUsage);
2314 }
2315 CFRelease(results);
2316 }
2317 if (query)
2318 CFRelease(query);
2319
2320 return (status==noErr) ? (int)noErr : (int)status;
2321 }
2322
2323
2324 int FindGenericPasswordByAccount(CFStringRef accountStr,
2325 CFTypeRef returnType,
2326 CFTypeRef matchLimit,
2327 CFIndex minMatchesExpected,
2328 OSStatus expected)
2329 {
2330 const void *keys[] = {
2331 kSecClass,
2332 kSecAttrAccount,
2333 kSecMatchLimit,
2334 returnType
2335 };
2336 const void *values[] = {
2337 kSecClassGenericPassword,
2338 accountStr,
2339 matchLimit,
2340 kCFBooleanTrue
2341 };
2342
2343 OSStatus status = noErr;
2344 CFTypeRef results = NULL;
2345 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2346 sizeof(keys) / sizeof(*keys),
2347 &kCFTypeDictionaryKeyCallBacks,
2348 &kCFTypeDictionaryValueCallBacks);
2349
2350 if (debug) PrintStringToMatch(accountStr);
2351
2352 status = SecItemCopyMatching(query, &results);
2353
2354 if (!status && results) {
2355 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2356 CFRelease(results);
2357 }
2358 if (query)
2359 CFRelease(query);
2360
2361 PrintTestResult("FindGenericPasswordByAccount", status, expected);
2362
2363 return (status==expected) ? (int)noErr : (int)status;
2364 }
2365
2366
2367 int FindGenericPasswordByAccountAndService(CFStringRef accountStr,
2368 CFStringRef serviceStr,
2369 CFTypeRef returnType,
2370 CFTypeRef matchLimit,
2371 CFIndex minMatchesExpected,
2372 OSStatus expected)
2373 {
2374 const void *keys[] = {
2375 kSecClass,
2376 kSecAttrAccount,
2377 kSecAttrService,
2378 kSecMatchLimit,
2379 returnType
2380 };
2381 const void *values[] = {
2382 kSecClassGenericPassword,
2383 accountStr,
2384 serviceStr,
2385 matchLimit,
2386 kCFBooleanTrue
2387 };
2388
2389 OSStatus status = noErr;
2390 CFTypeRef results = NULL;
2391 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2392 sizeof(keys) / sizeof(*keys),
2393 &kCFTypeDictionaryKeyCallBacks,
2394 &kCFTypeDictionaryValueCallBacks);
2395
2396 if (debug) {
2397 PrintStringToMatch(accountStr);
2398 PrintStringToMatch(serviceStr);
2399 }
2400 status = SecItemCopyMatching(query, &results);
2401
2402 if (!status && results) {
2403 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2404 CFRelease(results);
2405 }
2406 if (query)
2407 CFRelease(query);
2408
2409 PrintTestResult("FindGenericPasswordByAccountAndService", status, expected);
2410
2411 return (status==expected) ? (int)noErr : (int)status;
2412 }
2413
2414
2415 int FindInternetPasswordByAccount(CFStringRef accountStr,
2416 CFTypeRef returnType,
2417 CFTypeRef matchLimit,
2418 CFIndex minMatchesExpected,
2419 OSStatus expected)
2420 {
2421 const void *keys[] = {
2422 kSecClass,
2423 kSecAttrAccount,
2424 kSecMatchLimit,
2425 returnType
2426 };
2427 const void *values[] = {
2428 kSecClassInternetPassword,
2429 accountStr,
2430 matchLimit,
2431 kCFBooleanTrue
2432 };
2433
2434 OSStatus status = noErr;
2435 CFTypeRef results = NULL;
2436 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2437 sizeof(keys) / sizeof(*keys),
2438 &kCFTypeDictionaryKeyCallBacks,
2439 &kCFTypeDictionaryValueCallBacks);
2440
2441 if (debug) PrintStringToMatch(accountStr);
2442
2443 status = SecItemCopyMatching(query, &results);
2444
2445 if (!status && results) {
2446 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2447 CFRelease(results);
2448 }
2449 if (query)
2450 CFRelease(query);
2451
2452 PrintTestResult("FindInternetPasswordByAccount", status, expected);
2453
2454 return (status==expected) ? (int)noErr : (int)status;
2455 }
2456
2457
2458 int FindInternetPasswordByAccountAndServer(CFStringRef accountStr,
2459 CFStringRef serverStr,
2460 CFTypeRef returnType,
2461 CFTypeRef matchLimit,
2462 CFIndex minMatchesExpected,
2463 OSStatus expected)
2464 {
2465 const void *keys[] = {
2466 kSecClass,
2467 kSecAttrAccount,
2468 kSecAttrServer,
2469 kSecMatchLimit,
2470 returnType
2471 };
2472 const void *values[] = {
2473 kSecClassInternetPassword,
2474 accountStr,
2475 serverStr,
2476 matchLimit,
2477 kCFBooleanTrue
2478 };
2479
2480 OSStatus status = noErr;
2481 CFTypeRef results = NULL;
2482 CFDictionaryRef query = CFDictionaryCreate(NULL, keys, values,
2483 sizeof(keys) / sizeof(*keys),
2484 &kCFTypeDictionaryKeyCallBacks,
2485 &kCFTypeDictionaryValueCallBacks);
2486
2487 if (debug) {
2488 PrintStringToMatch(accountStr);
2489 PrintStringToMatch(serverStr);
2490 }
2491 status = SecItemCopyMatching(query, &results);
2492
2493 if (!status && results) {
2494 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2495 CFRelease(results);
2496 }
2497 if (query)
2498 CFRelease(query);
2499
2500 PrintTestResult("FindInternetPasswordByAccountAndServer", status, expected);
2501
2502 return (status==expected) ? (int)noErr : (int)status;
2503 }
2504
2505
2506 int FindMailPassword(
2507 CFStringRef account,
2508 CFStringRef server)
2509 {
2510 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
2511 &kCFTypeDictionaryKeyCallBacks,
2512 &kCFTypeDictionaryValueCallBacks);
2513
2514 SInt16 port = 143;
2515 CFNumberRef portNumber = CFNumberCreate(NULL, kCFNumberSInt16Type, &port);
2516
2517 // set up query for a Mail password (IMAP, port 143) for given account and server
2518 CFDictionaryAddValue( query, kSecClass, kSecClassInternetPassword );
2519 CFDictionaryAddValue( query, kSecAttrAccount, account );
2520 CFDictionaryAddValue( query, kSecAttrServer, server );
2521 CFDictionaryAddValue( query, kSecAttrProtocol, kSecAttrProtocolIMAP );
2522 CFDictionaryAddValue( query, kSecAttrPort, portNumber );
2523 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne );
2524 CFDictionaryAddValue( query, kSecReturnData, kCFBooleanTrue );
2525
2526 CFTypeRef results = NULL;
2527 OSStatus status = SecItemCopyMatching(query, &results);
2528
2529 if (!quiet && status)
2530 fprintf(stderr, "FindMailPassword: SecItemCopyMatching error %d\n", (int)status);
2531
2532 if (!status && results) {
2533 // since we asked for kSecMatchLimitOne w/kSecReturnData, the result is the found password
2534 CFDataRef password = (CFDataRef) results;
2535 if (CFDataGetTypeID() != CFGetTypeID(password)) {
2536 fprintf(stderr, "FindMailPassword: unexpected result type!\n");
2537 }
2538 else {
2539 if (debug) CFShow(password);
2540 }
2541 CFRelease(results);
2542 }
2543 if (query)
2544 CFRelease(query);
2545 if (portNumber)
2546 CFRelease(portNumber);
2547
2548 return (status==noErr) ? (int)noErr : (int)status;
2549 }
2550
2551
2552
2553 const CFStringRef gPrefix = CFSTR("Test Key");
2554 const CFStringRef gLabel = CFSTR("Test AES Encryption Key");
2555 const CFStringRef gUUID = CFSTR("550e8400-e29b-41d4-a716-446655441234");
2556
2557 // CreateSymmetricKey will create a new AES-128 symmetric encryption key
2558 // with the provided label, application label, and application tag.
2559 // Each of those attributes is optional, but only the latter two
2560 // (application label and application tag) are considered part of the
2561 // key's "unique" attribute set. Previously, if you attempted to create a
2562 // key which differs only in the label attribute (but not in the other two)
2563 // then the attempt would fail and leave a "turd" key with no label in your
2564 // keychain: <rdar://8289559>, fixed in 11A268a.
2565
2566 int CreateSymmetricKey(
2567 CFStringRef keyLabel,
2568 CFStringRef keyAppLabel,
2569 CFStringRef keyAppTag,
2570 OSStatus expected)
2571 {
2572 OSStatus status;
2573 int keySizeValue = 128;
2574 CFNumberRef keySize = CFNumberCreate(NULL, kCFNumberIntType, &keySizeValue);
2575
2576 // get a SecKeychainRef for the keychain in which we want the key to be created
2577 // (this step is optional, but if omitted, the key is NOT saved in any keychain!)
2578 SecKeychainRef keychain = NULL;
2579 status = SecKeychainCopyDefault(&keychain);
2580
2581 // create a SecAccessRef to set up the initial access control settings for this key
2582 // (this step is optional; if omitted, the creating application has access to the key)
2583 // note: the access descriptor should be the same string as will be used for the item's label,
2584 // since it's the string that is displayed by the access confirmation dialog to describe the item.
2585 SecAccessRef access = NULL;
2586 status = SecAccessCreate(gLabel, NULL, &access);
2587
2588 // create a dictionary of parameters describing the key we want to create
2589 CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL, 0,
2590 &kCFTypeDictionaryKeyCallBacks,
2591 &kCFTypeDictionaryValueCallBacks);
2592
2593 CFDictionaryAddValue( params, kSecClass, kSecClassKey );
2594 CFDictionaryAddValue( params, kSecUseKeychain, keychain );
2595 CFDictionaryAddValue( params, kSecAttrAccess, access );
2596 CFDictionaryAddValue( params, kSecAttrKeyClass, kSecAttrKeyClassSymmetric );
2597 CFDictionaryAddValue( params, kSecAttrKeyType, kSecAttrKeyTypeAES );
2598 CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize );
2599 CFDictionaryAddValue( params, kSecAttrIsPermanent, kCFBooleanTrue );
2600 CFDictionaryAddValue( params, kSecAttrCanEncrypt, kCFBooleanTrue );
2601 CFDictionaryAddValue( params, kSecAttrCanDecrypt, kCFBooleanTrue );
2602 CFDictionaryAddValue( params, kSecAttrCanWrap, kCFBooleanFalse );
2603 CFDictionaryAddValue( params, kSecAttrCanUnwrap, kCFBooleanFalse );
2604 if (keyLabel)
2605 CFDictionaryAddValue( params, kSecAttrLabel, keyLabel );
2606 if (keyAppLabel)
2607 CFDictionaryAddValue( params, kSecAttrApplicationLabel, keyAppLabel );
2608 if (keyAppTag)
2609 CFDictionaryAddValue( params, kSecAttrApplicationTag, keyAppTag );
2610
2611 // generate the key
2612 CFErrorRef error = NULL;
2613 SecKeyRef key = SecKeyGenerateSymmetric(params, &error);
2614
2615 // print result and clean up
2616 if (debug) {
2617 if (key == NULL) {
2618 CFStringRef desc = (error) ? CFErrorCopyDescription(error) : CFRetain(CFSTR("(no result!"));
2619 PrintCFStringWithFormat("SecKeyGenerateSymmetric failed: %s\n", desc);
2620 CFRelease(desc);
2621 }
2622 else {
2623 CFStringRef desc = CFCopyDescription(key);
2624 PrintCFStringWithFormat("SecKeyGenerateSymmetric succeeded: %s\n", desc);
2625 CFRelease(desc);
2626 }
2627 }
2628 status = (error) ? (OSStatus) CFErrorGetCode(error) : noErr;
2629 // if (status == errSecDuplicateItem)
2630 // status = noErr; // it's OK if the key already exists
2631
2632 if (key) CFRelease(key);
2633 if (error) CFRelease(error);
2634 if (params) CFRelease(params);
2635 if (keychain) CFRelease(keychain);
2636 if (access) CFRelease(access);
2637
2638 PrintTestResult("CreateSymmetricKey", status, expected);
2639
2640 return status;
2641 }
2642
2643
2644 int FindSymmetricKey(
2645 CFStringRef keyLabel,
2646 CFStringRef keyAppLabel,
2647 CFStringRef keyAppTag,
2648 OSStatus expected)
2649 {
2650 // create a dictionary of parameters describing the key we want to find,
2651 // and how we want the result to be returned
2652 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
2653 &kCFTypeDictionaryKeyCallBacks,
2654 &kCFTypeDictionaryValueCallBacks);
2655
2656 CFDictionaryAddValue( query, kSecClass, kSecClassKey );
2657 CFDictionaryAddValue( query, kSecAttrKeyClass, kSecAttrKeyClassSymmetric );
2658 CFDictionaryAddValue( query, kSecMatchLimit, kSecMatchLimitOne ); // we only want the first match
2659 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue ); // we want the result as a SecKeyRef
2660 CFDictionaryAddValue( query, kSecReturnAttributes, kCFBooleanTrue ); // we also want the found item's attributes
2661 if (keyLabel)
2662 CFDictionaryAddValue( query, kSecAttrLabel, keyLabel );
2663 if (keyAppLabel)
2664 CFDictionaryAddValue( query, kSecAttrApplicationLabel, keyAppLabel );
2665 if (keyAppTag)
2666 CFDictionaryAddValue( query, kSecAttrApplicationLabel, keyAppTag );
2667
2668 CFTypeRef result = NULL;
2669 OSStatus status = SecItemCopyMatching(query, &result);
2670
2671 // print result and clean up
2672 if (debug) {
2673 if (status == noErr) {
2674 fprintf(stdout, "SecItemCopyMatching succeeded; found key\n");
2675 PrintCFThing(result);
2676 }
2677 else if (status == errSecItemNotFound) {
2678 fprintf(stdout, "SecItemCopyMatching: item not found\n");
2679 }
2680 else {
2681 fprintf(stdout, "SecItemCopyMatching: failed! (error %d)\n", (int)status);
2682 }
2683 }
2684
2685 SecKeyRef key = NULL;
2686 if (result) {
2687 // since we asked for both the item reference and the item attributes,
2688 // we expect a dictionary to be returned...
2689 if (CFDictionaryGetTypeID() == CFGetTypeID(result)) {
2690 if (CFDictionaryGetValueIfPresent(result, kSecValueRef, (CFTypeRef*)&key))
2691 CFRetain(key);
2692 }
2693 CFRelease(result); // all done with result dictionary
2694 }
2695
2696 if (key) CFRelease(key);
2697 if (query) CFRelease(query);
2698
2699 PrintTestResult("FindSymmetricKey", status, expected);
2700
2701 return status;
2702 }
2703
2704
2705 int FindAndDeleteItemsByName(
2706 CFStringRef nameStr,
2707 CFStringRef accountStr,
2708 CFTypeRef itemClass,
2709 CFTypeRef matchLimit,
2710 CFIndex minMatchesExpected,
2711 OSStatus expected)
2712 {
2713 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
2714 &kCFTypeDictionaryKeyCallBacks,
2715 &kCFTypeDictionaryValueCallBacks);
2716
2717 CFTypeRef nameMatchKey;
2718 if (CFEqual(itemClass, kSecClassCertificate) ||
2719 CFEqual(itemClass, kSecClassIdentity)) {
2720 nameMatchKey = kSecMatchSubjectStartsWith; /* must start with nameStr */
2721 }
2722 else {
2723 nameMatchKey = kSecAttrLabel; /* nameStr must exactly match label */
2724 }
2725
2726 /* set up the query */
2727 CFDictionaryAddValue( query, kSecClass, itemClass );
2728 CFDictionaryAddValue( query, nameMatchKey, nameStr);
2729 CFDictionaryAddValue( query, kSecMatchLimit, matchLimit);
2730 if (accountStr) {
2731 CFDictionaryAddValue( query, kSecAttrAccount, accountStr);
2732 }
2733
2734 CFTypeRef results = NULL;
2735 if (debug) {
2736 PrintStringToMatch(nameStr);
2737 }
2738
2739 OSStatus status = SecItemCopyMatching(query, &results);
2740
2741 if (!status) {
2742 /* Make sure that we found the items we expected to find */
2743 status = CheckResults(results, minMatchesExpected, MAXITEMS);
2744 CFRelease(results);
2745 }
2746
2747 if (!status) {
2748 /* OK, now the real reason we're here... the same query must work for SecItemDelete */
2749 status = SecItemDelete(query);
2750
2751 PrintTestResult("FindAndDeleteItemsByName: deleting items", status, expected);
2752 }
2753
2754 if (!status) {
2755 /* re-run the same query... should find no matching items this time */
2756 status = SecItemCopyMatching(query, &results);
2757 if (!status) {
2758 /* oops... we still found matches using this query */
2759 int count = (int)CFArrayGetCount(results);
2760 fprintf(stderr, "### still found %d items, expected 0\n", count);
2761 CFRelease(results);
2762 }
2763 PrintTestResult("FindAndDeleteItemsByName: find after delete", status, errSecItemNotFound);
2764
2765 status = (status == errSecItemNotFound) ? expected : errSecInternalError;
2766 }
2767
2768 if (query)
2769 CFRelease(query);
2770
2771 return (status==expected) ? (int)noErr : (int)status;
2772 }
2773
2774
2775 #pragma mark -- Test Functions --
2776
2777
2778 int TestIdentityLookup()
2779 {
2780 int result = 0;
2781
2782 // look up identity by name, want first result as a SecIdentityRef
2783 result += FindIdentityByName(CFSTR("Test SSL User"), kSecReturnRef, kSecMatchLimitOne, 1, noErr);
2784
2785 // look up existing non-identity certificate by name, expect errSecItemNotFound error
2786 result += FindIdentityByName(CFSTR("Test-5685316-LEAF"), kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2787
2788 // look up non-existent identity by name, expect errSecItemNotFound error
2789 result += FindIdentityByName(CFSTR("myxlpytk"), kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2790
2791 // look up identity by policy, want first result as a SecIdentityRef (should find "Test SSL User" identity)
2792 result += FindIdentityByPolicy(kSecPolicyAppleSSL, TRUE, kSecReturnRef, kSecMatchLimitOne, 1, noErr);
2793
2794 // look up identity by policy, want first result as a CFDictionary of attributes (should find "Test SSL User" identity)
2795 result += FindIdentityByPolicy(kSecPolicyAppleSSL, TRUE, kSecReturnAttributes, kSecMatchLimitOne, 1, noErr);
2796
2797 // look up identity by policy, expect errSecItemNotFound error (this assumes no code signing identity is present!)
2798 result += FindIdentityByPolicy(kSecPolicyAppleCodeSigning, FALSE, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2799
2800 // -------------------------
2801 // test kSecMatchValidOnDate
2802 // -------------------------
2803
2804 // make a valid date which will match at least some identities we used to populate the keychain
2805 CFGregorianDate aCurrentGDate = { 2010, 7, 20, 12, 0, 0 }; // Jul 20 2010 12:00 PM
2806 CFDateRef aCurrentDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aCurrentGDate, NULL));
2807 if (FindIdentityByNameAndValidDate(CFSTR("Test SSL User"), aCurrentDate, kSecReturnRef, kSecMatchLimitAll, 1, noErr))
2808 ++result;
2809 if(aCurrentDate) CFRelease(aCurrentDate);
2810
2811 // make a date in the past which should NOT match any identities (expect errSecItemNotFound)
2812 CFGregorianDate aPastGDate = { 1984, 7, 20, 12, 0, 0 }; // Jul 20 1984 12:00 PM
2813 CFDateRef aPastDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aPastGDate, NULL));
2814 if (FindIdentityByNameAndValidDate(CFSTR("Test SSL User"), aPastDate, kSecReturnRef, kSecMatchLimitAll, 0, errSecItemNotFound))
2815 ++result;
2816 if(aPastDate) CFRelease(aPastDate);
2817
2818 // make a date in the future which should NOT match any identities yet (expect errSecItemNotFound)
2819 CFGregorianDate aFutureGDate = { 2034, 7, 20, 12, 0, 0 }; // Jul 20 2034 12:00 PM
2820 CFDateRef aFutureDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aFutureGDate, NULL));
2821 if (FindIdentityByNameAndValidDate(CFSTR("Test SSL User"), aFutureDate, kSecReturnRef, kSecMatchLimitAll, 0, errSecItemNotFound))
2822 ++result;
2823 if(aFutureDate) CFRelease(aFutureDate);
2824
2825 // make a date in the past which SHOULD match 2 identities we used to populate the keychain
2826 CFGregorianDate aPastValidGDate = { 2007, 12, 20, 12, 0, 0 }; // Dec 20 2007 12:00 PM
2827 CFDateRef aPastValidDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aPastValidGDate, NULL));
2828 if (FindIdentityByNameAndValidDate(CFSTR(" 2007"), aPastValidDate, kSecReturnRef, kSecMatchLimitAll, 0, noErr))
2829 ++result;
2830
2831 // test the ability of kCFNull to denote "currently valid" (should not find anything, since the " 2007" certs are expired)
2832 if (FindIdentityByNameAndValidDate(CFSTR(" 2007"), kCFNull, kSecReturnRef, kSecMatchLimitAll, 0, errSecItemNotFound))
2833 ++result;
2834
2835 // test Ian's bug: <rdar://8197632>; the 4th argument is a string which should NOT be present in any found items
2836 if (FindIdentityByPolicyAndValidDate(kSecPolicyAppleSMIME, FALSE, kCFNull, CFSTR(" 2007"), kSecReturnAttributes, kSecMatchLimitAll, 0, noErr))
2837 ++result;
2838
2839 return result;
2840 }
2841
2842
2843 int TestCertificateLookup()
2844 {
2845 int result = 0;
2846
2847 //======================================================================
2848 // item attribute tests (kSecItemAttr* keys)
2849 //======================================================================
2850
2851 // %%%TBA: need to flesh out this section with all certificate attributes
2852
2853 // ------------------------------------------
2854 // test kSecAttrIssuer & kSecAttrSerialNumber
2855 // ------------------------------------------
2856
2857 // look up cert by issuer & serial
2858 // %%%TBA -- underlying support was added in <rdar://8131491>; need to implement these keys
2859 //CFDictionarySetValue(query, (const void *)kSecAttrIssuer, (const void *)nameStr);
2860 //CFDictionarySetValue(query, (const void *)kSecAttrSerialNumber, (const void *)nameStr);
2861
2862 // -------------------------
2863 // test kSecAttrSubjectKeyID
2864 // -------------------------
2865
2866 // look up cert by subject key ID
2867 // %%%TBA -- can we get the subject key ID from SecCertificateCopyValues??
2868 //CFDictionarySetValue(query, (const void *)kSecAttrSubjectKeyID, (const void *)nameStr);
2869
2870 // ------------------
2871 // test kSecAttrLabel
2872 // ------------------
2873
2874 // look up cert by label, want array of all results (expect only 1) as SecCertificateRef
2875 result += FindCertificateByLabel(CFSTR("com.apple.kerberos.kdc"),
2876 kSecReturnRef, kSecMatchLimitAll, 1, 1, noErr);
2877
2878
2879 //======================================================================
2880 // search attribute tests (kSecMatch* keys)
2881 //======================================================================
2882
2883 // -----------------------------------
2884 // test kSecMatchEmailAddressIfPresent
2885 // -----------------------------------
2886
2887 // look up cert by email, want first result as a SecCertificateRef
2888 result += FindCertificateByEmail(CFSTR("security-dev@group.apple.com"),
2889 kSecReturnRef, kSecMatchLimitOne, 0, noErr);
2890
2891 // look up cert by email, want first result as a CFDictionaryRef of attributes
2892 result += FindCertificateByEmail(CFSTR("security-dev@group.apple.com"),
2893 kSecReturnAttributes, kSecMatchLimitOne, 0, noErr);
2894
2895 // -----------------------------
2896 // test kSecMatchSubjectContains
2897 // -----------------------------
2898
2899 // look up cert containing name, want array of all results (expect at least 3) as SecCertificateRef
2900 result += FindCertificateByNameInSubject(CFSTR("Test-5685316"),
2901 kSecMatchSubjectContains, kSecReturnRef, kSecMatchLimitAll, 3, noErr);
2902
2903 // look up non-existent cert by name, expect errSecItemNotFound error
2904 result += FindCertificateByNameInSubject(CFSTR("myxlpytk"),
2905 kSecMatchSubjectContains, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2906
2907 // look up cert by name, want array of all results (expect at least 2) as CFDataRef
2908 result += FindCertificateByNameInSubject(CFSTR("Test-5685316"),
2909 kSecMatchSubjectContains, kSecReturnData, kSecMatchLimitAll, 2, noErr);
2910
2911 // look up cert by name, want array of all results (expect at least 2) as CFDictionaryRef of attributes
2912 result += FindCertificateByNameInSubject(CFSTR("Test-5685316"),
2913 kSecMatchSubjectContains, kSecReturnAttributes, kSecMatchLimitAll, 2, noErr);
2914
2915 // -------------------------------
2916 // test kSecMatchSubjectStartsWith
2917 // -------------------------------
2918
2919 // look up cert starting with name, want array of all results (expect at least 3) as SecCertificateRef
2920 result += FindCertificateByNameInSubject(CFSTR("Test-568"),
2921 kSecMatchSubjectStartsWith, kSecReturnRef, kSecMatchLimitAll, 3, noErr);
2922
2923 // look up cert starting with a name which isn't at start, expect errSecItemNotFound error
2924 result += FindCertificateByNameInSubject(CFSTR("5685316"),
2925 kSecMatchSubjectStartsWith, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2926
2927 // -----------------------------
2928 // test kSecMatchSubjectEndsWith
2929 // -----------------------------
2930
2931 // look up cert ending with name, want array of all results (expect at least 1) as SecCertificateRef
2932 result += FindCertificateByNameInSubject(CFSTR("LEAF"),
2933 kSecMatchSubjectEndsWith, kSecReturnRef, kSecMatchLimitAll, 1, noErr);
2934
2935 // look up cert ending with a name which isn't at end, expect errSecItemNotFound error
2936 result += FindCertificateByNameInSubject(CFSTR("Test-"),
2937 kSecMatchSubjectEndsWith, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2938
2939 // --------------------------------
2940 // test kSecMatchSubjectWholeString
2941 // --------------------------------
2942
2943 // look up cert by whole name, want first result (expecting 1) as a SecCertificateRef
2944 result += FindCertificateByNameInSubject(CFSTR("Test-5685316-LEAF"),
2945 kSecMatchSubjectWholeString, kSecReturnRef, kSecMatchLimitOne, 1, noErr);
2946
2947 // look up cert by whole name (which is a substring in other certs), expect errSecItemNotFound error
2948 result += FindCertificateByNameInSubject(CFSTR("Test-568"),
2949 kSecMatchSubjectWholeString, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
2950
2951 // --------------------
2952 // test kSecMatchPolicy
2953 // --------------------
2954
2955 // look up cert by name and policy (Code Signing), want first result as a SecCertificateRef
2956 result += FindCertificateByNameAndPolicy(CFSTR("Test-7875801"),
2957 kSecPolicyAppleCodeSigning, FALSE,
2958 kSecReturnRef, kSecMatchLimitOne, 0, noErr);
2959
2960 // look up cert by name and policy (S/MIME), want first result as a SecCertificateRef
2961 result += FindCertificateByNameAndPolicy(CFSTR("Test-"),
2962 kSecPolicyAppleSMIME, FALSE,
2963 kSecReturnRef, kSecMatchLimitOne, 0, noErr);
2964
2965 // look up cert by name and policy, want array of all results as SecCertificateRef
2966 // (note that we expect an error here, since if all went well, there will be only 1 cert
2967 // matching both name and policy parameters, but we asked for a minimum of 2 matches.)
2968 result += FindCertificateByNameAndPolicy(CFSTR("Test-7875801"),
2969 kSecPolicyAppleCodeSigning, FALSE,
2970 kSecReturnAttributes, kSecMatchLimitAll, 2, errSecInternalError);
2971
2972 // look up cert by email address for SMIME encryption, date valid today, want array of all results as SecCertificateRef
2973 // (note that a date value of kCFNull is interpreted as the current date)
2974 result += FindCertificateForSMIMEEncryption(CFSTR("smime-test@apple.com"), kCFNull,
2975 kSecReturnRef, kSecMatchLimitAll, 1, noErr);
2976
2977 // -------------------------
2978 // test kSecMatchValidOnDate
2979 // -------------------------
2980
2981 // make a valid date which will match at least 2 certificates we used to populate the keychain
2982 CFGregorianDate aCurrentGDate = { 2010, 7, 20, 12, 0, 0 }; // Jul 20 2010 12:00 PM
2983 CFDateRef aCurrentDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aCurrentGDate, NULL));
2984 if (FindCertificateByNameAndValidDate(CFSTR("Test-"), aCurrentDate, kSecReturnRef, kSecMatchLimitAll, 2, noErr))
2985 ++result;
2986 if(aCurrentDate) CFRelease(aCurrentDate);
2987
2988 // make a date in the past which should NOT match any certificates (expect errSecItemNotFound)
2989 CFGregorianDate aPastGDate = { 1984, 7, 20, 12, 0, 0 }; // Jul 20 1984 12:00 PM
2990 CFDateRef aPastDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aPastGDate, NULL));
2991 if (FindCertificateByNameAndValidDate(CFSTR("Test-"), aPastDate, kSecReturnRef, kSecMatchLimitAll, 2, errSecItemNotFound))
2992 ++result;
2993 if(aPastDate) CFRelease(aPastDate);
2994
2995 // make a date in the future which should NOT match any certificates yet (expect errSecItemNotFound)
2996 CFGregorianDate aFutureGDate = { 2034, 7, 20, 12, 0, 0 }; // Jul 20 2034 12:00 PM
2997 CFDateRef aFutureDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aFutureGDate, NULL));
2998 if (FindCertificateByNameAndValidDate(CFSTR("Test-"), aFutureDate, kSecReturnRef, kSecMatchLimitAll, 2, errSecItemNotFound))
2999 ++result;
3000 if(aFutureDate) CFRelease(aFutureDate);
3001
3002 return result;
3003 }
3004
3005
3006 int TestPreferredIdentityLookup()
3007 {
3008 int result = 0;
3009
3010 // set a preferred identity first
3011 if (SetPreferredIdentityForSMIMESigning(CFSTR("Test-SignOnly (S/MIME)"), CFSTR("smime-test@apple.com")))
3012 ++result;
3013
3014 // define a valid date for this preferred identity (typically this would just be kCFNull in a real program, meaning "now")
3015 CFGregorianDate aCurrentGDate = { 2010, 7, 27, 21, 0, 0 }; // Jul 27 2010 9:00 PM
3016 CFDateRef aCurrentDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aCurrentGDate, NULL));
3017 if (FindPreferredIdentityForSMIMESigning(CFSTR("smime-test@apple.com"), aCurrentDate))
3018 ++result;
3019 if(aCurrentDate) CFRelease(aCurrentDate);
3020
3021 // delete identity preference(s) for this email address by setting a NULL identity
3022 if (SecIdentitySetPreferred(NULL, CFSTR("smime-test@apple.com"), 0) != noErr)
3023 ++result;
3024
3025 return result;
3026 }
3027
3028
3029 int TestPreferredCertificateLookup()
3030 {
3031 int result = 0;
3032
3033 // set a preferred certificate first
3034 if (SetPreferredCertificateForSMIMEEncryption(CFSTR("Test-Encryption (S/MIME)"), CFSTR("smime-test@apple.com")))
3035 ++result;
3036
3037 // define a valid date for this preferred certificate (typically this would just be kCFNull in a real program, meaning "now")
3038 CFGregorianDate aCurrentGDate = { 2010, 7, 27, 21, 0, 0 }; // Jul 27 2010 9:00 PM
3039 CFDateRef aCurrentDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aCurrentGDate, NULL));
3040 if (FindPreferredCertificateForSMIMEEncryption(CFSTR("smime-test@apple.com"), aCurrentDate))
3041 ++result;
3042 if(aCurrentDate) CFRelease(aCurrentDate);
3043
3044 // delete certificate preference(s) for this email address by setting a NULL identity
3045 if (SecCertificateSetPreferred(NULL, CFSTR("smime-test@apple.com"), 0) != noErr)
3046 ++result;
3047
3048 return result;
3049 }
3050
3051
3052 int TestSymmetricKeyLookup()
3053 {
3054 int result = 0;
3055
3056 // look up our symmetric key by label and UUID (it might not exist yet)
3057 if (FindSymmetricKey(gLabel, gUUID, NULL, errSecItemNotFound) != errSecSuccess) {
3058 // create test key (unique by UUID only)
3059 if (CreateSymmetricKey(gLabel, gUUID, NULL, errSecSuccess) != errSecSuccess)
3060 ++result;
3061 // look it up again (it should exist now!)
3062 if (FindSymmetricKey(gLabel, gUUID, NULL, errSecSuccess) != errSecSuccess)
3063 ++result;
3064 }
3065
3066 // now look up a key whose name is derived from today's date
3067 // (so we can make sure on a daily basis that SecKeyGenerateSymmetric is still working)
3068 CFGregorianDate curGDate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), NULL);
3069 CFStringRef curDateLabel = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%4d-%02d-%02d)"),
3070 gPrefix, curGDate.year, curGDate.month, curGDate.day);
3071 //
3072 //%%% FIXME Creating a symmetric key with attributes that would duplicate an existing
3073 // key item currently results in a broken <unknown> key which can't be found: <rdar://8289559>
3074 //
3075 //CFStringRef curAppTag = curDateLabel; // i.e. make sure it will be unique, for now
3076 CFStringRef curAppTag = CFSTR("SecItemFind");
3077
3078 // look up our date-based symmetric key by label, UUID, and tag (it might not exist yet)
3079 if (FindSymmetricKey(curDateLabel, gUUID, curAppTag, errSecItemNotFound) != errSecSuccess) {
3080 // create test key (unique by combination of UUID and application tag)
3081 if (CreateSymmetricKey(curDateLabel, gUUID, curAppTag, errSecSuccess) != errSecSuccess)
3082 ++result;
3083 // look it up again (it should exist now!)
3084 if (FindSymmetricKey(curDateLabel, gUUID, curAppTag, errSecSuccess) != errSecSuccess)
3085 ++result;
3086 }
3087
3088 // test handling of duplicate symmetric key items (<rdar://8289559>)
3089 if (CreateSymmetricKey(curDateLabel, gUUID, curAppTag, errSecDuplicateItem) != errSecDuplicateItem)
3090 ++result;
3091
3092 CFRelease(curDateLabel);
3093
3094 return result;
3095 }
3096
3097
3098 int TestInternetPasswordLookup()
3099 {
3100 int result = 0;
3101
3102 // look up internet password by account and server, want first result as data
3103 if (FindInternetPasswordByAccountAndServer(CFSTR("nobody"),
3104 CFSTR("test2.subdomain.apple.com"), kSecReturnData, kSecMatchLimitOne, 1, noErr))
3105 ++result;
3106
3107 // look up internet password by account and server, want dictionary of the item's attributes
3108 if (FindInternetPasswordByAccountAndServer(CFSTR("nobody"),
3109 CFSTR("test2.subdomain.apple.com"), kSecReturnAttributes, kSecMatchLimitOne, 1, noErr))
3110 ++result;
3111
3112 // look up internet passwords by account, want array of SecKeychainItemRef results
3113 if (FindInternetPasswordByAccount(CFSTR("nobody"),
3114 kSecReturnRef, kSecMatchLimitAll, 1, noErr))
3115 ++result;
3116
3117 // look up a Mail password for an IMAP account, replacing SecKeychainFindInternetPassword
3118 // (see <rdar://8347516>)
3119 if (FindMailPassword(CFSTR("testacct"), CFSTR("mail.apple.com")))
3120 ++result;
3121
3122 return result;
3123 }
3124
3125
3126 int TestGenericPasswordLookup()
3127 {
3128 int result = 0;
3129
3130 // look up generic password by account and service, want first result as data
3131 if (FindGenericPasswordByAccountAndService(CFSTR("nobody"),
3132 CFSTR("Test Service 42"), kSecReturnData, kSecMatchLimitOne, 1, noErr))
3133 ++result;
3134
3135 // look up generic password by account and service, dictionary of the item's attributes
3136 if (FindGenericPasswordByAccountAndService(CFSTR("nobody"),
3137 CFSTR("Test Service 42"), kSecReturnAttributes, kSecMatchLimitOne, 1, noErr))
3138 ++result;
3139
3140 // look up generic passwords by account, want array of SecKeychainItemRef results
3141 if (FindGenericPasswordByAccount(CFSTR("nobody"),
3142 kSecReturnRef, kSecMatchLimitAll, 1, noErr))
3143 ++result;
3144
3145 return result;
3146 }
3147
3148
3149 int TestUpdateItems()
3150 {
3151 int result = 0;
3152
3153 // test for <rdar://8658820>
3154 // create a new 1024-bit RSA key pair
3155 SecKeyRef publicKey = NULL;
3156 SecKeyRef privateKey = NULL;
3157 CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL, 0,
3158 &kCFTypeDictionaryKeyCallBacks,
3159 &kCFTypeDictionaryValueCallBacks);
3160 int keySizeValue = 1024;
3161 CFNumberRef keySize = CFNumberCreate(NULL, kCFNumberIntType, &keySizeValue);
3162 CFStringRef keyLabel = CFSTR("AppleID 8658820 test key");
3163 CFDictionaryAddValue( params, kSecAttrKeyType, kSecAttrKeyTypeRSA );
3164 CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize );
3165 CFDictionaryAddValue( params, kSecAttrLabel, keyLabel );
3166 // CFDictionaryAddValue( params, kSecUseKeychain, keychain );
3167 // CFDictionaryAddValue( params, kSecAttrAccess, access );
3168 // %%% note that SecKeyGeneratePair will create the key pair in the default keychain
3169 // if a keychain is not given via the kSecUseKeychain parameter.
3170 OSStatus status = SecKeyGeneratePair(params, &publicKey, &privateKey);
3171 if (status != noErr) {
3172 ++result;
3173 }
3174 PrintTestResult("TestUpdateItems: generating key pair", status, noErr);
3175
3176 // create a query which will match just the private key item (based on its known reference)
3177 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
3178 &kCFTypeDictionaryKeyCallBacks,
3179 &kCFTypeDictionaryValueCallBacks);
3180 CFArrayRef itemList = CFArrayCreate(NULL, (const void**) &privateKey, 1, &kCFTypeArrayCallBacks);
3181 // %%% note that kSecClass seems to be a required query parameter even though
3182 // kSecMatchItemList is provided; that looks like it could be a bug...
3183 CFDictionaryAddValue( query, kSecClass, kSecClassKey );
3184 // CFDictionaryAddValue( query, kSecAttrKeyClass, kSecAttrKeyClassPrivate );
3185 CFDictionaryAddValue( query, kSecMatchItemList, itemList );
3186
3187 // create dictionary of changed attributes for the private key
3188 CFMutableDictionaryRef attrs = CFDictionaryCreateMutable(NULL, 0,
3189 &kCFTypeDictionaryKeyCallBacks,
3190 &kCFTypeDictionaryValueCallBacks);
3191 SecAccessRef access = NULL;
3192 CFStringRef newLabel = CFSTR("AppleID 8658820 test PRIVATE key");
3193 status = SecAccessCreate(newLabel, NULL, &access);
3194 if (status != noErr) {
3195 ++result;
3196 }
3197 PrintTestResult("TestUpdateItems: creating access", status, noErr);
3198 //%%% note that changing the access for this key causes a dialog,
3199 // so leave this out for the moment (uncomment to test that access change works).
3200 // Normally the desired access should be passed into the SecKeyGeneratePair function.
3201 // so there is no need for a dialog later.
3202 // CFDictionaryAddValue( attrs, kSecAttrAccess, access );
3203 CFDictionaryAddValue( attrs, kSecAttrLabel, newLabel );
3204
3205 // update the private key with the new attributes
3206 status = SecItemUpdate( query, attrs );
3207 if (status != noErr) {
3208 ++result;
3209 }
3210 PrintTestResult("TestUpdateItems: updating item", status, noErr);
3211
3212 if (publicKey)
3213 CFRelease(publicKey);
3214 if (privateKey)
3215 CFRelease(privateKey);
3216 if (access)
3217 CFRelease(access);
3218
3219 if (params)
3220 CFRelease(params);
3221 if (query)
3222 CFRelease(query);
3223 if (attrs)
3224 CFRelease(attrs);
3225
3226 return result;
3227 }
3228
3229
3230 int TestDeleteItems()
3231 {
3232 int result = 0;
3233
3234 // delete our 3 test certificates that start with "Test-5685316-"
3235 if (FindAndDeleteItemsByName(CFSTR("Test-5685316-"), NULL, kSecClassCertificate, kSecMatchLimitAll, 3, noErr))
3236 ++result;
3237
3238 // delete our 2 test identities that start with "Test Identity S" (fixed by <rdar://8317856>)
3239 if (FindAndDeleteItemsByName(CFSTR("Test Identity S"), NULL, kSecClassIdentity, kSecMatchLimitAll, 2, noErr))
3240 ++result;
3241
3242 // delete the "Test-SignOnly (S/MIME)" identity
3243 if (FindAndDeleteItemsByName(CFSTR("Test-SignOnly (S/MIME)"), NULL, kSecClassIdentity, kSecMatchLimitAll, 1, noErr))
3244 ++result;
3245
3246 // delete the "Test-Encryption (S/MIME)" certificate
3247 if (FindAndDeleteItemsByName(CFSTR("Test-Encryption (S/MIME)"), NULL, kSecClassCertificate, kSecMatchLimitAll, 1, noErr))
3248 ++result;
3249
3250 // delete the "Test-7875801 (Code Signing)" certificate
3251 if (FindAndDeleteItemsByName(CFSTR("Test-7875801 (Code Signing)"), NULL, kSecClassCertificate, kSecMatchLimitAll, 1, noErr))
3252 ++result;
3253
3254 // delete our test passwords (no partial string matching for password items! need an ER Radar...)
3255 if (FindAndDeleteItemsByName(CFSTR("Test Service 42"), NULL, kSecClassGenericPassword, kSecMatchLimitAll, 1, noErr))
3256 ++result;
3257 if (FindAndDeleteItemsByName(CFSTR("Test Service 69"), NULL, kSecClassGenericPassword, kSecMatchLimitAll, 1, noErr))
3258 ++result;
3259 if (FindAndDeleteItemsByName(CFSTR("test1.subdomain.apple.com"), NULL, kSecClassInternetPassword, kSecMatchLimitAll, 1, noErr))
3260 ++result;
3261 if (FindAndDeleteItemsByName(CFSTR("test2.subdomain.apple.com"), NULL, kSecClassInternetPassword, kSecMatchLimitAll, 1, noErr))
3262 ++result;
3263 if (FindAndDeleteItemsByName(CFSTR("mail.apple.com"), CFSTR("testacct"), kSecClassInternetPassword, kSecMatchLimitAll, 1, noErr))
3264 ++result;
3265
3266 // delete our test symmetric keys (no partial string matching for key items! need an ER Radar...)
3267 if (FindAndDeleteItemsByName(gLabel, NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
3268 ++result;
3269 CFGregorianDate curGDate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), NULL);
3270 CFStringRef curDateLabel = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%4d-%02d-%02d)"),
3271 gPrefix, curGDate.year, curGDate.month, curGDate.day);
3272 if (FindAndDeleteItemsByName(curDateLabel, NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
3273 ++result;
3274 CFRelease(curDateLabel);
3275
3276 // delete our test asymmetric key pair (remember we renamed the private key...)
3277 if (FindAndDeleteItemsByName(CFSTR("AppleID 8658820 test key"), NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
3278 ++result;
3279 if (FindAndDeleteItemsByName(CFSTR("AppleID 8658820 test PRIVATE key"), NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
3280 ++result;
3281
3282 return result;
3283 }
3284
3285
3286 void usage(const char *arg0)
3287 {
3288 fprintf(stdout, "Usage: %s [-q] [-d]\n", arg0);
3289 fprintf(stdout, "Options:\n");
3290 fprintf(stdout, " -q : (quiet) suppress output of pass/fail lines\n");
3291 fprintf(stdout, " -d : (debug) show debug output\n");
3292 }
3293
3294
3295 int main (int argc, const char * argv[])
3296 {
3297 int n, i, c, e;
3298
3299 /* validate arguments */
3300 if (argc > 3)
3301 {
3302 usage(argv[0]);
3303 exit(1);
3304 }
3305
3306 for (i=1; i<argc; i++)
3307 {
3308 if (!strcmp(argv[i], "-q") || !strcmp(argv[i], "q"))
3309 quiet = 1;
3310 else if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "d"))
3311 debug = 1;
3312 else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "v"))
3313 verbose = 1;
3314 else {
3315 usage(argv[0]);
3316 exit(1);
3317 }
3318 }
3319 if (!quiet && !debug && !verbose) {
3320 fprintf(stdout, "Note: use -d and -v option flags to show debug output and verbose results\n");
3321 }
3322
3323 c = 0; /* count */
3324 e = 0; /* errors */
3325
3326 n = 10; /* number of tests we are doing below */
3327
3328 plan_tests(n);
3329 tests_begin(argc, (char * const *) argv);
3330
3331 /* run tests */
3332 if (!quiet) {
3333 fprintf(stdout, "=== Starting SecItem tests\n");
3334 }
3335 #define TEST(FUNC, NAME) { \
3336 if (!quiet) fprintf(stdout,"=== TEST %d: %s\n", ++c, NAME); \
3337 int r=FUNC; if(r) ++e; ok(!r, NAME); \
3338 }
3339
3340 TEST( TestAddItems(), "TestAddItems" );
3341 TEST( TestGenericPasswordLookup(), "TestGenericPasswordLookup" );
3342 TEST( TestInternetPasswordLookup(), "TestInternetPasswordLookup" );
3343 TEST( TestSymmetricKeyLookup(), "TestSymmetricKeyLookup" );
3344 TEST( TestIdentityLookup(), "TestIdentityLookup" );
3345 TEST( TestCertificateLookup(), "TestCertificateLookup" );
3346 TEST( TestPreferredIdentityLookup(), "TestPreferredIdentityLookup" );
3347 TEST( TestPreferredCertificateLookup(), "TestPreferredCertificateLookup" );
3348 TEST( TestUpdateItems(), "TestUpdateItems" );
3349 TEST( TestDeleteItems(), "TestDeleteItems" );
3350
3351 if (!quiet) {
3352 fprintf(stdout, "=== %d of %d tests succeeded ===\n", c-e, c);
3353 }
3354 fflush(stdout);
3355
3356 tests_end(1);
3357
3358 return (e) ? 1 : 0;
3359 }