main.c 18.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Miscellaneous crypt32 tests
 *
 * Copyright 2005 Juan Lang
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22 23 24 25 26
 */

#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <wincrypt.h>
27
#include <winreg.h>
28 29 30

#include "wine/test.h"

31
static HMODULE hCrypt;
32

33 34 35
static void test_findAttribute(void)
{
    PCRYPT_ATTRIBUTE ret;
Mike McCormack's avatar
Mike McCormack committed
36
    BYTE blobbin[] = {0x02,0x01,0x01};
37
    static CHAR oid[] = "1.2.3";
Mike McCormack's avatar
Mike McCormack committed
38
    CRYPT_ATTR_BLOB blobs[] = { { sizeof blobbin, blobbin }, };
39
    CRYPT_ATTRIBUTE attr = { oid, sizeof(blobs) / sizeof(blobs[0]), blobs };
40 41 42 43 44

    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindAttribute(NULL, 0, NULL);
    ok(ret == NULL, "Expected failure\n");
45
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
46
     GetLastError());
47 48 49
    if (0)
    {
        /* crashes */
50
        CertFindAttribute(NULL, 1, NULL);
51 52 53 54 55 56 57 58 59
        /* returns NULL, last error is ERROR_INVALID_PARAMETER
         * crashes on Vista
         */
        SetLastError(0xdeadbeef);
        ret = CertFindAttribute(NULL, 1, &attr);
        ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
         GetLastError());
    }
60 61 62 63
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindAttribute("bogus", 1, &attr);
    ok(ret == NULL, "Expected failure\n");
64
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
65 66 67 68 69
     GetLastError());
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindAttribute("1.2.4", 1, &attr);
    ok(ret == NULL, "Expected failure\n");
70
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
71 72 73 74
     GetLastError());
    /* succeeds, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindAttribute("1.2.3", 1, &attr);
75
    ok(ret != NULL, "CertFindAttribute failed: %08x\n", GetLastError());
76 77 78 79 80
}

static void test_findExtension(void)
{
    PCERT_EXTENSION ret;
81
    static CHAR oid[] = "1.2.3";
Mike McCormack's avatar
Mike McCormack committed
82
    BYTE blobbin[] = {0x02,0x01,0x01};
83
    CERT_EXTENSION ext = { oid, TRUE, { sizeof blobbin, blobbin } };
84 85 86 87 88

    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindExtension(NULL, 0, NULL);
    ok(ret == NULL, "Expected failure\n");
89
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
90
     GetLastError());
91 92 93 94
    if (0)
    {
        /* crashes */
        SetLastError(0xdeadbeef);
95
        CertFindExtension(NULL, 1, NULL);
96 97 98 99 100 101 102 103 104
        /* returns NULL, last error is ERROR_INVALID_PARAMETER
         * crashes on Vista
         */
        SetLastError(0xdeadbeef);
        ret = CertFindExtension(NULL, 1, &ext);
        ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
         GetLastError());
    }
105 106 107 108
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindExtension("bogus", 1, &ext);
    ok(ret == NULL, "Expected failure\n");
109
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
110 111 112 113 114
     GetLastError());
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindExtension("1.2.4", 1, &ext);
    ok(ret == NULL, "Expected failure\n");
115
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
116 117 118 119
     GetLastError());
    /* succeeds, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindExtension("1.2.3", 1, &ext);
120
    ok(ret != NULL, "CertFindExtension failed: %08x\n", GetLastError());
121 122 123 124 125
}

static void test_findRDNAttr(void)
{
    PCERT_RDN_ATTR ret;
126
    static CHAR oid[] = "1.2.3";
Mike McCormack's avatar
Mike McCormack committed
127
    BYTE bin[] = { 0x16,0x09,'J','u','a','n',' ','L','a','n','g' };
128
    CERT_RDN_ATTR attrs[] = {
129
     { oid, CERT_RDN_IA5_STRING, { sizeof bin, bin } },
130 131 132 133 134 135
    };
    CERT_RDN rdns[] = {
     { sizeof(attrs) / sizeof(attrs[0]), attrs },
    };
    CERT_NAME_INFO nameInfo = { sizeof(rdns) / sizeof(rdns[0]), rdns };

136 137 138 139
    if (0)
    {
        /* crashes */
        SetLastError(0xdeadbeef);
