crypt32/tests: Test OpenSSL chain separately to address test failures on Win98.
[wine] / dlls / crypt32 / tests / base64.c
1 /*
2  * Unit test suite for crypt32.dll's CryptStringToBinary and CryptBinaryToString
3  * functions.
4  *
5  * Copyright 2006 Juan Lang
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <windef.h>
24 #include <winbase.h>
25 #include <winerror.h>
26 #include <wincrypt.h>
27
28 #include "wine/test.h"
29
30 #define CERT_HEADER               "-----BEGIN CERTIFICATE-----\r\n"
31 #define CERT_TRAILER              "-----END CERTIFICATE-----\r\n"
32 #define CERT_REQUEST_HEADER       "-----BEGIN NEW CERTIFICATE REQUEST-----\r\n"
33 #define CERT_REQUEST_TRAILER      "-----END NEW CERTIFICATE REQUEST-----\r\n"
34 #define X509_HEADER               "-----BEGIN X509 CRL-----\r\n"
35 #define X509_TRAILER              "-----END X509 CRL-----\r\n"
36 #define CERT_HEADER_NOCR          "-----BEGIN CERTIFICATE-----\n"
37 #define CERT_TRAILER_NOCR         "-----END CERTIFICATE-----\n"
38 #define CERT_REQUEST_HEADER_NOCR  "-----BEGIN NEW CERTIFICATE REQUEST-----\n"
39 #define CERT_REQUEST_TRAILER_NOCR "-----END NEW CERTIFICATE REQUEST-----\n"
40 #define X509_HEADER_NOCR          "-----BEGIN X509 CRL-----\n"
41 #define X509_TRAILER_NOCR         "-----END X509 CRL-----\n"
42
43 static BOOL (WINAPI *pCryptBinaryToStringA)(const BYTE *pbBinary,
44  DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString);
45 static BOOL (WINAPI *pCryptStringToBinaryA)(LPCSTR pszString,
46  DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
47  DWORD *pdwSkip, DWORD *pdwFlags);
48
49 struct BinTests
50 {
51     const BYTE *toEncode;
52     DWORD       toEncodeLen;
53     const char *base64;
54 };
55
56 static const BYTE toEncode1[] = { 0 };
57 static const BYTE toEncode2[] = { 1,2 };
58 static const BYTE toEncode3[] = { 1,2,3 };
59 static const BYTE toEncode4[] =
60  "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
61  "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
62  "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
63
64 static const struct BinTests tests[] = {
65  { toEncode1, sizeof(toEncode1), "AA==\r\n", },
66  { toEncode2, sizeof(toEncode2), "AQI=\r\n", },
67  /* { toEncode3, sizeof(toEncode3), "AQID\r\n", },  This test fails on Vista. */
68  { toEncode4, sizeof(toEncode4),
69    "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISUpL\r\n"
70    "TE1OT1BRUlNUVVZXWFlaMDEyMzQ1Njc4OTBhYmNkZWZnaGlqbGttbm9wcXJzdHV2\r\n"
71    "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\r\n"
72    "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\r\n"
73    "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" },
74 };
75
76 static const struct BinTests testsNoCR[] = {
77  { toEncode1, sizeof(toEncode1), "AA==\n", },
78  { toEncode2, sizeof(toEncode2), "AQI=\n", },
79  /* { toEncode3, sizeof(toEncode3), "AQID\n", },  This test fails on Vista. */
80  { toEncode4, sizeof(toEncode4),
81    "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISUpL\n"
82    "TE1OT1BRUlNUVVZXWFlaMDEyMzQ1Njc4OTBhYmNkZWZnaGlqbGttbm9wcXJzdHV2\n"
83    "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\n"
84    "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\n"
85    "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" },
86 };
87
88 static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
89  DWORD format, const char *expected, const char *header, const char *trailer)
90 {
91     DWORD strLen = 0;
92     LPSTR str = NULL;
93     BOOL ret;
94
95     ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen);
96     ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
97     str = HeapAlloc(GetProcessHeap(), 0, strLen);
98     if (str)
99     {
100         DWORD strLen2 = strLen;
101         LPCSTR ptr = str;
102
103         ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, str,
104          &strLen2);
105         ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
106         ok(strLen2 == strLen - 1, "Expected length %d, got %d\n",
107          strLen - 1, strLen);
108         if (header)
109         {
110             ok(!strncmp(header, ptr, strlen(header)),
111              "Expected header %s, got %s\n", header, ptr);
112             ptr += strlen(header);
113         }
114         ok(!strncmp(expected, ptr, strlen(expected)),
115          "Expected %s, got %s\n", expected, ptr);
116         ptr += strlen(expected);
117         if (trailer)
118         {
119             ok(!strncmp(trailer, ptr, strlen(trailer)),
120              "Expected trailer %s, got %s\n", trailer, ptr);
121             ptr += strlen(trailer);
122         }
123         HeapFree(GetProcessHeap(), 0, str);
124     }
125 }
126
127 static void testBinaryToStringA(void)
128 {
129     BOOL ret;
130     DWORD strLen = 0, i;
131
132     ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, NULL);
133     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
134      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
135     ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, &strLen);
136     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
137      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
138     for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
139     {
140         DWORD strLen = 0;
141         LPSTR str = NULL;
142         BOOL ret;
143
144         ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
145          CRYPT_STRING_BINARY, NULL, &strLen);
146         ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
147         str = HeapAlloc(GetProcessHeap(), 0, strLen);
148         if (str)
149         {
150             DWORD strLen2 = strLen;
151
152             ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen,
153              CRYPT_STRING_BINARY, str, &strLen2);
154             ok(strLen == strLen2, "Expected length %d, got %d\n", strLen,
155              strLen2);
156             ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen),
157              "Unexpected value\n");
158             HeapFree(GetProcessHeap(), 0, str);
159         }
160         encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
161          CRYPT_STRING_BASE64, tests[i].base64, NULL, NULL);
162         encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
163          CRYPT_STRING_BASE64HEADER, tests[i].base64, CERT_HEADER,
164          CERT_TRAILER);
165         encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
166          CRYPT_STRING_BASE64REQUESTHEADER, tests[i].base64,
167          CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER);
168         encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen,
169          CRYPT_STRING_BASE64X509CRLHEADER, tests[i].base64, X509_HEADER,
170          X509_TRAILER);
171     }
172     for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
173     {
174         DWORD strLen = 0;
175         LPSTR str = NULL;
176         BOOL ret;
177
178         ret = pCryptBinaryToStringA(testsNoCR[i].toEncode,
179          testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR,
180          NULL, &strLen);
181         ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
182         str = HeapAlloc(GetProcessHeap(), 0, strLen);
183         if (str)
184         {
185             DWORD strLen2 = strLen;
186
187             ret = pCryptBinaryToStringA(testsNoCR[i].toEncode,
188              testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR,
189              str, &strLen2);
190             ok(strLen == strLen2, "Expected length %d, got %d\n", strLen,
191              strLen2);
192             ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen),
193              "Unexpected value\n");
194             HeapFree(GetProcessHeap(), 0, str);
195         }
196         encodeAndCompareBase64_A(testsNoCR[i].toEncode,
197          testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR,
198          testsNoCR[i].base64, NULL, NULL);
199         encodeAndCompareBase64_A(testsNoCR[i].toEncode,
200          testsNoCR[i].toEncodeLen,
201          CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64,
202          CERT_HEADER_NOCR, CERT_TRAILER_NOCR);
203         encodeAndCompareBase64_A(testsNoCR[i].toEncode,
204          testsNoCR[i].toEncodeLen,
205          CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR,
206          testsNoCR[i].base64, CERT_REQUEST_HEADER_NOCR,
207          CERT_REQUEST_TRAILER_NOCR);
208         encodeAndCompareBase64_A(testsNoCR[i].toEncode,
209          testsNoCR[i].toEncodeLen,
210          CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR,
211          testsNoCR[i].base64, X509_HEADER_NOCR, X509_TRAILER_NOCR);
212     }
213 }
214
215 static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
216  LPCSTR trailer, DWORD useFormat, DWORD expectedFormat, const BYTE *expected,
217  DWORD expectedLen)
218 {
219     static const char garbage[] = "garbage\r\n";
220     LPSTR str;
221     DWORD len = strlen(toDecode) + strlen(garbage) + 1;
222
223     if (header)
224         len += strlen(header);
225     if (trailer)
226         len += strlen(trailer);
227     str = HeapAlloc(GetProcessHeap(), 0, len);
228     if (str)
229     {
230         LPBYTE buf;
231         DWORD bufLen = 0;
232         BOOL ret;
233
234         if (header)
235             strcpy(str, header);
236         else
237             *str = 0;
238         strcat(str, toDecode);
239         if (trailer)
240             strcat(str, trailer);
241         ret = pCryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL,
242          NULL);
243         ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
244         buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
245         if (buf)
246         {
247             DWORD skipped, usedFormat;
248
249             /* check as normal, make sure last two parameters are optional */
250             ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL,
251              NULL);
252             ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
253             ok(bufLen == expectedLen,
254              "Expected length %d, got %d\n", expectedLen, bufLen);
255             ok(!memcmp(buf, expected, bufLen), "Unexpected value\n");
256             /* check last two params */
257             ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
258              &skipped, &usedFormat);
259             ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
260             ok(skipped == 0, "Expected skipped 0, got %d\n", skipped);
261             ok(usedFormat == expectedFormat, "Expected format %d, got %d\n",
262              expectedFormat, usedFormat);
263             HeapFree(GetProcessHeap(), 0, buf);
264         }
265
266         /* Check again, but with garbage up front */
267         strcpy(str, garbage);
268         if (header)
269             strcat(str, header);
270         strcat(str, toDecode);
271         if (trailer)
272             strcat(str, trailer);
273         ret = pCryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL,
274          NULL);
275         /* expect failure with no header, and success with one */
276         if (header)
277             ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
278         else
279             ok(!ret && GetLastError() == ERROR_INVALID_DATA,
280              "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%d\n", ret, GetLastError());
281         if (ret)
282         {
283             buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
284             if (buf)
285             {
286                 DWORD skipped, usedFormat;
287
288                 ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
289                  &skipped, &usedFormat);
290                 ok(skipped == strlen(garbage),
291                  "Expected %d characters of \"%s\" skipped when trying format %08x, got %d (used format is %08x)\n",
292                  lstrlenA(garbage), str, useFormat, skipped, usedFormat);
293                 HeapFree(GetProcessHeap(), 0, buf);
294             }
295         }
296         HeapFree(GetProcessHeap(), 0, str);
297     }
298 }
299
300 struct BadString
301 {
302     const char *str;
303     DWORD       format;
304 };
305
306 static const struct BadString badStrings[] = {
307  { "A\r\nA\r\n=\r\n=\r\n", CRYPT_STRING_BASE64 },
308  { "AA\r\n=\r\n=\r\n", CRYPT_STRING_BASE64 },
309  { "AA=\r\n=\r\n", CRYPT_STRING_BASE64 },
310  { "-----BEGIN X509 CRL-----\r\nAA==\r\n", CRYPT_STRING_BASE64X509CRLHEADER },
311 };
312
313 static void testStringToBinaryA(void)
314 {
315     BOOL ret;
316     DWORD bufLen = 0, i;
317
318     ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL);
319     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
320      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
321     ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL);
322     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
323      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
324     /* Bogus format */
325     ret = pCryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL,
326      NULL);
327     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
328      "Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
329     /* Decoding doesn't expect the NOCR flag to be specified */
330     ret = pCryptStringToBinaryA(tests[0].base64, 1,
331      CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, NULL, &bufLen, NULL, NULL);
332     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
333      "Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
334     /* Bad strings */
335     for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++)
336     {
337         bufLen = 0;
338         ret = pCryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format,
339          NULL, &bufLen, NULL, NULL);
340         ok(!ret && GetLastError() == ERROR_INVALID_DATA,
341          "Expected ERROR_INVALID_DATA, got %d\n", GetLastError());
342     }
343     /* Good strings */
344     for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
345     {
346         bufLen = 0;
347         /* Bogus length--oddly enough, that succeeds, even though it's not
348          * properly padded.
349          */
350         ret = pCryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64,
351          NULL, &bufLen, NULL, NULL);
352         todo_wine ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
353         /* Check with the precise format */
354         decodeAndCompareBase64_A(tests[i].base64, NULL, NULL,
355          CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, tests[i].toEncode,
356          tests[i].toEncodeLen);
357         decodeAndCompareBase64_A(tests[i].base64, CERT_HEADER, CERT_TRAILER,
358          CRYPT_STRING_BASE64HEADER, CRYPT_STRING_BASE64HEADER,
359          tests[i].toEncode, tests[i].toEncodeLen);
360         decodeAndCompareBase64_A(tests[i].base64, CERT_REQUEST_HEADER,
361          CERT_REQUEST_TRAILER, CRYPT_STRING_BASE64REQUESTHEADER,
362          CRYPT_STRING_BASE64REQUESTHEADER, tests[i].toEncode,
363          tests[i].toEncodeLen);
364         decodeAndCompareBase64_A(tests[i].base64, X509_HEADER, X509_TRAILER,
365          CRYPT_STRING_BASE64X509CRLHEADER, CRYPT_STRING_BASE64X509CRLHEADER,
366          tests[i].toEncode, tests[i].toEncodeLen);
367         /* And check with the "any" formats */
368         decodeAndCompareBase64_A(tests[i].base64, NULL, NULL,
369          CRYPT_STRING_BASE64_ANY, CRYPT_STRING_BASE64, tests[i].toEncode,
370          tests[i].toEncodeLen);
371         /* Don't check with no header and the string_any format, that'll
372          * always succeed.
373          */
374         decodeAndCompareBase64_A(tests[i].base64, CERT_HEADER, CERT_TRAILER,
375          CRYPT_STRING_BASE64_ANY, CRYPT_STRING_BASE64HEADER, tests[i].toEncode,
376          tests[i].toEncodeLen);
377         decodeAndCompareBase64_A(tests[i].base64, CERT_HEADER, CERT_TRAILER,
378          CRYPT_STRING_ANY, CRYPT_STRING_BASE64HEADER, tests[i].toEncode,
379          tests[i].toEncodeLen);
380         /* oddly, these seem to decode using the wrong format
381         decodeAndCompareBase64_A(tests[i].base64, CERT_REQUEST_HEADER,
382          CERT_REQUEST_TRAILER, CRYPT_STRING_BASE64_ANY,
383          CRYPT_STRING_BASE64REQUESTHEADER, tests[i].toEncode,
384          tests[i].toEncodeLen);
385         decodeAndCompareBase64_A(tests[i].base64, CERT_REQUEST_HEADER,
386          CERT_REQUEST_TRAILER, CRYPT_STRING_ANY,
387          CRYPT_STRING_BASE64REQUESTHEADER, tests[i].toEncode,
388          tests[i].toEncodeLen);
389         decodeAndCompareBase64_A(tests[i].base64, X509_HEADER, X509_TRAILER,
390          CRYPT_STRING_BASE64_ANY, CRYPT_STRING_BASE64X509CRLHEADER,
391          tests[i].toEncode, tests[i].toEncodeLen);
392         decodeAndCompareBase64_A(tests[i].base64, X509_HEADER, X509_TRAILER,
393          CRYPT_STRING_ANY, CRYPT_STRING_BASE64X509CRLHEADER, tests[i].toEncode,
394          tests[i].toEncodeLen);
395          */
396     }
397     /* And again, with no CR--decoding handles this automatically */
398     for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++)
399     {
400         bufLen = 0;
401         /* Bogus length--oddly enough, that succeeds, even though it's not
402          * properly padded.
403          */
404         ret = pCryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64,
405          NULL, &bufLen, NULL, NULL);
406         todo_wine ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
407         /* Check with the precise format */
408         decodeAndCompareBase64_A(testsNoCR[i].base64, NULL, NULL,
409          CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, testsNoCR[i].toEncode,
410          testsNoCR[i].toEncodeLen);
411         decodeAndCompareBase64_A(testsNoCR[i].base64, CERT_HEADER, CERT_TRAILER,
412          CRYPT_STRING_BASE64HEADER, CRYPT_STRING_BASE64HEADER,
413          testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen);
414         decodeAndCompareBase64_A(testsNoCR[i].base64, CERT_REQUEST_HEADER,
415          CERT_REQUEST_TRAILER, CRYPT_STRING_BASE64REQUESTHEADER,
416          CRYPT_STRING_BASE64REQUESTHEADER, testsNoCR[i].toEncode,
417          testsNoCR[i].toEncodeLen);
418         decodeAndCompareBase64_A(testsNoCR[i].base64, X509_HEADER, X509_TRAILER,
419          CRYPT_STRING_BASE64X509CRLHEADER, CRYPT_STRING_BASE64X509CRLHEADER,
420          testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen);
421         /* And check with the "any" formats */
422         decodeAndCompareBase64_A(testsNoCR[i].base64, NULL, NULL,
423          CRYPT_STRING_BASE64_ANY, CRYPT_STRING_BASE64, testsNoCR[i].toEncode,
424          testsNoCR[i].toEncodeLen);
425         /* Don't check with no header and the string_any format, that'll
426          * always succeed.
427          */
428         decodeAndCompareBase64_A(testsNoCR[i].base64, CERT_HEADER, CERT_TRAILER,
429          CRYPT_STRING_BASE64_ANY, CRYPT_STRING_BASE64HEADER,
430          testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen);
431         decodeAndCompareBase64_A(testsNoCR[i].base64, CERT_HEADER, CERT_TRAILER,
432          CRYPT_STRING_ANY, CRYPT_STRING_BASE64HEADER, testsNoCR[i].toEncode,
433          testsNoCR[i].toEncodeLen);
434     }
435 }
436
437 START_TEST(base64)
438 {
439     HMODULE lib = GetModuleHandleA("crypt32");
440
441     pCryptBinaryToStringA = (void *)GetProcAddress(lib, "CryptBinaryToStringA");
442     pCryptStringToBinaryA = (void *)GetProcAddress(lib, "CryptStringToBinaryA");
443
444     if (pCryptBinaryToStringA)
445         testBinaryToStringA();
446     else
447         win_skip("CryptBinaryToStringA is not available\n");
448
449     if (pCryptStringToBinaryA)
450         testStringToBinaryA();
451     else
452         win_skip("CryptStringToBinaryA is not available\n");
453 }