]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/regressions/kc-28-cert-sign.c
Security-57740.31.2.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / regressions / kc-28-cert-sign.c
1 /*
2 * Copyright (c) 2016 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the xLicense.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #import <Security/Security.h>
25 #include "keychain_regressions.h"
26 #include "kc-helpers.h"
27 #include "kc-keychain-file-helpers.h"
28 #include "test/testenv.h"
29
30 //
31 // Test for Radar 17159227
32 //
33
34 #include <CoreFoundation/CoreFoundation.h>
35 #include <Security/Security.h>
36 #include <Security/SecIdentityPriv.h> // for SecIdentityCreate
37 #include <CoreServices/CoreServices.h>
38
39 #include <stdlib.h>
40 #include <string.h>
41 #include <syslog.h>
42 #include <unistd.h>
43 #include <time.h>
44
45 /* Test CA certificate
46 */
47 unsigned char coreOSTestCA[995]={
48 0x30,0x82,0x03,0xDF,0x30,0x82,0x02,0xC7,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x78,
49 0x0C,0x4B,0x30,0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,
50 0x30,0x81,0x9F,0x31,0x31,0x30,0x2F,0x06,0x03,0x55,0x04,0x03,0x0C,0x28,0x43,0x6F,
51 0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x43,
52 0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,
53 0x68,0x6F,0x72,0x69,0x74,0x79,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,
54 0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x27,0x30,0x25,0x06,
55 0x03,0x55,0x04,0x0B,0x0C,0x1E,0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x20,0x2D,0x20,
56 0x44,0x45,0x56,0x45,0x4C,0x4F,0x50,0x4D,0x45,0x4E,0x54,0x20,0x55,0x53,0x45,0x20,
57 0x4F,0x4E,0x4C,0x59,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,
58 0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,
59 0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,
60 0x6E,0x6F,0x30,0x1E,0x17,0x0D,0x31,0x34,0x30,0x37,0x31,0x37,0x30,0x31,0x33,0x35,
61 0x30,0x37,0x5A,0x17,0x0D,0x31,0x36,0x30,0x37,0x31,0x37,0x30,0x31,0x33,0x35,0x30,
62 0x37,0x5A,0x30,0x81,0x9F,0x31,0x31,0x30,0x2F,0x06,0x03,0x55,0x04,0x03,0x0C,0x28,
63 0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,
64 0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,
65 0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,
66 0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x27,0x30,
67 0x25,0x06,0x03,0x55,0x04,0x0B,0x0C,0x1E,0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x20,
68 0x2D,0x20,0x44,0x45,0x56,0x45,0x4C,0x4F,0x50,0x4D,0x45,0x4E,0x54,0x20,0x55,0x53,
69 0x45,0x20,0x4F,0x4E,0x4C,0x59,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,
70 0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,
71 0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,
72 0x74,0x69,0x6E,0x6F,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
73 0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,
74 0x02,0x82,0x01,0x01,0x00,0xE3,0xC9,0x79,0xA2,0x1F,0xC8,0xFC,0x4F,0xF4,0x70,0x07,
75 0xAA,0x8A,0xFA,0xB2,0x60,0xEE,0x3E,0x9D,0xD6,0xA4,0x4F,0x4B,0x17,0x68,0x63,0x54,
76 0xC1,0x1C,0x12,0xE1,0x7A,0x93,0x5A,0x04,0x48,0x56,0x1B,0xDD,0x9C,0xC5,0x09,0xB0,
77 0x5F,0x39,0xE2,0xB0,0x86,0x60,0xAF,0x13,0x7A,0x8F,0x97,0x35,0x02,0xCC,0xC0,0x83,
78 0x90,0xAC,0x5C,0x44,0xFE,0xF2,0xC1,0xAB,0xB6,0x01,0xFF,0x57,0x7F,0x0B,0xF5,0xA9,
79 0x7B,0x5E,0xF0,0x99,0x1D,0xAE,0xA9,0x56,0xC6,0x32,0x71,0xB5,0x7E,0xEA,0xAB,0xBD,
80 0x01,0xFE,0xF8,0x35,0xFE,0xE6,0xB2,0x83,0x32,0x00,0x9D,0x51,0x74,0x64,0x00,0xDA,
81 0x58,0xD6,0x73,0xB4,0x11,0x8B,0xB6,0x7C,0x86,0x60,0x54,0x42,0x24,0xF9,0xC4,0xAD,
82 0x70,0x07,0xB1,0x05,0x29,0x1E,0x57,0x3B,0x97,0xDC,0x2F,0x51,0x4C,0xBB,0x3A,0x1D,
83 0x30,0xB5,0xC9,0x69,0x85,0x3D,0xFE,0x9B,0xE8,0x96,0xD9,0xC3,0xC0,0xB4,0xEB,0xB8,
84 0x48,0x90,0x74,0xDC,0xC0,0x65,0x50,0x01,0x36,0xCF,0x10,0x8A,0xBF,0xDA,0x9D,0x00,
85 0x07,0x2D,0xE9,0x9F,0x58,0x0D,0xF1,0x07,0x55,0xAE,0xC2,0x0F,0xE2,0x2D,0xB8,0xCF,
86 0xF5,0x79,0x1D,0x05,0xFD,0xE3,0xE9,0xB1,0x4D,0xD8,0xAA,0xB6,0x26,0xC2,0xC2,0x6E,
87 0x72,0xA2,0x18,0xA4,0x81,0x39,0x80,0xA6,0x6B,0x6D,0x16,0x4F,0xB5,0xA0,0xE3,0x20,
88 0xE2,0x5B,0x0E,0xE0,0x2D,0x31,0xAD,0x92,0xD6,0x4C,0x13,0x3D,0x81,0x55,0xD1,0xB3,
89 0x36,0xC0,0xFB,0xDD,0xCF,0x01,0x9F,0xED,0xCE,0x3B,0x47,0x70,0x59,0xE4,0x25,0x69,
90 0x99,0x5C,0x21,0x0C,0x13,0x02,0x03,0x01,0x00,0x01,0xA3,0x23,0x30,0x21,0x30,0x0F,
91 0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,
92 0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,0x86,0x30,
93 0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x82,
94 0x01,0x01,0x00,0xA1,0xFD,0xD2,0x4A,0xCC,0x63,0x5F,0x5C,0xC3,0xBD,0x59,0x47,0x53,
95 0x92,0xE9,0x7C,0x66,0xF6,0x17,0xC3,0x96,0x27,0xB3,0xE1,0xD3,0x52,0x40,0xF6,0xAA,
96 0xA3,0x96,0xC4,0xE2,0x76,0x7B,0xE3,0xA6,0xCD,0x6C,0xA1,0x49,0x52,0x82,0x09,0x77,
97 0xC6,0x87,0x1D,0x44,0x6E,0x47,0x8F,0x34,0xE2,0xB6,0x4B,0x1E,0x13,0x31,0x9E,0x93,
98 0x3E,0xF2,0x7B,0x56,0xEC,0x88,0x93,0x81,0x99,0x55,0x26,0x54,0x72,0x6E,0xD3,0x02,
99 0x45,0x9F,0x51,0x67,0xC2,0x7D,0x46,0xA1,0x4E,0xE5,0x37,0x3F,0x88,0xAB,0x4F,0xD6,
100 0x87,0xBC,0xEE,0xBA,0x29,0x07,0x10,0xCC,0x1E,0x3A,0xD6,0x38,0x5F,0x9D,0x12,0xE6,
101 0x8A,0x9B,0xD0,0xEB,0x5A,0x88,0xC0,0xE8,0x90,0x78,0xCB,0x8A,0x8A,0xBB,0x63,0xA1,
102 0x58,0x1C,0x32,0x8E,0xF0,0xB3,0xA5,0xB5,0x93,0x65,0xA1,0xE2,0x18,0xB1,0xE3,0x2C,
103 0xF8,0xF1,0x6C,0xC8,0xCD,0x7B,0xA8,0x8B,0x84,0x42,0xD0,0x5F,0x9A,0x72,0x4A,0x2C,
104 0x97,0x50,0x44,0x70,0x0D,0x95,0x86,0xE8,0xDF,0xA4,0x52,0xEB,0xE4,0x87,0xF2,0x69,
105 0xD6,0x78,0xA3,0x96,0x37,0x55,0x3D,0x5B,0x86,0x5B,0xED,0xF9,0x93,0x2A,0x75,0xE2,
106 0x1A,0x7D,0xF5,0xC9,0x34,0x76,0x80,0x37,0x0D,0x77,0x2B,0x37,0xCA,0x19,0x3D,0xB6,
107 0xB4,0xEB,0xC9,0xC8,0x76,0x75,0x07,0xE5,0x24,0x8C,0xB1,0xA3,0x29,0x53,0x54,0x43,
108 0xFC,0xE3,0x40,0x5B,0x31,0xC6,0x43,0x13,0x62,0xA8,0x1B,0xB9,0xE2,0xED,0x33,0x40,
109 0x0A,0xAB,0x43,0x69,0x31,0x4A,0x13,0x7B,0xCB,0xC8,0x33,0x93,0xDE,0x70,0xAD,0x80,
110 0x29,0xBF,0x9E,
111 };
112
113 /* Normal code signing certificate, issued by CA above
114 */
115 unsigned char leafSigningCertificate[1007]={
116 0x30,0x82,0x03,0xEB,0x30,0x82,0x02,0xD3,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x78,
117 0x0C,0xC5,0xD9,0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,
118 0x30,0x81,0x9F,0x31,0x31,0x30,0x2F,0x06,0x03,0x55,0x04,0x03,0x0C,0x28,0x43,0x6F,
119 0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x43,
120 0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,
121 0x68,0x6F,0x72,0x69,0x74,0x79,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,
122 0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x27,0x30,0x25,0x06,
123 0x03,0x55,0x04,0x0B,0x0C,0x1E,0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x20,0x2D,0x20,
124 0x44,0x45,0x56,0x45,0x4C,0x4F,0x50,0x4D,0x45,0x4E,0x54,0x20,0x55,0x53,0x45,0x20,
125 0x4F,0x4E,0x4C,0x59,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,
126 0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,
127 0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,
128 0x6E,0x6F,0x30,0x1E,0x17,0x0D,0x31,0x34,0x31,0x30,0x33,0x30,0x32,0x32,0x34,0x37,
129 0x32,0x30,0x5A,0x17,0x0D,0x31,0x35,0x31,0x30,0x33,0x30,0x32,0x32,0x34,0x37,0x32,
130 0x30,0x5A,0x30,0x81,0xA4,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x03,0x0C,0x0E,
131 0x52,0x61,0x64,0x61,0x72,0x20,0x31,0x37,0x31,0x35,0x39,0x32,0x32,0x37,0x31,0x13,
132 0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,
133 0x6E,0x63,0x2E,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0B,0x0C,0x10,0x43,0x6F,
134 0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x31,0x0B,
135 0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,
136 0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,
137 0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,
138 0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,
139 0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,
140 0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,
141 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,
142 0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xD0,0x6A,0xA3,0x00,0xEE,0xFC,
143 0x30,0x30,0x8C,0x4F,0xC1,0x51,0x7C,0x6E,0xF6,0x45,0x3C,0xE5,0x41,0xAB,0x77,0xDB,
144 0xEE,0x73,0x9E,0xE3,0x21,0xBF,0x89,0x3F,0xA7,0xBF,0x23,0x0B,0x3F,0x68,0xF6,0xA4,
145 0x80,0xB7,0xF4,0xE3,0xF0,0x10,0x21,0xF0,0xF6,0xBB,0x97,0x08,0x9E,0xA9,0xD0,0x9F,
146 0xAB,0xC8,0xF8,0xE9,0xFB,0x9A,0x89,0x2C,0x3C,0x30,0x93,0x92,0x9D,0x08,0x2C,0x0F,
147 0x63,0x1C,0xCC,0x4E,0x69,0x0E,0x62,0x9F,0xA6,0x3E,0xAE,0x8B,0x76,0x60,0x6F,0xD9,
148 0x5D,0xD2,0xBD,0x38,0x95,0xAA,0x22,0xFD,0xCE,0xDF,0x41,0x15,0x79,0x5E,0x4C,0xAB,
149 0x51,0x90,0x3D,0xD7,0x41,0xC3,0x90,0x41,0x58,0xEC,0xB4,0xB5,0x5A,0xBD,0x58,0x1B,
150 0x38,0x5D,0xFE,0xB6,0x55,0xA0,0xDA,0x67,0xDF,0x34,0x4F,0x3E,0xE2,0x1A,0xF1,0x8C,
151 0x44,0x57,0x2E,0xBB,0xE3,0x19,0xFA,0x08,0xE3,0xF1,0x9C,0x17,0xA2,0xDE,0x74,0xF4,
152 0xF7,0x5D,0x6B,0xA2,0xE8,0x2B,0xB3,0xF0,0x3B,0x77,0x4C,0xAE,0x63,0xCA,0xAD,0xB1,
153 0xBB,0x32,0x71,0xE0,0xC2,0x8D,0x6B,0x7B,0x3E,0xB4,0xAC,0x61,0xCA,0x40,0xDC,0xEA,
154 0xE4,0xA7,0x2C,0xA4,0xE4,0x40,0xCC,0xD1,0x1F,0xE9,0x05,0x91,0xA9,0x44,0x54,0xB2,
155 0x96,0x66,0xC5,0xF2,0x28,0xBF,0xA6,0xDA,0xA5,0xD8,0x09,0x53,0x08,0xF6,0x7D,0x09,
156 0xA3,0x6C,0x40,0x7B,0x3C,0x8D,0x09,0xE8,0xED,0xD2,0x55,0x86,0x1B,0x42,0x1C,0x72,
157 0xAB,0xAB,0xF2,0x6F,0x0B,0xB4,0x6F,0xCB,0xE7,0x59,0x29,0xFB,0x6A,0x4A,0x91,0xF4,
158 0x8C,0xFC,0xA0,0xF8,0x8B,0x55,0x4A,0xD3,0x3A,0x41,0x02,0x03,0x01,0x00,0x01,0xA3,
159 0x2A,0x30,0x28,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,
160 0x02,0x07,0x80,0x30,0x16,0x06,0x03,0x55,0x1D,0x25,0x01,0x01,0xFF,0x04,0x0C,0x30,
161 0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x0D,0x06,0x09,0x2A,
162 0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x60,
163 0xF9,0x1C,0xE5,0x5E,0xCE,0x79,0x57,0x7E,0x24,0xC1,0x7E,0x07,0x87,0xC6,0x55,0x6E,
164 0x38,0xBB,0x17,0x0B,0xAE,0xBC,0xDB,0x72,0xBD,0xA0,0x47,0x2F,0x54,0x34,0x53,0xE7,
165 0x21,0xD7,0x04,0x8B,0x06,0x84,0x76,0x81,0x2A,0x6A,0x75,0x06,0xB4,0x62,0xA0,0xBC,
166 0xC3,0x78,0x08,0x50,0x3D,0x63,0x44,0x32,0xEA,0xDA,0xFA,0x66,0xDF,0xF9,0xC2,0xE8,
167 0xEF,0x72,0x83,0xAF,0x3E,0x2F,0x20,0x83,0x08,0x61,0xD8,0x6A,0x1A,0x71,0x68,0xB8,
168 0x21,0x1F,0x0E,0xA8,0x2A,0xDA,0xF0,0x87,0xB1,0xAC,0xCE,0xAB,0xFB,0x9C,0xBC,0x43,
169 0x04,0xE5,0x2F,0xF3,0x7D,0xAD,0x78,0x43,0x00,0x74,0x65,0x28,0x8D,0x3F,0x27,0x8F,
170 0x33,0x7B,0x36,0xCD,0xAF,0x35,0x33,0xAF,0x06,0xF5,0x22,0x67,0xC7,0xD1,0x88,0x9B,
171 0x55,0xE8,0x0E,0x48,0x5F,0x9A,0x30,0x5A,0xF5,0x93,0x53,0x78,0x44,0x8B,0x3A,0xB6,
172 0x24,0x7F,0x5D,0x6E,0xDB,0x68,0x72,0x15,0xAD,0xB8,0x3E,0x66,0xE7,0x0E,0x99,0xEB,
173 0xAB,0x1D,0x91,0xC8,0xEF,0x5A,0x32,0xA9,0x3E,0x0B,0x82,0x4E,0x5A,0x64,0xC1,0xC5,
174 0xFD,0xD0,0x93,0xE0,0x82,0x39,0x7C,0x94,0x78,0x23,0x5D,0x5E,0x65,0x67,0xB9,0x83,
175 0xEB,0x3A,0xC6,0x6C,0x65,0x8A,0xC6,0x83,0x2F,0x90,0x4C,0x75,0x7F,0x7A,0x2F,0x3E,
176 0xA8,0xAA,0x16,0xF5,0x67,0x5D,0x50,0xC7,0x0E,0x7F,0x7C,0xA2,0xC8,0x10,0x67,0xFD,
177 0x3E,0x91,0xA4,0xD5,0xA0,0xF6,0x9D,0x5A,0x0E,0x56,0xC0,0xCA,0xBA,0xB4,0x8B,0xB1,
178 0xB5,0x3A,0x22,0xC0,0xEC,0xF8,0x8F,0xD7,0x49,0xBE,0x8D,0x98,0xE0,0x30,0x0E,
179 };
180
181 /* This certificate is longer than the length claimed in its top-level ASN.1 sequence.
182 It is only supposed to be 1007 bytes, but has 16 extra bytes tacked onto the end.
183 */
184 unsigned char bogusTrailingBytesSigningCertificate[1023]={
185 0x30,0x82,0x03,0xEB,0x30,0x82,0x02,0xD3,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x78,
186 0x0C,0xC5,0xD9,0x30,0x0B,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,
187 0x30,0x81,0x9F,0x31,0x31,0x30,0x2F,0x06,0x03,0x55,0x04,0x03,0x0C,0x28,0x43,0x6F,
188 0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x43,
189 0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,
190 0x68,0x6F,0x72,0x69,0x74,0x79,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,
191 0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x27,0x30,0x25,0x06,
192 0x03,0x55,0x04,0x0B,0x0C,0x1E,0x43,0x6F,0x72,0x65,0x20,0x4F,0x53,0x20,0x2D,0x20,
193 0x44,0x45,0x56,0x45,0x4C,0x4F,0x50,0x4D,0x45,0x4E,0x54,0x20,0x55,0x53,0x45,0x20,
194 0x4F,0x4E,0x4C,0x59,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,
195 0x41,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,
196 0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,
197 0x6E,0x6F,0x30,0x1E,0x17,0x0D,0x31,0x34,0x31,0x30,0x33,0x30,0x32,0x32,0x34,0x37,
198 0x32,0x30,0x5A,0x17,0x0D,0x31,0x35,0x31,0x30,0x33,0x30,0x32,0x32,0x34,0x37,0x32,
199 0x30,0x5A,0x30,0x81,0xA4,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x03,0x0C,0x0E,
200 0x52,0x61,0x64,0x61,0x72,0x20,0x31,0x37,0x31,0x35,0x39,0x32,0x32,0x37,0x31,0x13,
201 0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,
202 0x6E,0x63,0x2E,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0B,0x0C,0x10,0x43,0x6F,
203 0x72,0x65,0x20,0x4F,0x53,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x31,0x0B,
204 0x30,0x09,0x06,0x03,0x55,0x04,0x08,0x0C,0x02,0x43,0x41,0x31,0x0B,0x30,0x09,0x06,
205 0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,
206 0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x2B,0x30,0x29,
207 0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x1C,0x73,0x65,0x63,
208 0x75,0x72,0x69,0x74,0x79,0x2D,0x64,0x65,0x76,0x40,0x67,0x72,0x6F,0x75,0x70,0x2E,
209 0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,
210 0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,
211 0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xD0,0x6A,0xA3,0x00,0xEE,0xFC,
212 0x30,0x30,0x8C,0x4F,0xC1,0x51,0x7C,0x6E,0xF6,0x45,0x3C,0xE5,0x41,0xAB,0x77,0xDB,
213 0xEE,0x73,0x9E,0xE3,0x21,0xBF,0x89,0x3F,0xA7,0xBF,0x23,0x0B,0x3F,0x68,0xF6,0xA4,
214 0x80,0xB7,0xF4,0xE3,0xF0,0x10,0x21,0xF0,0xF6,0xBB,0x97,0x08,0x9E,0xA9,0xD0,0x9F,
215 0xAB,0xC8,0xF8,0xE9,0xFB,0x9A,0x89,0x2C,0x3C,0x30,0x93,0x92,0x9D,0x08,0x2C,0x0F,
216 0x63,0x1C,0xCC,0x4E,0x69,0x0E,0x62,0x9F,0xA6,0x3E,0xAE,0x8B,0x76,0x60,0x6F,0xD9,
217 0x5D,0xD2,0xBD,0x38,0x95,0xAA,0x22,0xFD,0xCE,0xDF,0x41,0x15,0x79,0x5E,0x4C,0xAB,
218 0x51,0x90,0x3D,0xD7,0x41,0xC3,0x90,0x41,0x58,0xEC,0xB4,0xB5,0x5A,0xBD,0x58,0x1B,
219 0x38,0x5D,0xFE,0xB6,0x55,0xA0,0xDA,0x67,0xDF,0x34,0x4F,0x3E,0xE2,0x1A,0xF1,0x8C,
220 0x44,0x57,0x2E,0xBB,0xE3,0x19,0xFA,0x08,0xE3,0xF1,0x9C,0x17,0xA2,0xDE,0x74,0xF4,
221 0xF7,0x5D,0x6B,0xA2,0xE8,0x2B,0xB3,0xF0,0x3B,0x77,0x4C,0xAE,0x63,0xCA,0xAD,0xB1,
222 0xBB,0x32,0x71,0xE0,0xC2,0x8D,0x6B,0x7B,0x3E,0xB4,0xAC,0x61,0xCA,0x40,0xDC,0xEA,
223 0xE4,0xA7,0x2C,0xA4,0xE4,0x40,0xCC,0xD1,0x1F,0xE9,0x05,0x91,0xA9,0x44,0x54,0xB2,
224 0x96,0x66,0xC5,0xF2,0x28,0xBF,0xA6,0xDA,0xA5,0xD8,0x09,0x53,0x08,0xF6,0x7D,0x09,
225 0xA3,0x6C,0x40,0x7B,0x3C,0x8D,0x09,0xE8,0xED,0xD2,0x55,0x86,0x1B,0x42,0x1C,0x72,
226 0xAB,0xAB,0xF2,0x6F,0x0B,0xB4,0x6F,0xCB,0xE7,0x59,0x29,0xFB,0x6A,0x4A,0x91,0xF4,
227 0x8C,0xFC,0xA0,0xF8,0x8B,0x55,0x4A,0xD3,0x3A,0x41,0x02,0x03,0x01,0x00,0x01,0xA3,
228 0x2A,0x30,0x28,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,
229 0x02,0x07,0x80,0x30,0x16,0x06,0x03,0x55,0x1D,0x25,0x01,0x01,0xFF,0x04,0x0C,0x30,
230 0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03,0x30,0x0D,0x06,0x09,0x2A,
231 0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x60,
232 0xF9,0x1C,0xE5,0x5E,0xCE,0x79,0x57,0x7E,0x24,0xC1,0x7E,0x07,0x87,0xC6,0x55,0x6E,
233 0x38,0xBB,0x17,0x0B,0xAE,0xBC,0xDB,0x72,0xBD,0xA0,0x47,0x2F,0x54,0x34,0x53,0xE7,
234 0x21,0xD7,0x04,0x8B,0x06,0x84,0x76,0x81,0x2A,0x6A,0x75,0x06,0xB4,0x62,0xA0,0xBC,
235 0xC3,0x78,0x08,0x50,0x3D,0x63,0x44,0x32,0xEA,0xDA,0xFA,0x66,0xDF,0xF9,0xC2,0xE8,
236 0xEF,0x72,0x83,0xAF,0x3E,0x2F,0x20,0x83,0x08,0x61,0xD8,0x6A,0x1A,0x71,0x68,0xB8,
237 0x21,0x1F,0x0E,0xA8,0x2A,0xDA,0xF0,0x87,0xB1,0xAC,0xCE,0xAB,0xFB,0x9C,0xBC,0x43,
238 0x04,0xE5,0x2F,0xF3,0x7D,0xAD,0x78,0x43,0x00,0x74,0x65,0x28,0x8D,0x3F,0x27,0x8F,
239 0x33,0x7B,0x36,0xCD,0xAF,0x35,0x33,0xAF,0x06,0xF5,0x22,0x67,0xC7,0xD1,0x88,0x9B,
240 0x55,0xE8,0x0E,0x48,0x5F,0x9A,0x30,0x5A,0xF5,0x93,0x53,0x78,0x44,0x8B,0x3A,0xB6,
241 0x24,0x7F,0x5D,0x6E,0xDB,0x68,0x72,0x15,0xAD,0xB8,0x3E,0x66,0xE7,0x0E,0x99,0xEB,
242 0xAB,0x1D,0x91,0xC8,0xEF,0x5A,0x32,0xA9,0x3E,0x0B,0x82,0x4E,0x5A,0x64,0xC1,0xC5,
243 0xFD,0xD0,0x93,0xE0,0x82,0x39,0x7C,0x94,0x78,0x23,0x5D,0x5E,0x65,0x67,0xB9,0x83,
244 0xEB,0x3A,0xC6,0x6C,0x65,0x8A,0xC6,0x83,0x2F,0x90,0x4C,0x75,0x7F,0x7A,0x2F,0x3E,
245 0xA8,0xAA,0x16,0xF5,0x67,0x5D,0x50,0xC7,0x0E,0x7F,0x7C,0xA2,0xC8,0x10,0x67,0xFD,
246 0x3E,0x91,0xA4,0xD5,0xA0,0xF6,0x9D,0x5A,0x0E,0x56,0xC0,0xCA,0xBA,0xB4,0x8B,0xB1,
247 0xB5,0x3A,0x22,0xC0,0xEC,0xF8,0x8F,0xD7,0x49,0xBE,0x8D,0x98,0xE0,0x30,0x0E,0x45,
248 0x4E,0x44,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x41,0x3D,0x3D
249 };
250
251 unsigned char TestIdentity_p12[2697] = {
252 0x30, 0x82, 0x0a, 0x85, 0x02, 0x01, 0x03, 0x30, 0x82, 0x0a, 0x4c, 0x06,
253 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82,
254 0x0a, 0x3d, 0x04, 0x82, 0x0a, 0x39, 0x30, 0x82, 0x0a, 0x35, 0x30, 0x82,
255 0x04, 0xbf, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07,
256 0x06, 0xa0, 0x82, 0x04, 0xb0, 0x30, 0x82, 0x04, 0xac, 0x02, 0x01, 0x00,
257 0x30, 0x82, 0x04, 0xa5, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
258 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7,
259 0x0d, 0x01, 0x0c, 0x01, 0x06, 0x30, 0x0e, 0x04, 0x08, 0x6c, 0x66, 0xc0,
260 0x46, 0x37, 0xb4, 0x92, 0x0b, 0x02, 0x02, 0x08, 0x00, 0x80, 0x82, 0x04,
261 0x78, 0x6d, 0xb4, 0x7c, 0xb4, 0x7f, 0x50, 0xfb, 0x09, 0x7a, 0xb5, 0x77,
262 0x13, 0x05, 0x98, 0x98, 0x04, 0x34, 0xd1, 0xc9, 0xca, 0x97, 0x69, 0x33,
263 0x28, 0xda, 0x58, 0xa6, 0x82, 0x0e, 0x1e, 0x05, 0x46, 0x47, 0x77, 0x90,
264 0xa1, 0xd6, 0x2b, 0xb9, 0x18, 0x89, 0x3c, 0x8a, 0x2e, 0xec, 0xd3, 0x98,
265 0x0b, 0x7b, 0x63, 0x12, 0xf3, 0x5d, 0x62, 0xc4, 0x8d, 0x52, 0xaa, 0xab,
266 0x67, 0xde, 0x46, 0x93, 0xdc, 0x9d, 0x1d, 0x29, 0xfb, 0x34, 0x7b, 0x84,
267 0xfa, 0x1f, 0x5b, 0x53, 0x1d, 0xab, 0x9e, 0x62, 0x4f, 0x48, 0x4e, 0xd0,
268 0x99, 0x1a, 0xfc, 0x60, 0x99, 0x71, 0x3f, 0xe2, 0xd7, 0xc5, 0xb2, 0x34,
269 0x24, 0x85, 0x3f, 0x3a, 0x4a, 0x40, 0x34, 0xa8, 0xc5, 0xbc, 0xa3, 0xfe,
270 0x3a, 0x7c, 0xdc, 0x96, 0xf3, 0x34, 0x8b, 0xc1, 0xb0, 0xb0, 0x3f, 0x51,
271 0xe2, 0x6d, 0x5e, 0x76, 0xb8, 0x44, 0x8d, 0xff, 0x65, 0xe3, 0x42, 0x05,
272 0x30, 0xa0, 0x78, 0x7f, 0x69, 0xc7, 0x6f, 0x82, 0x05, 0x20, 0x69, 0x64,
273 0x59, 0x84, 0xe1, 0x42, 0x37, 0x41, 0xc5, 0x78, 0x15, 0x2b, 0x77, 0x20,
274 0xb8, 0x31, 0x4b, 0x4d, 0xbd, 0x2d, 0xa5, 0xce, 0x65, 0x56, 0xfb, 0x5a,
275 0xfc, 0xe1, 0xdb, 0x60, 0x20, 0x1b, 0x5a, 0x91, 0x53, 0x36, 0x62, 0xdf,
276 0xb5, 0x4e, 0xf2, 0xc9, 0xce, 0xeb, 0xd4, 0x85, 0xf9, 0xe6, 0x8b, 0x60,
277 0xf3, 0x99, 0xfa, 0x4c, 0x13, 0x35, 0x8f, 0x17, 0x3b, 0xe3, 0x74, 0xc7,
278 0x7e, 0xb1, 0xf6, 0x8f, 0x4d, 0xdd, 0x40, 0xd6, 0x31, 0x84, 0x83, 0x54,
279 0x75, 0x7a, 0xc0, 0xa7, 0xc4, 0x3a, 0xc8, 0x17, 0x87, 0x0d, 0x8f, 0x4f,
280 0x0f, 0x8e, 0x6e, 0x08, 0xb8, 0x0a, 0x86, 0x61, 0x03, 0x18, 0xad, 0xd3,
281 0x43, 0xe7, 0x87, 0x62, 0x3e, 0x6c, 0xb5, 0x30, 0x81, 0xe0, 0x69, 0xe3,
282 0x6a, 0x1f, 0x3c, 0x5f, 0x48, 0xa6, 0x38, 0x06, 0xbf, 0x5e, 0x43, 0x05,
283 0xc8, 0x66, 0x97, 0xdd, 0x1c, 0x25, 0xba, 0x20, 0x44, 0xc6, 0x05, 0x31,
284 0xdd, 0x6a, 0xc1, 0x10, 0xe0, 0x63, 0x80, 0xac, 0x0b, 0x55, 0x83, 0x75,
285 0xc2, 0xb3, 0x39, 0xb7, 0x6b, 0x7c, 0xf6, 0x69, 0x3d, 0x6c, 0xcd, 0x35,
286 0xaf, 0x25, 0xb0, 0xb2, 0x0a, 0xff, 0x33, 0xf3, 0x41, 0x38, 0x39, 0xa6,
287 0xd0, 0x38, 0xb5, 0x89, 0xd5, 0xf0, 0x3c, 0x5c, 0x29, 0x8f, 0xc8, 0x1c,
288 0x74, 0xe9, 0x35, 0xc8, 0x9e, 0x3a, 0xcd, 0x84, 0xdb, 0x95, 0x55, 0x57,
289 0xa8, 0xe7, 0xc5, 0x58, 0xa8, 0xe6, 0xb0, 0x34, 0xbd, 0xa4, 0x00, 0x0c,
290 0xb3, 0x1a, 0x00, 0xb2, 0x7d, 0xcd, 0x74, 0x22, 0xaa, 0x8f, 0x0d, 0xe4,
291 0x99, 0x26, 0xcd, 0x81, 0x4f, 0xe1, 0xe1, 0x96, 0x41, 0xc6, 0x08, 0x1b,
292 0x2c, 0xc7, 0x9e, 0xe6, 0x63, 0x4a, 0x1c, 0x4d, 0xbb, 0x44, 0xeb, 0xb9,
293 0xd5, 0x7a, 0x55, 0xd2, 0x58, 0xa0, 0x8f, 0x4b, 0xf1, 0xdf, 0xc6, 0x67,
294 0x7c, 0xe8, 0xf5, 0x65, 0xca, 0x52, 0xdd, 0xa6, 0x7c, 0xa9, 0x0d, 0x7e,
295 0xec, 0x12, 0x57, 0xef, 0x09, 0x78, 0xdf, 0x40, 0x48, 0xb3, 0x6c, 0xad,
296 0xef, 0x5a, 0x81, 0x44, 0xdc, 0x1f, 0x66, 0xf6, 0x2c, 0xbe, 0xf6, 0x07,
297 0xc8, 0xb8, 0xff, 0xf3, 0x52, 0xe5, 0x15, 0xc8, 0xe0, 0xc9, 0x60, 0xea,
298 0x26, 0x21, 0xa3, 0x21, 0x99, 0x00, 0x84, 0x18, 0x5c, 0x84, 0x16, 0xd0,
299 0xf1, 0x63, 0x56, 0x7b, 0xf6, 0x66, 0x43, 0xcc, 0x1e, 0x3c, 0x1a, 0x8d,
300 0x8d, 0x3f, 0xf6, 0xf1, 0xcf, 0x04, 0xbf, 0xfb, 0x96, 0x63, 0x50, 0x61,
301 0xfd, 0x59, 0x66, 0x2e, 0xd7, 0xb4, 0xd8, 0x63, 0x94, 0xe1, 0x59, 0x96,
302 0x9c, 0x31, 0x8a, 0x7a, 0x6d, 0x3a, 0x79, 0xb6, 0xb9, 0xb3, 0xc3, 0xc3,
303 0xb8, 0xd3, 0x01, 0x02, 0x94, 0xec, 0x3a, 0x0c, 0x0e, 0x43, 0xef, 0x67,
304 0x95, 0xe6, 0xef, 0xa3, 0x98, 0x03, 0x8e, 0x7d, 0x38, 0xd4, 0xaa, 0xd3,
305 0xb1, 0x2c, 0x2b, 0x02, 0x76, 0x48, 0x7c, 0x5d, 0x74, 0x0e, 0x43, 0x00,
306 0xf8, 0xc7, 0x65, 0xb3, 0x0d, 0xd3, 0xc3, 0x06, 0xe1, 0x77, 0xa7, 0x54,
307 0x85, 0x81, 0xcb, 0xfd, 0x79, 0x0a, 0xe2, 0x9f, 0xe9, 0xe6, 0x9d, 0xc6,
308 0xa7, 0x5b, 0xc6, 0xb1, 0x2a, 0xe1, 0x9c, 0x79, 0x81, 0xa6, 0xac, 0x57,
309 0xa7, 0xe5, 0x96, 0x3e, 0xb7, 0x49, 0xc2, 0xcf, 0x71, 0x5b, 0x90, 0x3b,
310 0x59, 0x9a, 0x69, 0x24, 0x5f, 0xb7, 0x73, 0xad, 0x2c, 0x35, 0xbe, 0xcc,
311 0xd2, 0xb0, 0xe5, 0x3e, 0x86, 0x72, 0xbb, 0xe5, 0x0f, 0x34, 0x1c, 0xd5,
312 0x33, 0x78, 0x41, 0xf3, 0xb8, 0x3b, 0x2f, 0x63, 0x87, 0x48, 0x05, 0xc4,
313 0x29, 0x98, 0x60, 0x2f, 0xab, 0x87, 0x65, 0xdd, 0x22, 0x30, 0x48, 0xc5,
314 0x68, 0x29, 0xbf, 0x0d, 0x53, 0x10, 0x0f, 0x9e, 0x6d, 0xff, 0x4f, 0x9e,
315 0xab, 0x27, 0xb9, 0xca, 0xa8, 0x69, 0x5c, 0x36, 0x25, 0x48, 0xac, 0x84,
316 0xcb, 0x65, 0x75, 0xec, 0xc4, 0x21, 0xf5, 0x02, 0x9d, 0x4d, 0xa9, 0x58,
317 0x20, 0xae, 0x03, 0x14, 0xe4, 0x99, 0xe1, 0x22, 0x41, 0x49, 0x6b, 0x5b,
318 0x8e, 0x22, 0xb8, 0x12, 0x7e, 0x79, 0xe6, 0x74, 0x91, 0xaa, 0xf3, 0x98,
319 0xd8, 0x4c, 0xc1, 0xb6, 0xd7, 0x21, 0x94, 0x38, 0xa1, 0xd1, 0xa7, 0x18,
320 0x90, 0xf1, 0x60, 0xef, 0x69, 0x05, 0x26, 0xbe, 0x76, 0xd1, 0xd5, 0x56,
321 0x08, 0x02, 0x86, 0x33, 0x7f, 0x7d, 0xc5, 0xf4, 0x62, 0x0b, 0x5f, 0xbf,
322 0x6f, 0x58, 0x31, 0xa7, 0xce, 0xe6, 0xeb, 0x5c, 0x68, 0x97, 0xd5, 0x7d,
323 0xf3, 0xfb, 0x69, 0x03, 0x50, 0xac, 0x6d, 0x79, 0x83, 0x04, 0x31, 0x6e,
324 0x5b, 0x8b, 0x0a, 0x47, 0x14, 0xc1, 0xd2, 0xa2, 0x9d, 0xae, 0x4c, 0xa6,
325 0xe9, 0xa6, 0xb1, 0x6d, 0x9b, 0x71, 0x49, 0x89, 0x71, 0x8a, 0x9f, 0xdd,
326 0xc8, 0xc1, 0x95, 0x14, 0x69, 0x69, 0x66, 0xd8, 0xd9, 0xa4, 0x37, 0x1a,
327 0xdd, 0x47, 0x2c, 0xfb, 0x4a, 0x75, 0x9b, 0x02, 0x9f, 0x56, 0xdd, 0xf2,
328 0xbb, 0x24, 0x38, 0x8f, 0x97, 0x9a, 0x0a, 0x61, 0xfa, 0x3b, 0xe6, 0x43,
329 0xa9, 0x88, 0xd0, 0x0d, 0x65, 0x1c, 0x55, 0x67, 0x5e, 0x37, 0xd6, 0x50,
330 0x0f, 0x58, 0x2e, 0x62, 0xac, 0x02, 0xbc, 0xdb, 0xf3, 0xea, 0xc4, 0x97,
331 0x33, 0xf6, 0x48, 0x19, 0xb5, 0x59, 0x76, 0xd0, 0xb1, 0x5c, 0x0f, 0x02,
332 0x6b, 0x8b, 0xf8, 0x91, 0x17, 0x15, 0xcb, 0xaf, 0xa7, 0x4f, 0xfe, 0x5a,
333 0x04, 0x6f, 0xd8, 0x15, 0xae, 0x59, 0x8e, 0xd4, 0xfc, 0xcd, 0x21, 0xfd,
334 0x2a, 0x50, 0x4b, 0x4b, 0x2b, 0x0e, 0xcd, 0xd4, 0x66, 0x99, 0xe8, 0x3d,
335 0x6b, 0xad, 0x60, 0x4d, 0x40, 0xd5, 0xf5, 0xe5, 0x85, 0x19, 0xa6, 0xe0,
336 0x7e, 0x1c, 0x21, 0x00, 0x04, 0x4a, 0xd2, 0x90, 0xa6, 0xf5, 0xbf, 0xa4,
337 0xaf, 0x85, 0x8f, 0xec, 0xdf, 0x6d, 0xae, 0x88, 0xd5, 0x6b, 0x82, 0x8b,
338 0x6c, 0xc8, 0xb7, 0x7b, 0x70, 0x16, 0x30, 0xda, 0x97, 0x33, 0x0c, 0x21,
339 0x32, 0x54, 0x76, 0xe3, 0x63, 0x45, 0x8a, 0xdf, 0x07, 0xea, 0x23, 0x9b,
340 0xf8, 0xbd, 0x91, 0xe2, 0x47, 0x44, 0x55, 0x8e, 0xd2, 0xff, 0x1c, 0xef,
341 0x40, 0xe5, 0x69, 0xba, 0xfd, 0x4d, 0x34, 0x96, 0x80, 0x6c, 0x23, 0xbc,
342 0x0f, 0x6d, 0xac, 0x6b, 0xa4, 0x69, 0xf8, 0x4a, 0x6e, 0xe6, 0x7a, 0xa9,
343 0x1d, 0xf1, 0x51, 0xfe, 0xb5, 0x00, 0x86, 0xb7, 0x8b, 0x72, 0xb3, 0x56,
344 0x9d, 0x44, 0xde, 0x38, 0xe7, 0x34, 0xa9, 0xe9, 0x27, 0xfa, 0x48, 0x3f,
345 0xc7, 0x17, 0xe2, 0x8c, 0x28, 0xc1, 0xec, 0x90, 0xfe, 0x31, 0xb8, 0xd7,
346 0x11, 0x69, 0xf8, 0xa6, 0x61, 0xa8, 0x4b, 0xeb, 0xa4, 0x0d, 0xae, 0x1c,
347 0x50, 0xc1, 0x4e, 0x5b, 0xd5, 0xc5, 0x66, 0x89, 0x32, 0x88, 0x3a, 0x40,
348 0x0d, 0x6e, 0xb4, 0xf4, 0x29, 0xf9, 0xc8, 0x85, 0xe3, 0x0a, 0xe0, 0xb6,
349 0xb3, 0x49, 0x70, 0xf6, 0x5d, 0xd2, 0x62, 0x41, 0x92, 0x6e, 0xb5, 0x5d,
350 0x85, 0xf0, 0x1e, 0xb8, 0xca, 0xbb, 0x07, 0x88, 0x6f, 0x69, 0xea, 0xe4,
351 0xbb, 0x58, 0xb2, 0x6c, 0x86, 0x43, 0x04, 0xb7, 0xef, 0xc0, 0xc2, 0xeb,
352 0x82, 0x33, 0xb7, 0x3c, 0xd7, 0x24, 0x40, 0x96, 0x30, 0x60, 0x82, 0xe2,
353 0x00, 0x63, 0xd6, 0x06, 0x51, 0xc8, 0x3c, 0x77, 0x6c, 0x33, 0x02, 0x9a,
354 0xf4, 0xc5, 0xb7, 0x25, 0x4a, 0x4a, 0x65, 0x8f, 0x04, 0xfb, 0x22, 0xbb,
355 0xf0, 0x0f, 0x7e, 0x8b, 0x50, 0x74, 0x2a, 0xcf, 0xc4, 0xcf, 0xe0, 0xe6,
356 0x35, 0xf5, 0x89, 0x8f, 0xe0, 0x30, 0x82, 0x05, 0x6e, 0x06, 0x09, 0x2a,
357 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x05, 0x5f,
358 0x04, 0x82, 0x05, 0x5b, 0x30, 0x82, 0x05, 0x57, 0x30, 0x82, 0x05, 0x53,
359 0x06, 0x0b, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01,
360 0x02, 0xa0, 0x82, 0x04, 0xee, 0x30, 0x82, 0x04, 0xea, 0x30, 0x1c, 0x06,
361 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30,
362 0x0e, 0x04, 0x08, 0x38, 0xc0, 0x89, 0x4d, 0x2c, 0xbc, 0x90, 0xef, 0x02,
363 0x02, 0x08, 0x00, 0x04, 0x82, 0x04, 0xc8, 0x63, 0xb1, 0xd7, 0x6a, 0x1a,
364 0x2f, 0xd9, 0xee, 0x2b, 0xf6, 0x92, 0x2d, 0xf8, 0x90, 0x04, 0x0e, 0x62,
365 0xa4, 0x0a, 0x96, 0x12, 0x57, 0xe5, 0x95, 0x12, 0x61, 0xc8, 0x3e, 0x7f,
366 0xe4, 0x2e, 0xbb, 0xa0, 0xdc, 0x6b, 0x77, 0x58, 0x39, 0xf0, 0xb7, 0x20,
367 0xc6, 0x24, 0x6f, 0x24, 0xd9, 0xc4, 0x42, 0xb2, 0x1b, 0x97, 0xf9, 0x71,
368 0x70, 0x8d, 0x08, 0x75, 0x65, 0xb8, 0x16, 0xbf, 0x29, 0x1e, 0x1e, 0x42,
369 0x1e, 0xa4, 0xda, 0x7e, 0x78, 0xc5, 0x98, 0x9a, 0x79, 0xf4, 0x89, 0x2c,
370 0x0e, 0xfa, 0x72, 0x21, 0xde, 0x75, 0x34, 0x55, 0xfb, 0xa1, 0x3a, 0x6a,
371 0xc7, 0x0e, 0x68, 0xd8, 0x4b, 0xe4, 0x47, 0x04, 0xa2, 0x92, 0x68, 0xd0,
372 0x01, 0xcc, 0x42, 0x1f, 0xdf, 0x24, 0xba, 0xac, 0x05, 0x91, 0x23, 0x96,
373 0xf2, 0x94, 0x2d, 0xcb, 0x6f, 0xac, 0xea, 0x7a, 0x52, 0x7c, 0x00, 0xe5,
374 0x7c, 0x73, 0xf1, 0xdd, 0x89, 0x05, 0x16, 0x87, 0x08, 0x7a, 0x3d, 0xa9,
375 0x48, 0x99, 0x60, 0x01, 0xd7, 0x34, 0xf6, 0x7a, 0x90, 0xc8, 0x00, 0xa0,
376 0xc3, 0x97, 0x62, 0x06, 0xab, 0x14, 0x4c, 0x0b, 0x0f, 0x88, 0x59, 0x3c,
377 0x40, 0x47, 0x97, 0xcc, 0xa2, 0x6c, 0x5b, 0x09, 0x9c, 0x2d, 0xa2, 0x60,
378 0xb4, 0xfe, 0x86, 0x58, 0x22, 0xeb, 0x7e, 0xab, 0xdb, 0x90, 0x00, 0x8d,
379 0x59, 0xb5, 0xfa, 0x8d, 0x3f, 0x7a, 0x02, 0x4b, 0x5e, 0x11, 0x24, 0x95,
380 0x6f, 0xad, 0x2c, 0x15, 0xd7, 0x76, 0xa3, 0x8c, 0xfa, 0x38, 0xf5, 0x5a,
381 0x2e, 0xd8, 0xee, 0x7d, 0xd7, 0xde, 0x67, 0x7c, 0x27, 0xd0, 0x4a, 0x18,
382 0xbb, 0x7c, 0x15, 0x13, 0x37, 0xd2, 0xce, 0x9d, 0xf9, 0xf6, 0x10, 0xb8,
383 0xbd, 0x39, 0xa3, 0x27, 0xf2, 0x93, 0x8a, 0x6f, 0x4c, 0xe2, 0xca, 0x13,
384 0xf1, 0x2c, 0x22, 0x3b, 0x8a, 0x45, 0xf9, 0x06, 0x23, 0x9f, 0x8d, 0xa1,
385 0xd9, 0x35, 0x08, 0xb4, 0xdb, 0x48, 0x86, 0x64, 0x42, 0x0f, 0x4e, 0x5d,
386 0xa9, 0xf2, 0x2c, 0xbd, 0x22, 0xcb, 0xa5, 0xbf, 0x40, 0xdd, 0x21, 0x80,
387 0x23, 0xa4, 0xee, 0xc2, 0x9d, 0xb8, 0x78, 0x49, 0x82, 0x5e, 0x32, 0x85,
388 0xb5, 0xfe, 0x28, 0x61, 0x13, 0xb3, 0x1e, 0x66, 0xad, 0xcc, 0x10, 0x7f,
389 0x9e, 0x2f, 0x12, 0x38, 0x79, 0x6d, 0x59, 0x6b, 0xd6, 0x9d, 0xa7, 0xb7,
390 0xec, 0x55, 0xb6, 0x98, 0xb6, 0x63, 0xd1, 0x3c, 0x35, 0x4a, 0x0b, 0xc1,
391 0x4f, 0x5b, 0xca, 0x13, 0x7f, 0xe6, 0xc3, 0xc5, 0x89, 0x02, 0xf6, 0xfd,
392 0x33, 0x79, 0x53, 0x07, 0xe6, 0xdf, 0xc1, 0x01, 0xb4, 0x74, 0x2c, 0x72,
393 0x3d, 0x3c, 0xf6, 0xfa, 0x28, 0x73, 0x48, 0x08, 0x55, 0x4f, 0xc5, 0xb2,
394 0x73, 0xd6, 0xa1, 0x27, 0xee, 0xdf, 0x89, 0x1c, 0x7c, 0x90, 0x2a, 0x9c,
395 0x0f, 0x15, 0x19, 0x6f, 0x53, 0x5f, 0x99, 0xc6, 0x9b, 0x7a, 0x19, 0x08,
396 0x1c, 0xe2, 0x7e, 0x22, 0x53, 0xd9, 0xe1, 0x1e, 0x35, 0xe4, 0xb1, 0xbd,
397 0xdc, 0xcd, 0xf3, 0x0e, 0x31, 0x7e, 0x14, 0xea, 0x6e, 0x7f, 0x9f, 0xc7,
398 0x94, 0x23, 0x42, 0x10, 0xa0, 0x32, 0x9c, 0x94, 0x09, 0xae, 0x79, 0xa2,
399 0x6b, 0x6b, 0x1a, 0xf5, 0xda, 0xaf, 0xe9, 0xb3, 0xf5, 0xac, 0x75, 0xec,
400 0xdb, 0xcb, 0x5c, 0x21, 0xc5, 0x7f, 0x57, 0x9e, 0xbe, 0x2d, 0xea, 0x59,
401 0x8e, 0x5d, 0x88, 0x15, 0x1a, 0xfe, 0xc5, 0xaa, 0xc6, 0x68, 0x90, 0x79,
402 0xd1, 0xba, 0x5d, 0xdd, 0x05, 0x90, 0xdf, 0x3c, 0x0f, 0x69, 0x11, 0x33,
403 0x57, 0x6b, 0x99, 0xf7, 0x9a, 0x35, 0x07, 0x07, 0x7d, 0x28, 0x19, 0xba,
404 0xac, 0x24, 0x15, 0xbd, 0x18, 0x20, 0x0b, 0xe1, 0x0b, 0x22, 0xfa, 0x03,
405 0x14, 0xc8, 0x9d, 0x0e, 0x2a, 0xa4, 0x1d, 0x15, 0x91, 0x8a, 0x06, 0x02,
406 0x1d, 0xe7, 0xfe, 0x2b, 0x97, 0xd1, 0x7a, 0xbb, 0x5a, 0xc1, 0x76, 0xfd,
407 0x4f, 0xda, 0x87, 0xbb, 0xd4, 0xcc, 0x32, 0x12, 0xb1, 0xeb, 0xc9, 0xaa,
408 0xd1, 0xe3, 0x32, 0x5d, 0xde, 0x1f, 0x4a, 0x31, 0x4d, 0x25, 0x03, 0xe2,
409 0xc8, 0x44, 0xe5, 0x48, 0xab, 0x45, 0xf4, 0xe4, 0x4d, 0xd7, 0x7b, 0x0b,
410 0x46, 0x80, 0xca, 0x38, 0x3b, 0x40, 0x31, 0x15, 0x5e, 0x90, 0x60, 0x0b,
411 0x21, 0x29, 0xff, 0x39, 0x59, 0xaa, 0x71, 0x0b, 0xfc, 0xda, 0x23, 0xbb,
412 0xdb, 0x2a, 0xe2, 0x9c, 0x8c, 0xf0, 0xf0, 0x33, 0x67, 0xff, 0xd1, 0x29,
413 0x0d, 0xe2, 0xc4, 0x36, 0x4c, 0x35, 0x87, 0x8f, 0xb4, 0x61, 0x32, 0x07,
414 0x56, 0x77, 0x31, 0x36, 0x6e, 0x62, 0xe8, 0x95, 0xee, 0x93, 0x05, 0x48,
415 0xa3, 0xd9, 0x85, 0x42, 0xd4, 0x1f, 0x84, 0x75, 0x1d, 0x31, 0x88, 0x08,
416 0xc7, 0x5c, 0xae, 0x00, 0xcf, 0x8b, 0x18, 0x36, 0x40, 0x98, 0x57, 0x5f,
417 0xb2, 0x09, 0xeb, 0xd7, 0xc6, 0xbd, 0x4f, 0xa4, 0x50, 0x31, 0xb2, 0x2d,
418 0x7a, 0x62, 0x7a, 0x69, 0x45, 0x3d, 0x22, 0x65, 0x7b, 0x92, 0x50, 0xfa,
419 0xaa, 0x9d, 0x97, 0xb3, 0x40, 0x5f, 0x79, 0x72, 0x77, 0x24, 0x4d, 0x81,
420 0x7d, 0x98, 0xeb, 0x1f, 0x39, 0x90, 0x5d, 0x94, 0x70, 0xe5, 0xc5, 0x00,
421 0xb0, 0xfe, 0x0f, 0x45, 0x0e, 0xdb, 0x25, 0x1d, 0xe9, 0xa0, 0x1d, 0x29,
422 0x2a, 0x0c, 0x9d, 0x6a, 0x19, 0xbd, 0x39, 0xe3, 0x5c, 0x0f, 0xc8, 0x29,
423 0xb5, 0xd8, 0xf7, 0x57, 0xfd, 0x3c, 0x8c, 0xcb, 0x8b, 0x09, 0x5e, 0xe0,
424 0x6c, 0xfe, 0xf2, 0x7c, 0x34, 0x8b, 0x07, 0x5e, 0x80, 0x9c, 0xc0, 0xe4,
425 0x54, 0x54, 0xbc, 0xc5, 0x82, 0x30, 0x2c, 0xe5, 0xfe, 0xf0, 0x4e, 0xd1,
426 0x6a, 0x5f, 0x70, 0x77, 0x3f, 0x2e, 0x57, 0x7f, 0x9e, 0x28, 0x34, 0x78,
427 0x15, 0xb1, 0xd6, 0xa6, 0xfb, 0x08, 0x11, 0x2a, 0xd6, 0xa5, 0xb4, 0x24,
428 0x6a, 0xd0, 0x8d, 0x4b, 0xa9, 0x54, 0x8f, 0x65, 0xb9, 0x2b, 0x3e, 0x13,
429 0x80, 0x05, 0x6c, 0x83, 0x90, 0x33, 0x48, 0x1f, 0xe5, 0x4d, 0xef, 0x22,
430 0x48, 0xa0, 0xbe, 0xf7, 0x4d, 0x91, 0x3d, 0xea, 0x07, 0x72, 0x83, 0x33,
431 0xa4, 0x7a, 0x66, 0x2e, 0xce, 0x09, 0x10, 0xe2, 0xeb, 0xc5, 0xfa, 0x70,
432 0x11, 0x52, 0x36, 0xd6, 0xc7, 0x72, 0x65, 0x9f, 0xdd, 0xdc, 0x6a, 0x19,
433 0x3e, 0x14, 0x25, 0x59, 0x00, 0x20, 0xf0, 0xc2, 0x51, 0x14, 0x14, 0x16,
434 0x9b, 0xeb, 0x18, 0x01, 0x4e, 0x93, 0xbf, 0xe8, 0xc0, 0x46, 0xec, 0x97,
435 0xc6, 0x54, 0x3e, 0x56, 0xd3, 0x04, 0x6e, 0xa5, 0xba, 0xe9, 0xa8, 0x71,
436 0x49, 0x83, 0xea, 0x0d, 0x83, 0x4e, 0x43, 0x96, 0x1e, 0x7d, 0x4b, 0x60,
437 0x06, 0xd7, 0xb3, 0x48, 0xa2, 0xd8, 0xa4, 0x78, 0x1e, 0x23, 0x07, 0xb9,
438 0xb4, 0x6b, 0xfd, 0xde, 0x1d, 0x01, 0xd0, 0x5b, 0x41, 0x87, 0xc5, 0xa4,
439 0x0c, 0x5a, 0x0f, 0x17, 0x1c, 0x19, 0x79, 0xf3, 0x79, 0x55, 0x0a, 0x3d,
440 0x67, 0xf8, 0x83, 0x02, 0xa3, 0xb3, 0xc6, 0xdc, 0x7c, 0xf0, 0x42, 0xfc,
441 0x27, 0x9e, 0x02, 0xbe, 0x57, 0x9f, 0xcf, 0x5d, 0x7a, 0x14, 0xa9, 0xb1,
442 0x2b, 0xc8, 0x91, 0x4c, 0x9f, 0x09, 0x9c, 0x44, 0xbd, 0xb7, 0x9f, 0x7b,
443 0x3a, 0xa8, 0xec, 0x7f, 0xac, 0x0b, 0xf6, 0xdd, 0xb8, 0x23, 0xf6, 0x07,
444 0xab, 0x6b, 0x7d, 0xbf, 0x1b, 0x33, 0xf2, 0x1e, 0x38, 0x0e, 0x47, 0x0f,
445 0xfe, 0x3e, 0x26, 0x07, 0x8a, 0xb4, 0x3d, 0xc7, 0x02, 0x0f, 0x75, 0xb5,
446 0x84, 0x74, 0x2d, 0x84, 0x43, 0x53, 0x79, 0x2e, 0xfe, 0xdd, 0xaf, 0x74,
447 0x1b, 0x39, 0xb1, 0x20, 0x55, 0x97, 0xdc, 0x7c, 0x5f, 0x03, 0x9b, 0x97,
448 0xd6, 0x26, 0x84, 0x81, 0x4d, 0xc1, 0x76, 0x6f, 0xaf, 0xd0, 0xee, 0x2b,
449 0xee, 0x55, 0x11, 0x40, 0xfd, 0x93, 0xa0, 0x6c, 0x03, 0x47, 0x2c, 0xe8,
450 0x3a, 0x36, 0xfd, 0xec, 0xa0, 0xbf, 0xeb, 0x59, 0xa9, 0x85, 0x79, 0xdf,
451 0xfa, 0x70, 0x9b, 0xca, 0x78, 0x38, 0x57, 0x38, 0xed, 0x9b, 0xf6, 0xa2,
452 0xa2, 0xfe, 0xd9, 0x31, 0x25, 0x80, 0xda, 0x0d, 0xb9, 0x33, 0x90, 0x17,
453 0xe6, 0x5a, 0xa2, 0x04, 0xa1, 0x05, 0x74, 0x9a, 0x2d, 0x00, 0xde, 0x68,
454 0x81, 0x68, 0x91, 0xe5, 0x6d, 0x55, 0xf4, 0x57, 0xd1, 0x71, 0x87, 0xd6,
455 0x4b, 0xdb, 0x65, 0x53, 0x05, 0xfd, 0x78, 0x91, 0x78, 0xc0, 0xdf, 0xb9,
456 0x39, 0xb2, 0x02, 0x79, 0x25, 0x3b, 0x26, 0x45, 0x6a, 0x2f, 0x87, 0x68,
457 0xf6, 0x13, 0x14, 0xa6, 0xef, 0xf4, 0x39, 0xf7, 0x51, 0x2f, 0xcb, 0x2c,
458 0xea, 0x7c, 0xa6, 0x43, 0x91, 0x8c, 0x33, 0xa3, 0x64, 0x45, 0x2b, 0x11,
459 0x57, 0x3c, 0x60, 0xf5, 0xf0, 0x23, 0x0f, 0xd4, 0xe0, 0x6b, 0xd1, 0x97,
460 0xeb, 0x77, 0x3a, 0xa3, 0x53, 0x9f, 0xa0, 0xe5, 0x9f, 0x17, 0x0a, 0xbd,
461 0x2b, 0xc3, 0x04, 0xe7, 0x22, 0xcc, 0xed, 0x8a, 0xe9, 0xa3, 0x1c, 0xfe,
462 0x2a, 0x8d, 0x29, 0x81, 0xb6, 0x78, 0x3e, 0x20, 0x91, 0x58, 0xb4, 0xc5,
463 0x6d, 0x6a, 0xf2, 0x1d, 0x4b, 0xf7, 0x52, 0x28, 0x3a, 0xea, 0x8a, 0x10,
464 0xf6, 0x3c, 0x06, 0x19, 0x6b, 0x14, 0xb2, 0xf9, 0x2e, 0xb6, 0x58, 0x86,
465 0x57, 0xfa, 0xf0, 0x8f, 0x2c, 0xa5, 0x0b, 0x31, 0x52, 0x30, 0x2b, 0x06,
466 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x14, 0x31, 0x1e,
467 0x1e, 0x1c, 0x00, 0x52, 0x00, 0x61, 0x00, 0x64, 0x00, 0x61, 0x00, 0x72,
468 0x00, 0x20, 0x00, 0x31, 0x00, 0x37, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39,
469 0x00, 0x32, 0x00, 0x32, 0x00, 0x37, 0x30, 0x23, 0x06, 0x09, 0x2a, 0x86,
470 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x15, 0x31, 0x16, 0x04, 0x14, 0x91,
471 0xe9, 0x30, 0xa4, 0xec, 0x77, 0x61, 0x86, 0x5c, 0x44, 0x3d, 0xf0, 0x08,
472 0xc3, 0xdc, 0x9f, 0x6f, 0x20, 0x21, 0xba, 0x30, 0x30, 0x30, 0x21, 0x30,
473 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14,
474 0xc4, 0xc3, 0xdb, 0x6c, 0x25, 0xc2, 0xdb, 0x25, 0xbb, 0x9b, 0x1b, 0xab,
475 0x04, 0x66, 0x32, 0x08, 0x46, 0x04, 0x94, 0xe6, 0x04, 0x08, 0xc8, 0x12,
476 0xa3, 0x2a, 0xbd, 0x3f, 0xce, 0x3d, 0x02, 0x01, 0x01
477 };
478
479 int verbose = 0;
480
481 static int TestSignAndVerifyDataWithIdentity(SecIdentityRef identity)
482 {
483 CMSEncoderRef encoder = NULL;
484 CMSDecoderRef decoder = NULL;
485 CFDataRef signedData = NULL;
486 OSStatus status;
487 int result = 0;
488
489 status = CMSEncoderCreate(&encoder);
490 ok_status(status, "%s: CMSEncoderCreate", testName);
491 if (status) {
492 fprintf(stderr, "Unable to create encoder: error %d\n", (int)status);
493 return (++result);
494 }
495
496 status = CMSEncoderAddSigners(encoder, identity);
497 ok_status(status, "%s: CMSEncodingAddSigners", testName);
498 if (status) {
499 fprintf(stderr, "Unable to add signers: error %d\n", (int)status);
500 return (++result);
501 }
502
503 status = CMSEncoderSetCertificateChainMode(encoder, kCMSCertificateSignerOnly);
504 ok_status(status, "%s: CMSEncoderSetCertificateChainMode", testName);
505 if (status) {
506 fprintf(stderr, "Unable to set chain mode: error %d\n", (int)status);
507 return (++result);
508 }
509
510 const uint8_t blob[12] = {'j','a','b','b','e','r','w','o','c','k','y','\0'};
511
512 status = CMSEncoderUpdateContent(encoder, blob, sizeof(blob));
513 ok_status(status, "%s: CMSEncoderUpdateContent", testName);
514 if (status) {
515 fprintf(stderr, "Unable to update content: error %d\n", (int)status);
516 return (++result);
517 }
518
519 status = CMSEncoderCopyEncodedContent(encoder, &signedData);
520 ok_status(status, "%s: CMSEncoderCopyEncodedContent", testName);
521 if (status || !signedData) {
522 fprintf(stderr, "Unable to encode content: error %d\n", (int)status);
523 return (++result);
524 }
525
526 /* Verify the content... */
527 status = CMSDecoderCreate(&decoder);
528 ok_status(status, "%s: CMSDecoderCreate", testName);
529 if (status) {
530 fprintf(stderr, "Unable to create decoder: error %d\n", (int)status);
531 return (++result);
532 }
533
534 status = CMSDecoderUpdateMessage(decoder, (const void*)CFDataGetBytePtr(signedData), (size_t)CFDataGetLength(signedData));
535 ok_status(status, "%s: CMSDecoderUpdateMessage", testName);
536 if (status) {
537 fprintf(stderr, "Unable to decode message: error %d\n", (int)status);
538 return (++result);
539 }
540
541 status = CMSDecoderFinalizeMessage(decoder);
542 ok_status(status, "%s: CMSDecoderFinalizeMessage", testName);
543 if (status) {
544 fprintf(stderr, "Unable to finalize message: error %d\n", (int)status);
545 return (++result);
546 }
547
548 CMSSignerStatus signerStatus=0;
549 OSStatus verifyResult=0;
550 SecPolicyRef policy = SecPolicyCreateBasicX509();
551 status = CMSDecoderCopySignerStatus(decoder, 0, policy, false, &signerStatus, NULL, &verifyResult);
552 ok_status(status, "%s: CMSDecoderCopySignerStatus", testName);
553 if (status) {
554 fprintf(stderr, "Unable to copy signer status: error %d\n", (int)status);
555 return (++result);
556 }
557
558 if (verbose) {
559 fprintf(stdout, "Signer status: %d\n", (int)signerStatus);
560 }
561
562 is(signerStatus, kCMSSignerValid, "%s: CMS signature verified correctly", testName);
563
564 if (decoder) CFRelease(decoder);
565 if (encoder) CFRelease(encoder);
566 if (signedData) CFRelease(signedData);
567 return result;
568 }
569
570 static int Test()
571 {
572 SecKeychainRef goodKeychain=NULL;
573 SecKeychainRef badKeychain=NULL;
574 SecCertificateRef goodLeaf=NULL, badLeaf=NULL, root=NULL;
575 CFDataRef tmpData=NULL;
576 CFArrayRef items=NULL;
577 SecKeyRef privateKey=NULL;
578 SecIdentityRef identity=NULL;
579 OSStatus status;
580 int result = 0;
581
582 goodKeychain = createNewKeychain("test_rdar17159227_good.keychain", "password");
583 badKeychain = createNewKeychain("test_rdar17159227_bad.keychain", "password");
584
585 /* get certificates */
586 tmpData = CFDataCreateWithBytesNoCopy(NULL, leafSigningCertificate,
587 sizeof(leafSigningCertificate), kCFAllocatorNull);
588 goodLeaf = SecCertificateCreateWithData(NULL, tmpData);
589 CFRelease(tmpData);
590
591 tmpData = CFDataCreateWithBytesNoCopy(NULL, bogusTrailingBytesSigningCertificate,
592 sizeof(bogusTrailingBytesSigningCertificate), kCFAllocatorNull);
593 badLeaf = SecCertificateCreateWithData(NULL, tmpData);
594 CFRelease(tmpData);
595
596 tmpData = CFDataCreateWithBytesNoCopy(NULL, coreOSTestCA,
597 sizeof(coreOSTestCA), kCFAllocatorNull);
598 root = SecCertificateCreateWithData(NULL, tmpData);
599 CFRelease(tmpData);
600
601 ok_status(SecCertificateAddToKeychain(root, goodKeychain), "%s: SecCertificateAddToKeychain (root)", testName);
602 ok_status(SecCertificateAddToKeychain(goodLeaf, goodKeychain), "%s: SecCertificateAddToKeychain (goodLeaf)", testName);
603 ok_status(SecCertificateAddToKeychain(badLeaf, badKeychain), "%s: SecCertificateAddToKeychain (badLeaf)", testName);
604
605 /* import P12 container */
606 {
607 CFDataRef p12DataRef = CFDataCreateWithBytesNoCopy(NULL, TestIdentity_p12,
608 sizeof(TestIdentity_p12), kCFAllocatorNull);
609 SecExternalFormat format = kSecFormatPKCS12;
610 SecExternalItemType itemType = kSecItemTypeAggregate;
611 SecItemImportExportFlags flags = 0;
612
613
614 CFTypeRef keyUsages[1] = { kSecAttrCanSign };
615 CFArrayRef keyUsagesArray = CFArrayCreate(NULL, keyUsages, 1, &kCFTypeArrayCallBacks);
616 CFTypeRef keyAttrs[1] = { kSecAttrIsPermanent };
617 CFArrayRef keyAttrsArray = CFArrayCreate(NULL, keyAttrs, 1, &kCFTypeArrayCallBacks);
618 SecItemImportExportKeyParameters keyParams = {
619 SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION, // uint32_t version
620 0, // SecKeyImportExportFlags flags
621 CFSTR("test"), // CFTypeRef passphrase
622 NULL, //CFSTR("title"), // CFStringRef alertTitle
623 NULL, //CFSTR("pw:"), // CFStringRef alertPrompt
624 NULL, // SecAccessRef accessRef (unspecified, use default)
625 keyUsagesArray, // CFArrayRef keyUsages
626 keyAttrsArray // CFArrayRef keyAttributes
627 };
628 status = SecItemImport(p12DataRef,
629 NULL, &format, &itemType, flags, &keyParams, goodKeychain, &items);
630 ok_status(status, "%s: SecItemImport", testName);
631
632 CFRelease(keyUsagesArray);
633 CFRelease(keyAttrsArray);
634 if (status) {
635 fprintf(stderr, "Unable to import identity: error %d\n", (int)status);
636 ++result;
637 }
638 }
639 if (!items || CFArrayGetCount(items) < 1) {
640 // Private key import succeeded but was not returned, need to look up key
641 CFTypeRef results = NULL;
642 CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0,
643 &kCFTypeDictionaryKeyCallBacks,
644 &kCFTypeDictionaryValueCallBacks);
645 CFDictionaryAddValue( query, kSecClass, kSecClassKey );
646 CFDictionaryAddValue( query, kSecAttrKeyClass, kSecAttrKeyClassPrivate );
647 CFDictionaryAddValue( query, kSecAttrLabel, CFSTR("Radar 17159227") );
648 CFDictionaryAddValue( query, kSecReturnRef, kCFBooleanTrue );
649
650 status = SecItemCopyMatching(query, &results);
651 ok_status(status, "%s: SecItemCopyMatching for private key", testName);
652
653 privateKey = (SecKeyRef)results;
654 if (status || !results) {
655 fprintf(stderr, "Unable to find private key: error %d\n", (int)status);
656 } else if (verbose) {
657 fprintf(stdout, "Private key found in search: %p\n", privateKey);
658 }
659 }
660 else {
661 identity=(SecIdentityRef)CFArrayGetValueAtIndex(items,0);
662 if (identity) CFRetain(identity);
663 if (verbose) {
664 fprintf(stdout, "Identity was imported: %p\n", identity);
665 }
666 }
667 if (items) CFRelease(items);
668
669 status = SecIdentityCopyPrivateKey(identity, &privateKey);
670 ok_status(status, "%s: SecItentityCopyPrivateKey", testName);
671
672 /* Case 1: good leaf certificate, expected to always succeed */
673 if (verbose) {
674 fprintf(stdout, "### cert 1 ###\n");
675 }
676 identity = SecIdentityCreate(kCFAllocatorDefault, goodLeaf, privateKey);
677
678 if (status) {
679 identity = NULL;
680 }
681 if (!identity) {
682 fprintf(stderr, "Failed to create identity #1: error %d\n", (int)status);
683 ++result;
684 }
685 result += TestSignAndVerifyDataWithIdentity(identity);
686 if (identity) CFRelease(identity);
687
688 /* Case 2: bad leaf certificate, expected to succeed with the fix for rdar://17159227, but fail without it */
689 if (verbose) {
690 fprintf(stdout, "### cert 2 ###\n");
691 }
692 identity = SecIdentityCreate(kCFAllocatorDefault, badLeaf, privateKey);
693 if (status) {
694 identity = NULL;
695 }
696 if (!identity) {
697 fprintf(stderr, "Failed to create identity #2: error %d\n", (int)status);
698 ++result;
699 }
700 result += TestSignAndVerifyDataWithIdentity(identity);
701 if (identity) CFRelease(identity);
702
703 if (privateKey) CFRelease(privateKey);
704
705
706 /* clean up temporary keychains before we leave */
707 if (goodKeychain) {
708 ok_status(SecKeychainDelete(goodKeychain), "%s: SecKeychainDelete", testName);
709 CFRelease(goodKeychain);
710 }
711 if (badKeychain) {
712 ok_status(SecKeychainDelete(badKeychain), "%s: SecKeychainDelete", testName);
713 CFRelease(badKeychain);
714 }
715
716 return result;
717 }
718
719
720 int kc_28_cert_sign(int argc, char *const *argv)
721 {
722 plan_tests(31);
723 initializeKeychainTests(__FUNCTION__);
724
725 verbose = test_verbose;
726
727 Test();
728
729 checkPrompts(0, "No prompts");
730
731 deleteTestFiles();
732 return 0;
733 }