140
        CertFindRDNAttr(NULL, NULL);
141 142 143 144 145 146 147 148 149
        /* returns NULL, last error is ERROR_INVALID_PARAMETER
         * crashes on Vista
         */
        SetLastError(0xdeadbeef);
        ret = CertFindRDNAttr(NULL, &nameInfo);
        ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
         GetLastError());
    }
150 151 152 153
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindRDNAttr("bogus", &nameInfo);
    ok(ret == NULL, "Expected failure\n");
154
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
155 156 157 158 159
     GetLastError());
    /* returns NULL, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindRDNAttr("1.2.4", &nameInfo);
    ok(ret == NULL, "Expected failure\n");
160
    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
161 162 163 164
     GetLastError());
    /* succeeds, last error not set */
    SetLastError(0xdeadbeef);
    ret = CertFindRDNAttr("1.2.3", &nameInfo);
165
    ok(ret != NULL, "CertFindRDNAttr failed: %08x\n", GetLastError());
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
}

static void test_verifyTimeValidity(void)
{
    SYSTEMTIME sysTime;
    FILETIME fileTime;
    CERT_INFO info = { 0 };
    LONG ret;

    GetSystemTime(&sysTime);
    SystemTimeToFileTime(&sysTime, &fileTime);
    /* crashes
    ret = CertVerifyTimeValidity(NULL, NULL);
    ret = CertVerifyTimeValidity(&fileTime, NULL);
     */
    /* Check with 0 NotBefore and NotAfter */
    ret = CertVerifyTimeValidity(&fileTime, &info);
183
    ok(ret == 1, "Expected 1, got %d\n", ret);
184 185 186
    memcpy(&info.NotAfter, &fileTime, sizeof(info.NotAfter));
    /* Check with NotAfter equal to comparison time */
    ret = CertVerifyTimeValidity(&fileTime, &info);
187
    ok(ret == 0, "Expected 0, got %d\n", ret);
188 189 190 191
    /* Check with NotBefore after comparison time */
    memcpy(&info.NotBefore, &fileTime, sizeof(info.NotBefore));
    info.NotBefore.dwLowDateTime += 5000;
    ret = CertVerifyTimeValidity(&fileTime, &info);
192
    ok(ret == -1, "Expected -1, got %d\n", ret);
193 194
}

195 196 197 198 199
static void test_cryptAllocate(void)
{
    LPVOID buf;

    buf = CryptMemAlloc(0);
200
    ok(buf != NULL, "CryptMemAlloc failed: %08x\n", GetLastError());
201
    CryptMemFree(buf);
202
    /* CryptMemRealloc(NULL, 0) fails pre-Vista */
203 204
    buf = CryptMemAlloc(0);
    buf = CryptMemRealloc(buf, 1);
205
    ok(buf != NULL, "CryptMemRealloc failed: %08x\n", GetLastError());
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
    CryptMemFree(buf);
}

typedef DWORD  (WINAPI *I_CryptAllocTlsFunc)(void);
typedef LPVOID (WINAPI *I_CryptDetachTlsFunc)(DWORD dwTlsIndex);
typedef LPVOID (WINAPI *I_CryptGetTlsFunc)(DWORD dwTlsIndex);
typedef BOOL   (WINAPI *I_CryptSetTlsFunc)(DWORD dwTlsIndex, LPVOID lpTlsValue);
typedef BOOL   (WINAPI *I_CryptFreeTlsFunc)(DWORD dwTlsIndex, DWORD unknown);

