[CRYPT32_WINETEST] Add a PCH.
[reactos.git] / modules / rostests / winetests / crypt32 / str.c
1 /*
2 * Unit test suite for crypt32.dll's Cert*ToStr and CertStrToName functions.
3 *
4 * Copyright 2006 Juan Lang, Aric Stewart for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "precomp.h"
22
23 typedef struct _CertRDNAttrEncoding {
24 LPCSTR pszObjId;
25 DWORD dwValueType;
26 CERT_RDN_VALUE_BLOB Value;
27 LPCSTR str;
28 BOOL todo;
29 } CertRDNAttrEncoding, *PCertRDNAttrEncoding;
30
31 typedef struct _CertRDNAttrEncodingW {
32 LPCSTR pszObjId;
33 DWORD dwValueType;
34 CERT_RDN_VALUE_BLOB Value;
35 LPCWSTR str;
36 BOOL todo;
37 } CertRDNAttrEncodingW, *PCertRDNAttrEncodingW;
38
39 static BYTE bin1[] = { 0x55, 0x53 };
40 static BYTE bin2[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x73, 0x6f, 0x74,
41 0x61 };
42 static BYTE bin3[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x61, 0x70, 0x6f,
43 0x6c, 0x69, 0x73 };
44 static BYTE bin4[] = { 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, 0x76,
45 0x65, 0x72, 0x73 };
46 static BYTE bin5[] = { 0x57, 0x69, 0x6e, 0x65, 0x20, 0x44, 0x65, 0x76,
47 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74 };
48 static BYTE bin6[] = { 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73,
49 0x74 };
50 static BYTE bin7[] = { 0x61, 0x72, 0x69, 0x63, 0x40, 0x63, 0x6f, 0x64,
51 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x6f, 0x6d };
52 static BYTE bin8[] = {
53 0x65,0x00,0x50,0x00,0x4b,0x00,0x49,0x00,0x20,0x00,0x52,0x00,0x6f,0x00,0x6f,
54 0x00,0x74,0x00,0x20,0x00,0x43,0x00,0x65,0x00,0x72,0x00,0x74,0x00,0x69,0x00,
55 0x66,0x00,0x69,0x00,0x63,0x00,0x61,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,
56 0x00,0x20,0x00,0x41,0x00,0x75,0x00,0x74,0x00,0x68,0x00,0x6f,0x00,0x72,0x00,
57 0x69,0x00,0x74,0x00,0x79,0x00 };
58 static BYTE bin9[] = { 0x61, 0x62, 0x63, 0x22, 0x64, 0x65, 0x66 };
59 static BYTE bin10[] = { 0x61, 0x62, 0x63, 0x27, 0x64, 0x65, 0x66 };
60 static BYTE bin11[] = { 0x61, 0x62, 0x63, 0x2c, 0x20, 0x64, 0x65, 0x66 };
61 static BYTE bin12[] = { 0x20, 0x61, 0x62, 0x63, 0x20 };
62 static BYTE bin13[] = { 0x22, 0x64, 0x65, 0x66, 0x22 };
63 static BYTE bin14[] = { 0x31, 0x3b, 0x33 };
64
65 static const BYTE cert[] =
66 {0x30,0x82,0x2,0xbb,0x30,0x82,0x2,0x24,0x2,0x9,0x0,0xe3,0x5a,0x10,0xf1,0xfc,
67 0x4b,0xf3,0xa2,0x30,0xd,0x6,0x9,0x2a,0x86,0x48,0x86,0xf7,0xd,0x1,0x1,0x4,0x5,
68 0x0,0x30,0x81,0xa1,0x31,0xb,0x30,0x9,0x6,0x3,0x55,0x4,0x6,0x13,0x2,0x55,0x53,
69 0x31,0x12,0x30,0x10,0x6,0x3,0x55,0x4,0x8,0x13,0x9,0x4d,0x69,0x6e,0x6e,0x65,
70 0x73,0x6f,0x74,0x61,0x31,0x14,0x30,0x12,0x6,0x3,0x55,0x4,0x7,0x13,0xb,0x4d,
71 0x69,0x6e,0x6e,0x65,0x61,0x70,0x6f,0x6c,0x69,0x73,0x31,0x14,0x30,0x12,0x6,0x3,
72 0x55,0x4,0xa,0x13,0xb,0x43,0x6f,0x64,0x65,0x57,0x65,0x61,0x76,0x65,0x72,0x73,
73 0x31,0x19,0x30,0x17,0x6,0x3,0x55,0x4,0xb,0x13,0x10,0x57,0x69,0x6e,0x65,0x20,
74 0x44,0x65,0x76,0x65,0x6c,0x6f,0x70,0x6d,0x65,0x6e,0x74,0x31,0x12,0x30,0x10,
75 0x6,0x3,0x55,0x4,0x3,0x13,0x9,0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74,
76 0x31,0x23,0x30,0x21,0x6,0x9,0x2a,0x86,0x48,0x86,0xf7,0xd,0x1,0x9,0x1,0x16,
77 0x14,0x61,0x72,0x69,0x63,0x40,0x63,0x6f,0x64,0x65,0x77,0x65,0x61,0x76,0x65,
78 0x72,0x73,0x2e,0x63,0x6f,0x6d,0x30,0x1e,0x17,0xd,0x30,0x36,0x30,0x31,0x32,
79 0x35,0x31,0x33,0x35,0x37,0x32,0x34,0x5a,0x17,0xd,0x30,0x36,0x30,0x32,0x32,
80 0x34,0x31,0x33,0x35,0x37,0x32,0x34,0x5a,0x30,0x81,0xa1,0x31,0xb,0x30,0x9,0x6,
81 0x3,0x55,0x4,0x6,0x13,0x2,0x55,0x53,0x31,0x12,0x30,0x10,0x6,0x3,0x55,0x4,0x8,
82 0x13,0x9,0x4d,0x69,0x6e,0x6e,0x65,0x73,0x6f,0x74,0x61,0x31,0x14,0x30,0x12,0x6,
83 0x3,0x55,0x4,0x7,0x13,0xb,0x4d,0x69,0x6e,0x6e,0x65,0x61,0x70,0x6f,0x6c,0x69,
84 0x73,0x31,0x14,0x30,0x12,0x6,0x3,0x55,0x4,0xa,0x13,0xb,0x43,0x6f,0x64,0x65,
85 0x57,0x65,0x61,0x76,0x65,0x72,0x73,0x31,0x19,0x30,0x17,0x6,0x3,0x55,0x4,0xb,
86 0x13,0x10,0x57,0x69,0x6e,0x65,0x20,0x44,0x65,0x76,0x65,0x6c,0x6f,0x70,0x6d,
87 0x65,0x6e,0x74,0x31,0x12,0x30,0x10,0x6,0x3,0x55,0x4,0x3,0x13,0x9,0x6c,0x6f,
88 0x63,0x61,0x6c,0x68,0x6f,0x73,0x74,0x31,0x23,0x30,0x21,0x6,0x9,0x2a,0x86,0x48,
89 0x86,0xf7,0xd,0x1,0x9,0x1,0x16,0x14,0x61,0x72,0x69,0x63,0x40,0x63,0x6f,0x64,
90 0x65,0x77,0x65,0x61,0x76,0x65,0x72,0x73,0x2e,0x63,0x6f,0x6d,0x30,0x81,0x9f,
91 0x30,0xd,0x6,0x9,0x2a,0x86,0x48,0x86,0xf7,0xd,0x1,0x1,0x1,0x5,0x0,0x3,0x81,
92 0x8d,0x0,0x30,0x81,0x89,0x2,0x81,0x81,0x0,0x9b,0xb5,0x8f,0xaf,0xfb,0x9a,0xaf,
93 0xdc,0xa2,0x4d,0xb1,0xc8,0x72,0x44,0xef,0x79,0x7f,0x28,0xb6,0xfe,0x50,0xdc,
94 0x8a,0xf7,0x11,0x2f,0x90,0x70,0xed,0xa4,0xa9,0xd,0xbf,0x82,0x3e,0x56,0xd8,
95 0x36,0xb6,0x9,0x52,0x83,0xab,0x65,0x95,0x0,0xe2,0xea,0x3c,0x4f,0x85,0xb8,0xc,
96 0x41,0x42,0x77,0x5c,0x9d,0x44,0xeb,0xcf,0x7d,0x60,0x64,0x7a,0x6c,0x4c,0xac,
97 0x4a,0x9a,0x23,0x25,0x15,0xd7,0x92,0xb4,0x10,0xe7,0x95,0xad,0x4b,0x93,0xda,
98 0x6a,0x76,0xe0,0xa5,0xd2,0x13,0x8,0x12,0x30,0x68,0xde,0xb9,0x5b,0x6e,0x2a,
99 0x97,0x43,0xaa,0x7b,0x22,0x33,0x34,0xb1,0xca,0x5d,0x19,0xd8,0x42,0x26,0x45,
100 0xc6,0xe9,0x1d,0xee,0x7,0xc2,0x27,0x95,0x87,0xd8,0x12,0xec,0x4b,0x16,0x9f,0x2,
101 0x3,0x1,0x0,0x1,0x30,0xd,0x6,0x9,0x2a,0x86,0x48,0x86,0xf7,0xd,0x1,0x1,0x4,0x5,
102 0x0,0x3,0x81,0x81,0x0,0x96,0xf9,0xf6,0x6a,0x3d,0xd9,0xca,0x6e,0xd5,0x76,0x73,
103 0xab,0x75,0xc1,0xcc,0x98,0x44,0xc3,0xa9,0x90,0x68,0x88,0x76,0xb9,0xeb,0xb6,
104 0xbe,0x60,0x62,0xb9,0x67,0x1e,0xcc,0xf4,0xe1,0xe7,0x6c,0xc8,0x67,0x3f,0x1d,
105 0xf3,0x68,0x86,0x30,0xee,0xaa,0x92,0x61,0x37,0xd7,0x82,0x90,0x28,0xaa,0x7a,
106 0x18,0x88,0x60,0x14,0x88,0x75,0xc0,0x4a,0x4e,0x7d,0x48,0xe7,0x3,0xa6,0xfd,
107 0xd7,0xce,0x3c,0xe5,0x9b,0xaf,0x2f,0xdc,0xbb,0x7c,0xbd,0x20,0x49,0xd9,0x68,
108 0x37,0xeb,0x5d,0xbb,0xe2,0x6d,0x66,0xe3,0x11,0xc1,0xa7,0x88,0x49,0xc6,0x6f,
109 0x65,0xd3,0xce,0xae,0x26,0x19,0x3,0x2e,0x4f,0x78,0xa5,0xa,0x97,0x7e,0x4f,0xc4,
110 0x91,0x8a,0xf8,0x5,0xef,0x5b,0x3b,0x49,0xbf,0x5f,0x2b};
111
112 static char issuerStr[] =
113 "US, Minnesota, Minneapolis, CodeWeavers, Wine Development, localhost, aric@codeweavers.com";
114 static char issuerStrSemicolon[] =
115 "US; Minnesota; Minneapolis; CodeWeavers; Wine Development; localhost; aric@codeweavers.com";
116 static char issuerStrCRLF[] =
117 "US\r\nMinnesota\r\nMinneapolis\r\nCodeWeavers\r\nWine Development\r\nlocalhost\r\naric@codeweavers.com";
118 static char subjectStr[] =
119 "2.5.4.6=US, 2.5.4.8=Minnesota, 2.5.4.7=Minneapolis, 2.5.4.10=CodeWeavers, 2.5.4.11=Wine Development, 2.5.4.3=localhost, 1.2.840.113549.1.9.1=aric@codeweavers.com";
120 static char subjectStrSemicolon[] =
121 "2.5.4.6=US; 2.5.4.8=Minnesota; 2.5.4.7=Minneapolis; 2.5.4.10=CodeWeavers; 2.5.4.11=Wine Development; 2.5.4.3=localhost; 1.2.840.113549.1.9.1=aric@codeweavers.com";
122 static char subjectStrCRLF[] =
123 "2.5.4.6=US\r\n2.5.4.8=Minnesota\r\n2.5.4.7=Minneapolis\r\n2.5.4.10=CodeWeavers\r\n2.5.4.11=Wine Development\r\n2.5.4.3=localhost\r\n1.2.840.113549.1.9.1=aric@codeweavers.com";
124 static char x500SubjectStr[] = "C=US, S=Minnesota, L=Minneapolis, O=CodeWeavers, OU=Wine Development, CN=localhost, E=aric@codeweavers.com";
125 static char x500SubjectStrSemicolonReverse[] = "E=aric@codeweavers.com; CN=localhost; OU=Wine Development; O=CodeWeavers; L=Minneapolis; S=Minnesota; C=US";
126 static WCHAR issuerStrW[] = {
127 'U','S',',',' ','M','i','n','n','e','s','o','t','a',',',' ','M','i','n','n',
128 'e','a','p','o','l','i','s',',',' ','C','o','d','e','W','e','a','v','e','r',
129 's',',',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t',
130 ',',' ','l','o','c','a','l','h','o','s','t',',',' ','a','r','i','c','@','c',
131 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 };
132 static WCHAR issuerStrSemicolonW[] = {
133 'U','S',';',' ','M','i','n','n','e','s','o','t','a',';',' ','M','i','n','n',
134 'e','a','p','o','l','i','s',';',' ','C','o','d','e','W','e','a','v','e','r',
135 's',';',' ','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t',
136 ';',' ','l','o','c','a','l','h','o','s','t',';',' ','a','r','i','c','@','c',
137 'o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 };
138 static WCHAR issuerStrCRLFW[] = {
139 'U','S','\r','\n','M','i','n','n','e','s','o','t','a','\r','\n','M','i','n',
140 'n','e','a','p','o','l','i','s','\r','\n','C','o','d','e','W','e','a','v','e',
141 'r','s','\r','\n','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n',
142 't','\r','\n','l','o','c','a','l','h','o','s','t','\r','\n','a','r','i','c',
143 '@','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0 };
144 static WCHAR subjectStrW[] = {
145 '2','.','5','.','4','.','6','=','U','S',',',' ','2','.','5','.','4','.','8',
146 '=','M','i','n','n','e','s','o','t','a',',',' ','2','.','5','.','4','.','7',
147 '=','M','i','n','n','e','a','p','o','l','i','s',',',' ','2','.','5','.','4',
148 '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',',',' ','2','.',
149 '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p',
150 'm','e','n','t',',',' ','2','.','5','.','4','.','3','=','l','o','c','a','l',
151 'h','o','s','t',',',' ','1','.','2','.','8','4','0','.','1','1','3','5','4',
152 '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e',
153 'a','v','e','r','s','.','c','o','m',0 };
154 static WCHAR subjectStrSemicolonW[] = {
155 '2','.','5','.','4','.','6','=','U','S',';',' ','2','.','5','.','4','.','8',
156 '=','M','i','n','n','e','s','o','t','a',';',' ','2','.','5','.','4','.','7',
157 '=','M','i','n','n','e','a','p','o','l','i','s',';',' ','2','.','5','.','4',
158 '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s',';',' ','2','.',
159 '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p',
160 'm','e','n','t',';',' ','2','.','5','.','4','.','3','=','l','o','c','a','l',
161 'h','o','s','t',';',' ','1','.','2','.','8','4','0','.','1','1','3','5','4',
162 '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e',
163 'a','v','e','r','s','.','c','o','m',0 };
164 static WCHAR subjectStrCRLFW[] = {
165 '2','.','5','.','4','.','6','=','U','S','\r','\n','2','.','5','.','4','.','8',
166 '=','M','i','n','n','e','s','o','t','a','\r','\n','2','.','5','.','4','.','7',
167 '=','M','i','n','n','e','a','p','o','l','i','s','\r','\n','2','.','5','.','4',
168 '.','1','0','=','C','o','d','e','W','e','a','v','e','r','s','\r','\n','2','.',
169 '5','.','4','.','1','1','=','W','i','n','e',' ','D','e','v','e','l','o','p',
170 'm','e','n','t','\r','\n','2','.','5','.','4','.','3','=','l','o','c','a','l',
171 'h','o','s','t','\r','\n','1','.','2','.','8','4','0','.','1','1','3','5','4',
172 '9','.','1','.','9','.','1','=','a','r','i','c','@','c','o','d','e','w','e',
173 'a','v','e','r','s','.','c','o','m',0 };
174 static WCHAR x500SubjectStrSemicolonReverseW[] = {
175 'E','=','a','r','i','c','@','c','o','d','e','w','e','a','v','e','r','s','.','c',
176 'o','m',';',' ','C','N','=','l','o','c','a','l','h','o','s','t',';',' ','O','U',
177 '=','W','i','n','e',' ','D','e','v','e','l','o','p','m','e','n','t',';',' ','O',
178 '=','C','o','d','e','W','e','a','v','e','r','s',';',' ','L','=','M','i','n','n',
179 'e','a','p','o','l','i','s',';',' ','S','=','M','i','n','n','e','s','o','t','a',
180 ';',' ','C','=','U','S',0 };
181
182 static HMODULE dll;
183 static DWORD (WINAPI *pCertNameToStrA)(DWORD,LPVOID,DWORD,LPSTR,DWORD);
184 static DWORD (WINAPI *pCertNameToStrW)(DWORD,LPVOID,DWORD,LPWSTR,DWORD);
185 static DWORD (WINAPI *pCertRDNValueToStrA)(DWORD, PCERT_RDN_VALUE_BLOB,
186 LPSTR, DWORD);
187 static DWORD (WINAPI *pCertRDNValueToStrW)(DWORD, PCERT_RDN_VALUE_BLOB,
188 LPWSTR, DWORD);
189 static BOOL (WINAPI *pCertStrToNameA)(DWORD dwCertEncodingType,
190 LPCSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded,
191 DWORD *pcbEncoded, LPCSTR *ppszError);
192 static BOOL (WINAPI *pCertStrToNameW)(DWORD dwCertEncodingType,
193 LPCWSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded,
194 DWORD *pcbEncoded, LPCWSTR *ppszError);
195 static DWORD (WINAPI *pCertGetNameStringA)(PCCERT_CONTEXT cert, DWORD type,
196 DWORD flags, void *typePara, LPSTR str, DWORD cch);
197
198
199 static void test_CertRDNValueToStrA(void)
200 {
201 CertRDNAttrEncoding attrs[] = {
202 { "2.5.4.6", CERT_RDN_PRINTABLE_STRING,
203 { sizeof(bin1), bin1 }, "US", FALSE },
204 { "2.5.4.8", CERT_RDN_PRINTABLE_STRING,
205 { sizeof(bin2), bin2 }, "Minnesota", FALSE },
206 { "2.5.4.7", CERT_RDN_PRINTABLE_STRING,
207 { sizeof(bin3), bin3 }, "Minneapolis", FALSE },
208 { "2.5.4.10", CERT_RDN_PRINTABLE_STRING,
209 { sizeof(bin4), bin4 }, "CodeWeavers", FALSE },
210 { "2.5.4.11", CERT_RDN_PRINTABLE_STRING,
211 { sizeof(bin5), bin5 }, "Wine Development", FALSE },
212 { "2.5.4.3", CERT_RDN_PRINTABLE_STRING,
213 { sizeof(bin6), bin6 }, "localhost", FALSE },
214 { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING,
215 { sizeof(bin7), bin7 }, "aric@codeweavers.com", FALSE },
216 { "0", CERT_RDN_PRINTABLE_STRING,
217 { sizeof(bin9), bin9 }, "abc\"def", FALSE },
218 { "0", CERT_RDN_PRINTABLE_STRING,
219 { sizeof(bin10), bin10 }, "abc'def", FALSE },
220 { "0", CERT_RDN_PRINTABLE_STRING,
221 { sizeof(bin11), bin11 }, "abc, def", FALSE },
222 { "0", CERT_RDN_PRINTABLE_STRING,
223 { sizeof(bin12), bin12 }, " abc ", FALSE },
224 { "0", CERT_RDN_PRINTABLE_STRING,
225 { sizeof(bin13), bin13 }, "\"def\"", FALSE },
226 { "0", CERT_RDN_PRINTABLE_STRING,
227 { sizeof(bin14), bin14 }, "1;3", FALSE },
228 };
229 DWORD i, ret;
230 char buffer[2000];
231 CERT_RDN_VALUE_BLOB blob = { 0, NULL };
232 static const char ePKI[] = "ePKI Root Certification Authority";
233
234 if (!pCertRDNValueToStrA) return;
235
236 /* This crashes
237 ret = pCertRDNValueToStrA(0, NULL, NULL, 0);
238 */
239 /* With empty input, it generates the empty string */
240 SetLastError(0xdeadbeef);
241 ret = pCertRDNValueToStrA(0, &blob, NULL, 0);
242 ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
243 ret = pCertRDNValueToStrA(0, &blob, buffer, sizeof(buffer));
244 ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
245 ok(!buffer[0], "Expected empty string\n");
246
247 for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++)
248 {
249 ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value,
250 buffer, sizeof(buffer));
251 todo_wine_if (attrs[i].todo)
252 {
253 ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %d\n",
254 lstrlenA(attrs[i].str) + 1, ret);
255 ok(!strcmp(buffer, attrs[i].str), "Expected %s, got %s\n",
256 attrs[i].str, buffer);
257 }
258 }
259 blob.pbData = bin8;
260 blob.cbData = sizeof(bin8);
261 ret = pCertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer,
262 sizeof(buffer));
263 ok(ret == strlen(ePKI) + 1 || broken(ret != strlen(ePKI) + 1),
264 "Expected length %d, got %d\n", lstrlenA(ePKI), ret);
265 if (ret == strlen(ePKI) + 1)
266 ok(!strcmp(buffer, ePKI), "Expected %s, got %s\n", ePKI, buffer);
267 }
268
269 static void test_CertRDNValueToStrW(void)
270 {
271 static const WCHAR usW[] = { 'U','S',0 };
272 static const WCHAR minnesotaW[] = { 'M','i','n','n','e','s','o','t','a',0 };
273 static const WCHAR minneapolisW[] = { 'M','i','n','n','e','a','p','o','l',
274 'i','s',0 };
275 static const WCHAR codeweaversW[] = { 'C','o','d','e','W','e','a','v','e',
276 'r','s',0 };
277 static const WCHAR wineDevW[] = { 'W','i','n','e',' ','D','e','v','e','l',
278 'o','p','m','e','n','t',0 };
279 static const WCHAR localhostW[] = { 'l','o','c','a','l','h','o','s','t',0 };
280 static const WCHAR aricW[] = { 'a','r','i','c','@','c','o','d','e','w','e',
281 'a','v','e','r','s','.','c','o','m',0 };
282 static const WCHAR ePKIW[] = { 'e','P','K','I',' ','R','o','o','t',' ',
283 'C','e','r','t','i','f','i','c','a','t','i','o','n',' ','A','u','t','h',
284 'o','r','i','t','y',0 };
285 static const WCHAR embeddedDoubleQuoteW[] = { 'a','b','c','"','d','e','f',
286 0 };
287 static const WCHAR embeddedSingleQuoteW[] = { 'a','b','c','\'','d','e','f',
288 0 };
289 static const WCHAR embeddedCommaW[] = { 'a','b','c',',',' ','d','e','f',0 };
290 static const WCHAR trailingAndEndingSpaceW[] = { ' ','a','b','c',' ',0 };
291 static const WCHAR enclosingQuotesW[] = { '"','d','e','f','"',0 };
292 static const WCHAR embeddedSemiW[] = { '1',';','3',0 };
293 CertRDNAttrEncodingW attrs[] = {
294 { "2.5.4.6", CERT_RDN_PRINTABLE_STRING,
295 { sizeof(bin1), bin1 }, usW, FALSE },
296 { "2.5.4.8", CERT_RDN_PRINTABLE_STRING,
297 { sizeof(bin2), bin2 }, minnesotaW, FALSE },
298 { "2.5.4.7", CERT_RDN_PRINTABLE_STRING,
299 { sizeof(bin3), bin3 }, minneapolisW, FALSE },
300 { "2.5.4.10", CERT_RDN_PRINTABLE_STRING,
301 { sizeof(bin4), bin4 }, codeweaversW, FALSE },
302 { "2.5.4.11", CERT_RDN_PRINTABLE_STRING,
303 { sizeof(bin5), bin5 }, wineDevW, FALSE },
304 { "2.5.4.3", CERT_RDN_PRINTABLE_STRING,
305 { sizeof(bin6), bin6 }, localhostW, FALSE },
306 { "1.2.840.113549.1.9.1", CERT_RDN_IA5_STRING,
307 { sizeof(bin7), bin7 }, aricW, FALSE },
308 { "0", CERT_RDN_PRINTABLE_STRING,
309 { sizeof(bin9), bin9 }, embeddedDoubleQuoteW, FALSE },
310 { "0", CERT_RDN_PRINTABLE_STRING,
311 { sizeof(bin10), bin10 }, embeddedSingleQuoteW, FALSE },
312 { "0", CERT_RDN_PRINTABLE_STRING,
313 { sizeof(bin11), bin11 }, embeddedCommaW, FALSE },
314 { "0", CERT_RDN_PRINTABLE_STRING,
315 { sizeof(bin12), bin12 }, trailingAndEndingSpaceW, FALSE },
316 { "0", CERT_RDN_PRINTABLE_STRING,
317 { sizeof(bin13), bin13 }, enclosingQuotesW, FALSE },
318 { "0", CERT_RDN_PRINTABLE_STRING,
319 { sizeof(bin14), bin14 }, embeddedSemiW, FALSE },
320 };
321 DWORD i, ret;
322 WCHAR buffer[2000];
323 CERT_RDN_VALUE_BLOB blob = { 0, NULL };
324
325 if (!pCertRDNValueToStrW)
326 {
327 win_skip("CertRDNValueToStrW is not available\n");
328 return;
329 }
330
331 /* This crashes
332 ret = pCertRDNValueToStrW(0, NULL, NULL, 0);
333 */
334 /* With empty input, it generates the empty string */
335 SetLastError(0xdeadbeef);
336 ret = pCertRDNValueToStrW(0, &blob, NULL, 0);
337 ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
338 ret = pCertRDNValueToStrW(0, &blob, buffer,
339 sizeof(buffer) / sizeof(buffer[0]));
340 ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n");
341 ok(!buffer[0], "Expected empty string\n");
342
343 for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++)
344 {
345 ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value,
346 buffer, sizeof(buffer) / sizeof(buffer[0]));
347 todo_wine_if (attrs[i].todo)
348 {
349 ok(ret == lstrlenW(attrs[i].str) + 1,
350 "Expected length %d, got %d\n", lstrlenW(attrs[i].str) + 1, ret);
351 ok(!lstrcmpW(buffer, attrs[i].str), "Expected %s, got %s\n",
352 wine_dbgstr_w(attrs[i].str), wine_dbgstr_w(buffer));
353 }
354 }
355 blob.pbData = bin8;
356 blob.cbData = sizeof(bin8);
357 ret = pCertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer,
358 sizeof(buffer));
359 ok(ret == lstrlenW(ePKIW) + 1 || broken(ret != lstrlenW(ePKIW) + 1),
360 "Expected length %d, got %d\n", lstrlenW(ePKIW), ret);
361 if (ret == lstrlenW(ePKIW) + 1)
362 ok(!lstrcmpW(buffer, ePKIW), "Expected %s, got %s\n",
363 wine_dbgstr_w(ePKIW), wine_dbgstr_w(buffer));
364 }
365
366 static void test_NameToStrConversionA(PCERT_NAME_BLOB pName, DWORD dwStrType,
367 LPCSTR expected, BOOL todo)
368 {
369 char buffer[2000] = { 0 };
370 DWORD i;
371
372 i = pCertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0);
373 todo_wine_if (todo)
374 ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
375 lstrlenA(expected) + 1, i);
376 i = pCertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer,
377 sizeof(buffer));
378 todo_wine_if (todo)
379 ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
380 lstrlenA(expected) + 1, i);
381 todo_wine_if (todo)
382 ok(!strcmp(buffer, expected), "Expected %s, got %s\n", expected,
383 buffer);
384 }
385
386 static BYTE encodedSimpleCN[] = {
387 0x30,0x0c,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x31 };
388 static BYTE encodedSingleQuotedCN[] = { 0x30,0x0e,0x31,0x0c,0x30,0x0a,
389 0x06,0x03,0x55,0x04,0x03,0x13,0x03,0x27,0x31,0x27 };
390 static BYTE encodedSpacedCN[] = { 0x30,0x0e,0x31,0x0c,0x30,0x0a,0x06,0x03,
391 0x55,0x04,0x03,0x13,0x03,0x20,0x31,0x20 };
392 static BYTE encodedQuotedCN[] = { 0x30,0x11,0x31,0x0f,0x30,0x0d,0x06,0x03,
393 0x55, 0x04,0x03,0x1e,0x06,0x00,0x22,0x00,0x31,0x00,0x22, };
394 static BYTE encodedMultipleAttrCN[] = { 0x30,0x0e,0x31,0x0c,0x30,0x0a,
395 0x06,0x03,0x55,0x04,0x03,0x13,0x03,0x31,0x2b,0x32 };
396 static BYTE encodedCommaCN[] = {
397 0x30,0x0e,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,0x04,0x03,0x13,0x03,0x61,0x2c,
398 0x62 };
399 static BYTE encodedEqualCN[] = {
400 0x30,0x0e,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,0x04,0x03,0x13,0x03,0x61,0x3d,
401 0x62 };
402 static BYTE encodedLessThanCN[] = {
403 0x30,0x0d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x03,0x1e,0x02,0x00,0x3c
404 };
405 static BYTE encodedGreaterThanCN[] = {
406 0x30,0x0d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x03,0x1e,0x02,0x00,0x3e
407 };
408 static BYTE encodedHashCN[] = {
409 0x30,0x0d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x03,0x1e,0x02,0x00,0x23
410 };
411 static BYTE encodedSemiCN[] = {
412 0x30,0x0d,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x03,0x1e,0x02,0x00,0x3b
413 };
414 static BYTE encodedNewlineCN[] = {
415 0x30,0x11,0x31,0x0f,0x30,0x0d,0x06,0x03,0x55,0x04,0x03,0x1e,0x06,0x00,0x61,
416 0x00,0x0a,0x00,0x62 };
417 static BYTE encodedDummyCN[] = {
418 0x30,0x1F,0x31,0x0E,0x30,0x0C,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x64,0x75,
419 0x6D,0x6D,0x79,0x31,0x0D,0x30,0x0B,0x06,0x03,0x55,0x04,0x0C,0x13,0x04,0x74,
420 0x65,0x73,0x74 };
421 static BYTE encodedFields[] = {
422 0x30,0x2F,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x57,0x69,
423 0x6E,0x65,0x20,0x54,0x65,0x73,0x74,0x31,0x0C,0x30,0x0A,0x06,0x03,0x55,0x04,
424 0x0C,0x13,0x03,0x31,0x32,0x33,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
425 0x13,0x02,0x42,0x52 };
426
427 static void test_CertNameToStrA(void)
428 {
429 PCCERT_CONTEXT context;
430 CERT_NAME_BLOB blob;
431
432 if (!pCertNameToStrA)
433 {
434 win_skip("CertNameToStrA is not available\n");
435 return;
436 }
437
438 context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
439 sizeof(cert));
440 ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
441 GetLastError());
442 if (context)
443 {
444 DWORD ret;
445
446 /* This crashes
447 ret = pCertNameToStrA(0, NULL, 0, NULL, 0);
448 */
449 /* Test with a bogus encoding type */
450 SetLastError(0xdeadbeef);
451 ret = pCertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0);
452 ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
453 "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
454 ret, GetLastError());
455 SetLastError(0xdeadbeef);
456 ret = pCertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
457 0, NULL, 0);
458 ok(ret && GetLastError() == ERROR_SUCCESS,
459 "Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
460 ret, GetLastError());
461
462 test_NameToStrConversionA(&context->pCertInfo->Issuer,
463 CERT_SIMPLE_NAME_STR, issuerStr, FALSE);
464 test_NameToStrConversionA(&context->pCertInfo->Issuer,
465 CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
466 issuerStrSemicolon, FALSE);
467 test_NameToStrConversionA(&context->pCertInfo->Issuer,
468 CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
469 issuerStrCRLF, FALSE);
470 test_NameToStrConversionA(&context->pCertInfo->Subject,
471 CERT_OID_NAME_STR, subjectStr, FALSE);
472 test_NameToStrConversionA(&context->pCertInfo->Subject,
473 CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
474 subjectStrSemicolon, FALSE);
475 test_NameToStrConversionA(&context->pCertInfo->Subject,
476 CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
477 subjectStrCRLF, FALSE);
478 test_NameToStrConversionA(&context->pCertInfo->Subject,
479 CERT_X500_NAME_STR, x500SubjectStr, FALSE);
480 test_NameToStrConversionA(&context->pCertInfo->Subject,
481 CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG,
482 x500SubjectStrSemicolonReverse, FALSE);
483
484 CertFreeCertificateContext(context);
485 }
486 blob.pbData = encodedSimpleCN;
487 blob.cbData = sizeof(encodedSimpleCN);
488 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=1", FALSE);
489 blob.pbData = encodedSingleQuotedCN;
490 blob.cbData = sizeof(encodedSingleQuotedCN);
491 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN='1'", FALSE);
492 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "'1'", FALSE);
493 blob.pbData = encodedSpacedCN;
494 blob.cbData = sizeof(encodedSpacedCN);
495 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\" 1 \"", FALSE);
496 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\" 1 \"", FALSE);
497 blob.pbData = encodedQuotedCN;
498 blob.cbData = sizeof(encodedQuotedCN);
499 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"\"\"1\"\"\"",
500 FALSE);
501 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"\"\"1\"\"\"",
502 FALSE);
503 blob.pbData = encodedMultipleAttrCN;
504 blob.cbData = sizeof(encodedMultipleAttrCN);
505 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"1+2\"", FALSE);
506 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"1+2\"", FALSE);
507 blob.pbData = encodedCommaCN;
508 blob.cbData = sizeof(encodedCommaCN);
509 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a,b\"", FALSE);
510 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a,b\"", FALSE);
511 blob.pbData = encodedEqualCN;
512 blob.cbData = sizeof(encodedEqualCN);
513 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a=b\"", FALSE);
514 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a=b\"", FALSE);
515 blob.pbData = encodedLessThanCN;
516 blob.cbData = sizeof(encodedLessThanCN);
517 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"<\"", FALSE);
518 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"<\"", FALSE);
519 blob.pbData = encodedGreaterThanCN;
520 blob.cbData = sizeof(encodedGreaterThanCN);
521 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\">\"", FALSE);
522 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\">\"", FALSE);
523 blob.pbData = encodedHashCN;
524 blob.cbData = sizeof(encodedHashCN);
525 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"#\"", FALSE);
526 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"#\"", FALSE);
527 blob.pbData = encodedSemiCN;
528 blob.cbData = sizeof(encodedSemiCN);
529 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\";\"", FALSE);
530 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\";\"", FALSE);
531 blob.pbData = encodedNewlineCN;
532 blob.cbData = sizeof(encodedNewlineCN);
533 test_NameToStrConversionA(&blob, CERT_X500_NAME_STR, "CN=\"a\nb\"", FALSE);
534 test_NameToStrConversionA(&blob, CERT_SIMPLE_NAME_STR, "\"a\nb\"", FALSE);
535 }
536
537 static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
538 LPCWSTR expected, BOOL todo)
539 {
540 WCHAR buffer[2000] = { 0 };
541 DWORD i;
542
543 i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0);
544 todo_wine_if (todo)
545 ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
546 lstrlenW(expected) + 1, i);
547 i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer,
548 sizeof(buffer) / sizeof(buffer[0]));
549 todo_wine_if (todo)
550 ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
551 lstrlenW(expected) + 1, i);
552 todo_wine_if (todo)
553 ok(!lstrcmpW(buffer, expected), "Expected %s, got %s\n",
554 wine_dbgstr_w(expected), wine_dbgstr_w(buffer));
555 }
556
557 static const WCHAR simpleCN_W[] = { 'C','N','=','1',0 };
558 static const WCHAR singledQuotedCN_W[] = { 'C','N','=','\'','1','\'',0 };
559 static const WCHAR simpleSingleQuotedCN_W[] = { '\'','1','\'',0 };
560 static const WCHAR spacedCN_W[] = { 'C','N','=','"',' ','1',' ','"',0 };
561 static const WCHAR simpleSpacedCN_W[] = { '"',' ','1',' ','"',0 };
562 static const WCHAR quotedCN_W[] = { 'C','N','=','"','"','"','1','"','"','"',0 };
563 static const WCHAR simpleQuotedCN_W[] = { '"','"','"','1','"','"','"',0 };
564 static const WCHAR multipleAttrCN_W[] = { 'C','N','=','"','1','+','2','"',0 };
565 static const WCHAR simpleMultipleAttrCN_W[] = { '"','1','+','2','"',0 };
566 static const WCHAR commaCN_W[] = { 'C','N','=','"','a',',','b','"',0 };
567 static const WCHAR simpleCommaCN_W[] = { '"','a',',','b','"',0 };
568 static const WCHAR equalCN_W[] = { 'C','N','=','"','a','=','b','"',0 };
569 static const WCHAR simpleEqualCN_W[] = { '"','a','=','b','"',0 };
570 static const WCHAR lessThanCN_W[] = { 'C','N','=','"','<','"',0 };
571 static const WCHAR simpleLessThanCN_W[] = { '"','<','"',0 };
572 static const WCHAR greaterThanCN_W[] = { 'C','N','=','"','>','"',0 };
573 static const WCHAR simpleGreaterThanCN_W[] = { '"','>','"',0 };
574 static const WCHAR hashCN_W[] = { 'C','N','=','"','#','"',0 };
575 static const WCHAR simpleHashCN_W[] = { '"','#','"',0 };
576 static const WCHAR semiCN_W[] = { 'C','N','=','"',';','"',0 };
577 static const WCHAR simpleSemiCN_W[] = { '"',';','"',0 };
578 static const WCHAR newlineCN_W[] = { 'C','N','=','"','a','\n','b','"',0 };
579 static const WCHAR simpleNewlineCN_W[] = { '"','a','\n','b','"',0 };
580
581 static void test_CertNameToStrW(void)
582 {
583 PCCERT_CONTEXT context;
584 CERT_NAME_BLOB blob;
585
586 if (!pCertNameToStrW)
587 {
588 win_skip("CertNameToStrW is not available\n");
589 return;
590 }
591
592 context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
593 sizeof(cert));
594 ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
595 GetLastError());
596 if (context)
597 {
598 DWORD ret;
599
600 /* This crashes
601 ret = pCertNameToStrW(0, NULL, 0, NULL, 0);
602 */
603 /* Test with a bogus encoding type */
604 SetLastError(0xdeadbeef);
605 ret = pCertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0);
606 ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
607 "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
608 ret, GetLastError());
609 SetLastError(0xdeadbeef);
610 ret = pCertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
611 0, NULL, 0);
612 ok(ret && GetLastError() == ERROR_SUCCESS,
613 "Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
614 ret, GetLastError());
615
616 test_NameToStrConversionW(&context->pCertInfo->Issuer,
617 CERT_SIMPLE_NAME_STR, issuerStrW, FALSE);
618 test_NameToStrConversionW(&context->pCertInfo->Issuer,
619 CERT_SIMPLE_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
620 issuerStrSemicolonW, FALSE);
621 test_NameToStrConversionW(&context->pCertInfo->Issuer,
622 CERT_SIMPLE_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
623 issuerStrCRLFW, FALSE);
624 test_NameToStrConversionW(&context->pCertInfo->Subject,
625 CERT_OID_NAME_STR, subjectStrW, FALSE);
626 test_NameToStrConversionW(&context->pCertInfo->Subject,
627 CERT_OID_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG,
628 subjectStrSemicolonW, FALSE);
629 test_NameToStrConversionW(&context->pCertInfo->Subject,
630 CERT_OID_NAME_STR | CERT_NAME_STR_CRLF_FLAG,
631 subjectStrCRLFW, FALSE);
632 test_NameToStrConversionW(&context->pCertInfo->Subject,
633 CERT_X500_NAME_STR | CERT_NAME_STR_SEMICOLON_FLAG | CERT_NAME_STR_REVERSE_FLAG,
634 x500SubjectStrSemicolonReverseW, FALSE);
635
636 CertFreeCertificateContext(context);
637 }
638 blob.pbData = encodedSimpleCN;
639 blob.cbData = sizeof(encodedSimpleCN);
640 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, simpleCN_W, FALSE);
641 blob.pbData = encodedSingleQuotedCN;
642 blob.cbData = sizeof(encodedSingleQuotedCN);
643 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, singledQuotedCN_W,
644 FALSE);
645 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
646 simpleSingleQuotedCN_W, FALSE);
647 blob.pbData = encodedSpacedCN;
648 blob.cbData = sizeof(encodedSpacedCN);
649 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, spacedCN_W, FALSE);
650 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSpacedCN_W,
651 FALSE);
652 blob.pbData = encodedQuotedCN;
653 blob.cbData = sizeof(encodedQuotedCN);
654 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, quotedCN_W,
655 FALSE);
656 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleQuotedCN_W,
657 FALSE);
658 blob.pbData = encodedMultipleAttrCN;
659 blob.cbData = sizeof(encodedMultipleAttrCN);
660 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, multipleAttrCN_W,
661 FALSE);
662 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
663 simpleMultipleAttrCN_W, FALSE);
664 blob.pbData = encodedCommaCN;
665 blob.cbData = sizeof(encodedCommaCN);
666 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, commaCN_W, FALSE);
667 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleCommaCN_W,
668 FALSE);
669 blob.pbData = encodedEqualCN;
670 blob.cbData = sizeof(encodedEqualCN);
671 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, equalCN_W, FALSE);
672 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleEqualCN_W,
673 FALSE);
674 blob.pbData = encodedLessThanCN;
675 blob.cbData = sizeof(encodedLessThanCN);
676 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, lessThanCN_W, FALSE);
677 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleLessThanCN_W,
678 FALSE);
679 blob.pbData = encodedGreaterThanCN;
680 blob.cbData = sizeof(encodedGreaterThanCN);
681 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, greaterThanCN_W,
682 FALSE);
683 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR,
684 simpleGreaterThanCN_W, FALSE);
685 blob.pbData = encodedHashCN;
686 blob.cbData = sizeof(encodedHashCN);
687 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, hashCN_W, FALSE);
688 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleHashCN_W,
689 FALSE);
690 blob.pbData = encodedSemiCN;
691 blob.cbData = sizeof(encodedSemiCN);
692 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, semiCN_W, FALSE);
693 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleSemiCN_W,
694 FALSE);
695 blob.pbData = encodedNewlineCN;
696 blob.cbData = sizeof(encodedNewlineCN);
697 test_NameToStrConversionW(&blob, CERT_X500_NAME_STR, newlineCN_W, FALSE);
698 test_NameToStrConversionW(&blob, CERT_SIMPLE_NAME_STR, simpleNewlineCN_W,
699 FALSE);
700 }
701
702 struct StrToNameA
703 {
704 LPCSTR x500;
705 DWORD encodedSize;
706 const BYTE *encoded;
707 };
708
709 static const struct StrToNameA namesA[] = {
710 { "CN=1", sizeof(encodedSimpleCN), encodedSimpleCN },
711 { "CN=\"1\"", sizeof(encodedSimpleCN), encodedSimpleCN },
712 { "CN = \"1\"", sizeof(encodedSimpleCN), encodedSimpleCN },
713 { "CN='1'", sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN },
714 { "CN=\" 1 \"", sizeof(encodedSpacedCN), encodedSpacedCN },
715 { "CN=\"\"\"1\"\"\"", sizeof(encodedQuotedCN), encodedQuotedCN },
716 { "CN=\"1+2\"", sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN },
717 { "CN=\"a,b\"", sizeof(encodedCommaCN), encodedCommaCN },
718 { "CN=\"a=b\"", sizeof(encodedEqualCN), encodedEqualCN },
719 { "CN=\"<\"", sizeof(encodedLessThanCN), encodedLessThanCN },
720 { "CN=\">\"", sizeof(encodedGreaterThanCN), encodedGreaterThanCN },
721 { "CN=\"#\"", sizeof(encodedHashCN), encodedHashCN },
722 { "CN=\";\"", sizeof(encodedSemiCN), encodedSemiCN },
723 { "CN=dummy,T=test", sizeof(encodedDummyCN), encodedDummyCN },
724 { " CN = Wine Test,T = 123, C = BR", sizeof(encodedFields), encodedFields },
725 };
726
727 static void test_CertStrToNameA(void)
728 {
729 BOOL ret;
730 DWORD size, i;
731 BYTE buf[100];
732
733 if (!pCertStrToNameA)
734 {
735 win_skip("CertStrToNameA is not available\n");
736 return;
737 }
738
739 /* Crash
740 ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, NULL, NULL);
741 */
742 ret = pCertStrToNameA(0, NULL, 0, NULL, NULL, &size, NULL);
743 ok(!ret, "Expected failure\n");
744 ret = pCertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL);
745 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
746 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
747 ret = pCertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL);
748 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
749 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
750 ret = pCertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL);
751 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
752 "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
753 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL);
754 ok(ret, "CertStrToNameA failed: %08x\n", GetLastError());
755 size = sizeof(buf);
756 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"\"1\"\"", 0, NULL, buf, &size,
757 NULL);
758 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
759 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
760 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf,
761 &size, NULL);
762 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
763 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
764 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf,
765 &size, NULL);
766 ok(ret && GetLastError() == ERROR_SUCCESS,
767 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
768 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
769 &size, NULL);
770 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
771 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
772 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"1,2;3,4\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
773 &size, NULL);
774 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
775 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
776 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf,
777 &size, NULL);
778 ok(ret && GetLastError() == ERROR_SUCCESS,
779 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
780 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
781 &size, NULL);
782 ok(ret && GetLastError() == ERROR_SUCCESS,
783 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
784 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", 0, NULL, buf,
785 &size, NULL);
786 ok(ret && GetLastError() == ERROR_SUCCESS,
787 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
788 ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
789 &size, NULL);
790 ok(!ret && GetLastError() == ERROR_MORE_DATA,
791 "Expected ERROR_MORE_DATA, got %08x\n", GetLastError());
792 for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++)
793 {
794 size = sizeof(buf);
795 ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf,
796 &size, NULL);
797 ok(ret, "CertStrToNameA failed on string %s: %08x\n", namesA[i].x500,
798 GetLastError());
799 ok(size == namesA[i].encodedSize,
800 "Expected size %d, got %d\n", namesA[i].encodedSize, size);
801 if (ret)
802 ok(!memcmp(buf, namesA[i].encoded, namesA[i].encodedSize),
803 "Unexpected value for string %s\n", namesA[i].x500);
804 }
805 }
806
807 struct StrToNameW
808 {
809 LPCWSTR x500;
810 DWORD encodedSize;
811 const BYTE *encoded;
812 };
813
814 static const WCHAR badlyQuotedCN_W[] = { 'C','N','=','"','"','1','"','"',0 };
815 static const WCHAR simpleCN2_W[] = { 'C','N','=','"','1','"',0 };
816 static const WCHAR simpleCN3_W[] = { 'C','N',' ','=',' ','"','1','"',0 };
817 static const WCHAR japaneseCN_W[] = { 'C','N','=',0x226f,0x575b,0 };
818 static const WCHAR dummyCN_W[] = { 'C','N','=','d','u','m','m','y',',','T','=','t','e','s','t',0 };
819 static const WCHAR encodedFields_W[] = { ' ','C','N',' ','=',' ',' ',' ','W','i','n','e',' ','T',
820 'e','s','t',',','T',' ','=',' ','1','2','3',',',' ','C',
821 ' ','=',' ','B','R',0 };
822 static const BYTE encodedJapaneseCN[] = { 0x30,0x0f,0x31,0x0d,0x30,0x0b,0x06,
823 0x03,0x55,0x04,0x03,0x1e,0x04,0x22,0x6f,0x57,0x5b };
824
825 static const struct StrToNameW namesW[] = {
826 { simpleCN_W, sizeof(encodedSimpleCN), encodedSimpleCN },
827 { simpleCN2_W, sizeof(encodedSimpleCN), encodedSimpleCN },
828 { simpleCN3_W, sizeof(encodedSimpleCN), encodedSimpleCN },
829 { singledQuotedCN_W, sizeof(encodedSingleQuotedCN), encodedSingleQuotedCN },
830 { spacedCN_W, sizeof(encodedSpacedCN), encodedSpacedCN },
831 { quotedCN_W, sizeof(encodedQuotedCN), encodedQuotedCN },
832 { multipleAttrCN_W, sizeof(encodedMultipleAttrCN), encodedMultipleAttrCN },
833 { japaneseCN_W, sizeof(encodedJapaneseCN), encodedJapaneseCN },
834 { commaCN_W, sizeof(encodedCommaCN), encodedCommaCN },
835 { equalCN_W, sizeof(encodedEqualCN), encodedEqualCN },
836 { lessThanCN_W, sizeof(encodedLessThanCN), encodedLessThanCN },
837 { greaterThanCN_W, sizeof(encodedGreaterThanCN), encodedGreaterThanCN },
838 { hashCN_W, sizeof(encodedHashCN), encodedHashCN },
839 { semiCN_W, sizeof(encodedSemiCN), encodedSemiCN },
840 { dummyCN_W, sizeof(encodedDummyCN), encodedDummyCN },
841 { encodedFields_W, sizeof(encodedFields), encodedFields },
842 };
843
844 static void test_CertStrToNameW(void)
845 {
846 static const WCHAR bogusW[] = { 'b','o','g','u','s',0 };
847 static const WCHAR fooW[] = { 'f','o','o','=','1',0 };
848 BOOL ret;
849 DWORD size, i;
850 LPCWSTR errorPtr;
851 BYTE buf[100];
852
853 if (!pCertStrToNameW)
854 {
855 win_skip("CertStrToNameW is not available\n");
856 return;
857 }
858
859 /* Crash
860 ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, NULL, NULL);
861 */
862 ret = pCertStrToNameW(0, NULL, 0, NULL, NULL, &size, NULL);
863 ok(!ret, "Expected failure\n");
864 ret = pCertStrToNameW(0, bogusW, 0, NULL, NULL, &size, NULL);
865 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
866 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
867 ret = pCertStrToNameW(0, fooW, 0, NULL, NULL, &size, NULL);
868 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
869 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
870 ret = pCertStrToNameW(0, simpleCN_W, 0, NULL, NULL, &size, NULL);
871 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
872 "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
873 ret = pCertStrToNameW(X509_ASN_ENCODING, simpleCN_W, 0, NULL, NULL, &size,
874 NULL);
875 ok(ret, "CertStrToNameW failed: %08x\n", GetLastError());
876 size = sizeof(buf);
877 ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
878 &size, NULL);
879 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
880 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
881 ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
882 &size, &errorPtr);
883 ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
884 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
885 ok(errorPtr && *errorPtr == '1', "Expected first error character was 1\n");
886 for (i = 0; i < sizeof(namesW) / sizeof(namesW[0]); i++)
887 {
888 size = sizeof(buf);
889 ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,
890 &size, NULL);
891 ok(ret, "Index %d: CertStrToNameW failed: %08x\n", i, GetLastError());
892 ok(size == namesW[i].encodedSize,
893 "Index %d: expected size %d, got %d\n", i, namesW[i].encodedSize,
894 size);
895 if (ret)
896 ok(!memcmp(buf, namesW[i].encoded, size),
897 "Index %d: unexpected value for string %s\n", i, wine_dbgstr_w(namesW[i].x500));
898 }
899 }
900
901 static void test_CertGetNameStringA(void)
902 {
903 PCCERT_CONTEXT context;
904
905 if (!pCertGetNameStringA)
906 {
907 win_skip("CertGetNameStringA is not available\n");
908 return;
909 }
910
911 context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
912 sizeof(cert));
913 ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
914 GetLastError());
915 if (context)
916 {
917 static const char aric[] = "aric@codeweavers.com";
918 static const char localhost[] = "localhost";
919 DWORD len, type;
920 LPSTR str;
921
922 /* Bad string types/types missing from the cert */
923 len = pCertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
924 ok(len == 1, "expected 1, got %d\n", len);
925 len = pCertGetNameStringA(context, 0, 0, NULL, NULL, 0);
926 ok(len == 1, "expected 1, got %d\n", len);
927 len = pCertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL,
928 0);
929 ok(len == 1, "expected 1, got %d\n", len);
930
931 len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL,
932 0);
933 ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
934 str = HeapAlloc(GetProcessHeap(), 0, len);
935 if (str)
936 {
937 len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL,
938 str, len);
939 ok(!strcmp(str, aric), "unexpected value %s\n", str);
940 HeapFree(GetProcessHeap(), 0, str);
941 }
942
943 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL,
944 0);
945 ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len);
946 str = HeapAlloc(GetProcessHeap(), 0, len);
947 if (str)
948 {
949 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL,
950 str, len);
951 ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
952 HeapFree(GetProcessHeap(), 0, str);
953 }
954 type = 0;
955 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
956 0);
957 ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len);
958 str = HeapAlloc(GetProcessHeap(), 0, len);
959 if (str)
960 {
961 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
962 str, len);
963 ok(!strcmp(str, issuerStr), "unexpected value %s\n", str);
964 HeapFree(GetProcessHeap(), 0, str);
965 }
966 type = CERT_OID_NAME_STR;
967 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
968 0);
969 ok(len == strlen(subjectStr) + 1, "unexpected length %d\n", len);
970 str = HeapAlloc(GetProcessHeap(), 0, len);
971 if (str)
972 {
973 len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type,
974 str, len);
975 ok(!strcmp(str, subjectStr), "unexpected value %s\n", str);
976 HeapFree(GetProcessHeap(), 0, str);
977 }
978
979 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL,
980 0);
981 ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
982 str = HeapAlloc(GetProcessHeap(), 0, len);
983 if (str)
984 {
985 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL,
986 str, len);
987 ok(!strcmp(str, aric), "unexpected value %s\n", str);
988 HeapFree(GetProcessHeap(), 0, str);
989 }
990 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
991 (void *)szOID_RSA_emailAddr, NULL, 0);
992 ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
993 str = HeapAlloc(GetProcessHeap(), 0, len);
994 if (str)
995 {
996 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
997 (void *)szOID_RSA_emailAddr, str, len);
998 ok(!strcmp(str, aric), "unexpected value %s\n", str);
999 HeapFree(GetProcessHeap(), 0, str);
1000 }
1001 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
1002 (void *)szOID_COMMON_NAME, NULL, 0);
1003 ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
1004 str = HeapAlloc(GetProcessHeap(), 0, len);
1005 if (str)
1006 {
1007 len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
1008 (void *)szOID_COMMON_NAME, str, len);
1009 ok(!strcmp(str, localhost), "unexpected value %s\n", str);
1010 HeapFree(GetProcessHeap(), 0, str);
1011 }
1012
1013 len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
1014 NULL, NULL, 0);
1015 ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
1016 str = HeapAlloc(GetProcessHeap(), 0, len);
1017 if (str)
1018 {
1019 len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE,
1020 0, NULL, str, len);
1021 ok(!strcmp(str, localhost), "unexpected value %s\n", str);
1022 HeapFree(GetProcessHeap(), 0, str);
1023 }
1024
1025 len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0,
1026 NULL, NULL, 0);
1027 ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
1028 str = HeapAlloc(GetProcessHeap(), 0, len);
1029 if (str)
1030 {
1031 len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE,
1032 0, NULL, str, len);
1033 ok(!strcmp(str, localhost), "unexpected value %s\n", str);
1034 HeapFree(GetProcessHeap(), 0, str);
1035 }
1036
1037 len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL,
1038 0);
1039 ok(len == strlen(localhost) + 1 || broken(len == 1) /* NT4 */,
1040 "unexpected length %d\n", len);
1041 if (len > 1)
1042 {
1043 str = HeapAlloc(GetProcessHeap(), 0, len);
1044 if (str)
1045 {
1046 len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL,
1047 str, len);
1048 ok(!strcmp(str, localhost), "unexpected value %s\n", str);
1049 HeapFree(GetProcessHeap(), 0, str);
1050 }
1051 }
1052
1053 CertFreeCertificateContext(context);
1054 }
1055 }
1056
1057 START_TEST(str)
1058 {
1059 dll = GetModuleHandleA("Crypt32.dll");
1060
1061 pCertNameToStrA = (void*)GetProcAddress(dll,"CertNameToStrA");
1062 pCertNameToStrW = (void*)GetProcAddress(dll,"CertNameToStrW");
1063 pCertRDNValueToStrA = (void*)GetProcAddress(dll, "CertRDNValueToStrA");
1064 pCertRDNValueToStrW = (void*)GetProcAddress(dll, "CertRDNValueToStrW");
1065 pCertStrToNameA = (void*)GetProcAddress(dll,"CertStrToNameA");
1066 pCertStrToNameW = (void*)GetProcAddress(dll,"CertStrToNameW");
1067 pCertGetNameStringA = (void*)GetProcAddress(dll, "CertGetNameStringA");
1068
1069 test_CertRDNValueToStrA();
1070 test_CertRDNValueToStrW();
1071 test_CertNameToStrA();
1072 test_CertNameToStrW();
1073 test_CertStrToNameA();
1074 test_CertStrToNameW();
1075 test_CertGetNameStringA();
1076 }