static I_CryptAllocTlsFunc pI_CryptAllocTls;
static I_CryptDetachTlsFunc pI_CryptDetachTls;
static I_CryptGetTlsFunc pI_CryptGetTls;
static I_CryptSetTlsFunc pI_CryptSetTls;
static I_CryptFreeTlsFunc pI_CryptFreeTls;

static void test_cryptTls(void)
{
223 224
    DWORD index;
    BOOL ret;
225

226 227 228 229 230 231 232 233 234 235
    pI_CryptAllocTls = (I_CryptAllocTlsFunc)GetProcAddress(hCrypt,
     "I_CryptAllocTls");
    pI_CryptDetachTls = (I_CryptDetachTlsFunc)GetProcAddress(hCrypt,
     "I_CryptDetachTls");
    pI_CryptGetTls = (I_CryptGetTlsFunc)GetProcAddress(hCrypt,
     "I_CryptGetTls");
    pI_CryptSetTls = (I_CryptSetTlsFunc)GetProcAddress(hCrypt,
     "I_CryptSetTls");
    pI_CryptFreeTls = (I_CryptFreeTlsFunc)GetProcAddress(hCrypt,
     "I_CryptFreeTls");
236

237 238
    /* One normal pass */
    index = pI_CryptAllocTls();
239
    ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
240 241 242
    if (index)
    {
        LPVOID ptr;
243

244 245 246
        ptr = pI_CryptGetTls(index);
        ok(!ptr, "Expected NULL\n");
        ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
247
        ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
248 249 250 251 252 253
        ptr = pI_CryptGetTls(index);
        ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
        /* This crashes
        ret = pI_CryptFreeTls(index, 1);
         */
        ret = pI_CryptFreeTls(index, 0);
254
        ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
255
        ret = pI_CryptFreeTls(index, 0);
256 257
        ok(!ret, "I_CryptFreeTls succeeded\n");
        ok(GetLastError() == E_INVALIDARG,
258
         "Expected E_INVALIDARG, got %08x\n", GetLastError());
259 260 261
    }
    /* Similar pass, check I_CryptDetachTls */
    index = pI_CryptAllocTls();
262
    ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
263 264 265
    if (index)
    {
        LPVOID ptr;
266

267 268 269
        ptr = pI_CryptGetTls(index);
        ok(!ptr, "Expected NULL\n");
        ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
270
        ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
271 272 273 274 275 276
        ptr = pI_CryptGetTls(index);
        ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
        ptr = pI_CryptDetachTls(index);
        ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
        ptr = pI_CryptGetTls(index);
        ok(!ptr, "Expected NULL\n");
277 278 279
    }
}

280 281 282 283 284
typedef BOOL (WINAPI *I_CryptReadTrustedPublisherDWORDValueFromRegistryFunc)
 (LPCWSTR, DWORD *);

static void test_readTrustedPublisherDWORD(void)
{
285
    I_CryptReadTrustedPublisherDWORDValueFromRegistryFunc pReadDWORD;
286

287 288 289 290
    pReadDWORD = 
     (I_CryptReadTrustedPublisherDWORDValueFromRegistryFunc)GetProcAddress(
     hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry");
    if (pReadDWORD)
291
    {
292 293 294 295 296 297 298 299 300 301
        static const WCHAR safer[] = { 
         'S','o','f','t','w','a','r','e','\\',
         'P','o','l','i','c','i','e','s','\\',
         'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
         'C','e','r','t','i','f','i','c','a','t','e','s','\\',
         'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',
         '\\','S','a','f','e','r',0 };
        static const WCHAR authenticodeFlags[] = { 'A','u','t','h','e','n',
         't','i','c','o','d','e','F','l','a','g','s',0 };
        BOOL ret, exists = FALSE;
302
        DWORD size, readFlags = 0, returnedFlags;
303 304
        HKEY key;
        LONG rc;
305

306 307
        rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, safer, &key);
        if (rc == ERROR_SUCCESS)
308
        {
309 310 311
            size = sizeof(readFlags);
            rc = RegQueryValueExW(key, authenticodeFlags, NULL, NULL,
             (LPBYTE)&readFlags, &size);
312
            if (rc == ERROR_SUCCESS)
313
                exists = TRUE;
314
        }
315
        returnedFlags = 0xdeadbeef;
316 317
        ret = pReadDWORD(authenticodeFlags, &returnedFlags);
        ok(ret == exists, "Unexpected return value\n");
318
        ok(readFlags == returnedFlags,
319
         "Expected flags %08x, got %08x\n", readFlags, returnedFlags);
320 321 322
    }
}

323 324 325 326 327 328 329 330 331 332 333 334 335
typedef HCRYPTPROV (WINAPI *I_CryptGetDefaultCryptProvFunc)(DWORD w);

static void test_getDefaultCryptProv(void)
{
    I_CryptGetDefaultCryptProvFunc pI_CryptGetDefaultCryptProv;
    HCRYPTPROV prov;

    pI_CryptGetDefaultCryptProv = (I_CryptGetDefaultCryptProvFunc)
     GetProcAddress(hCrypt, "I_CryptGetDefaultCryptProv");
    if (!pI_CryptGetDefaultCryptProv) return;

    prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
    ok(prov == 0 && GetLastError() == E_INVALIDARG,
336
     "Expected E_INVALIDARG, got %08x\n", GetLastError());
337 338
    prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
    ok(prov == 0 && GetLastError() == E_INVALIDARG,
339
     "Expected E_INVALIDARG, got %08x\n", GetLastError());
340 341
    prov = pI_CryptGetDefaultCryptProv(1);
    ok(prov == 0 && GetLastError() == E_INVALIDARG,
342
     "Expected E_INVALIDARG, got %08x\n", GetLastError());
343
    prov = pI_CryptGetDefaultCryptProv(0);
344
    ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError());
345 346 347
    CryptReleaseContext(prov, 0);
}

348 349 350 351 352 353 354 355 356 357 358 359
typedef int (WINAPI *I_CryptInstallOssGlobal)(DWORD,DWORD,DWORD);

static void test_CryptInstallOssGlobal(void)
{
    int ret,i;
    I_CryptInstallOssGlobal pI_CryptInstallOssGlobal;

    pI_CryptInstallOssGlobal= (I_CryptInstallOssGlobal)GetProcAddress(hCrypt,"I_CryptInstallOssGlobal");
    /* passing in some random values to I_CryptInstallOssGlobal, it always returns 9 the first time, then 10, 11 etc.*/
    for(i=0;i<30;i++)
    {
      ret =  pI_CryptInstallOssGlobal(rand(),rand(),rand());
360 361 362
      ok((9+i) == ret ||
         ret == 0, /* Vista */
         "Expected %d or 0, got %d\n",(9+i),ret);
363 364 365
    }
}

366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
static BOOL (WINAPI *pCryptFormatObject)(DWORD dwEncoding, DWORD dwFormatType,
 DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
 const BYTE *pbEncoded, DWORD dwEncoded, void *pbFormat, DWORD *pcbFormat);

static const BYTE encodedInt[] = { 0x02,0x01,0x01 };
static const WCHAR encodedIntStr[] = { '0','2',' ','0','1',' ','0','1',0 };
static const BYTE encodedBigInt[] = { 0x02,0x1f,0x01,0x02,0x03,0x04,0x05,0x06,
 0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,
 0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f };
static const WCHAR encodedBigIntStr[] = { '0','2',' ','1','f',' ','0','1',' ',
 '0','2',' ','0','3',' ','0','4',' ','0','5',' ','0','6',' ','0','7',' ','0',
 '8',' ','0','9',' ','0','a',' ','0','b',' ','0','c',' ','0','d',' ','0','e',
 ' ','0','f',' ','1','0',' ','1','1',' ','1','2',' ','1','3',' ','1','4',' ',
 '1','5',' ','1','6',' ','1','7',' ','1','8',' ','1','9',' ','1','a',' ','1',
 'b',' ','1','c',' ','1','d',' ','1','e',' ','1','f',0 };

static void test_format_object(void)
{
    BOOL ret;
    DWORD size;
    LPWSTR str;

    pCryptFormatObject = (void *)GetProcAddress(hCrypt, "CryptFormatObject");
    if (!pCryptFormatObject)
    {
        skip("No CryptFormatObject\n");
        return;
    }
    /* Crash */
    if (0)
    {
397
        pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL);
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
    }
    /* When called with any but the default encoding, it fails to find a
     * formatting function.
     */
    SetLastError(0xdeadbeef);
    ret = pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
    ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
     "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
    /* When called with the default encoding type for any undefined struct type
     * (including none), it succeeds:  the default encoding is a hex string
     * encoding.
     */
    SetLastError(0xdeadbeef);
    ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
     NULL, &size);
    ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
    if (ret)
    {
416 417 418 419 420
        if (size == 0 && GetLastError() == ERROR_FILE_NOT_FOUND)
        {
            win_skip("CryptFormatObject has no default implementation\n");
            return;
        }
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
        ok(size == sizeof(WCHAR), "unexpected size %d\n", size);
        str = HeapAlloc(GetProcessHeap(), 0, size);
        SetLastError(0xdeadbeef);
        size = 0;
        ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
         str, &size);
        ok(!ret && GetLastError() == ERROR_MORE_DATA,
         "expected ERROR_MORE_DATA, got %d\n", GetLastError());
        size = sizeof(WCHAR);
        ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
         str, &size);
        ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
        ok(!str[0], "expected empty string\n");
        HeapFree(GetProcessHeap(), 0, str);
    }
    ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
     sizeof(encodedInt), NULL, &size);
    ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
    if (ret)
    {
        str = HeapAlloc(GetProcessHeap(), 0, size);
        ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
         encodedInt, sizeof(encodedInt), str, &size);
        ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
        ok(!lstrcmpW(str, encodedIntStr), "unexpected format string\n");
        HeapFree(GetProcessHeap(), 0, str);
    }
    ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
     encodedBigInt, sizeof(encodedBigInt), NULL, &size);
    ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
    if (ret)
    {
        str = HeapAlloc(GetProcessHeap(), 0, size);
        ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
         encodedBigInt, sizeof(encodedBigInt), str, &size);
        ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
457
        ok(!lstrcmpiW(str, encodedBigIntStr), "unexpected format string\n");
458 459 460 461 462 463 464 465 466
        HeapFree(GetProcessHeap(), 0, str);
    }
    /* When called with the default encoding type for any undefined struct
     * type but CRYPT_FORMAT_STR_NO_HEX specified, it fails to find a
     * formatting function.
     */
    SetLastError(0xdeadbeef);
    ret = pCryptFormatObject(X509_ASN_ENCODING, 0, CRYPT_FORMAT_STR_NO_HEX,
     NULL, NULL, NULL, 0, NULL, &size);
467 468 469 470
    ok(!ret, "CryptFormatObject succeeded\n");
    ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
     GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
     "expected ERROR_FILE_NOT_FOUND or no change, got %d\n", GetLastError());
471 472 473 474 475 476 477 478 479 480
    /* When called to format an AUTHORITY_KEY_ID2_INFO, it fails when no
     * data are given.
     */
    SetLastError(0xdeadbeef);
    ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL,
     szOID_AUTHORITY_KEY_IDENTIFIER2, NULL, 0, NULL, &size);
    ok(!ret && GetLastError() == E_INVALIDARG,
     "expected E_INVALIDARG, got %d\n", GetLastError());
}

481 482
START_TEST(main)
{
483 484
    hCrypt = GetModuleHandleA("crypt32.dll");

485 486 487 488
    test_findAttribute();
    test_findExtension();
    test_findRDNAttr();
    test_verifyTimeValidity();
489 490
    test_cryptAllocate();
    test_cryptTls();
491
    test_readTrustedPublisherDWORD();
492
    test_getDefaultCryptProv();
493
    test_CryptInstallOssGlobal();
494
    test_format_object();
495
}